Topic hub

Building and maintaining MCP servers

How a program gives a language model tools, data, and prompts through the Model Context Protocol, from both sides of the wire, from the first message to a server that keeps working as it changes.

The problem

A language model on its own can only produce text. To check the weather, read a file, or add a calendar entry, the app around it has to run real code and hand the result back. Before the Model Context Protocol (MCP), every app wired up every integration its own way, so a tool built for one assistant did not work in another.

MCP is a shared contract for that wiring. A server offers tools, data, and prompt templates. A host (the app a person uses) runs one client per server and lets the model use what the servers offer. Write a server once and any MCP host can use it. Write a host once and any MCP server plugs in.

This cluster covers both sides: what goes over the wire, how to design a server a model can use well, how to build one in Python, how a client and host drive it, how to keep it secure, and how to keep it working as it and the protocol change. It is written against the 2026-07-28 revision of the specification, which made the protocol stateless: no handshake, no sessions, every request self-contained. Follow the "Before this" links down until you reach something you already know, then read back up.

The pipeline

Every page points back to this picture of a server's life.

Stage Question it answers Techniques that live here
1. Speak the protocol What does an MCP message look like, and how do two sides agree on a version? Anatomy of an MCP request, Version negotiation
2. Design the surface Which tools, resources, and prompts should the server offer, with what schemas, and when does it need to ask for more input? Designing tools, Resources and prompts, Multi round-trip requests
3. Build and connect How does a Python server run, and how do a client and host reach it? Building a server in Python, Transports: stdio and Streamable HTTP, Building a client, The host loop
4. Secure it Who may call the server, and what can go wrong when a model is the caller? Authorization for remote servers, Security threats and defenses
5. Test and ship How do you know it works, and how does it run somewhere other than your laptop? Testing MCP servers, Deploying remote servers
6. Maintain it How does it change without breaking the clients that depend on it, and how do you see what it is doing? Evolving a server without breaking clients, Observability and operations

Stages 2 and 6 are where most of the long-term cost sits. A tool with a vague description gets called at the wrong times by every model that ever sees it, and a careless rename breaks every client that was built against the old name. Neither shows up as a crash on your own machine.

Which page for which job

You have never seen MCP before. Read Anatomy of an MCP request, then Designing tools, then Building a server in Python. That is the shortest path to a server that runs.

You are building a host or an agent that uses servers. Start at Building a client and The host loop, then read Security threats and defenses before anything you build reads untrusted data.

Your server works locally and now has to run for other people. Transports, then Authorization for remote servers, then Deploying remote servers.

People already depend on your server. Evolving a server without breaking clients and Version negotiation, with Testing MCP servers for the snapshot test that catches accidental breaking changes.

The model keeps calling the wrong tool, or calling the right one badly. That is a design problem, not a code problem: Designing tools, then the "How language models use tools" prerequisite underneath it.

The basics underneath

None of these needs more than first-year college material and a little programming.

You need For
JSON The text format of every message.
Processes and standard streams How a host launches a local server and talks to it over stdin and stdout.
HTTP basics How a remote server receives requests and streams responses.
Python essentials for MCP Type hints, decorators, and async, which every sample uses.
JSON-RPC The request, response, and error shapes MCP is built on.
JSON Schema How a tool says what arguments it accepts and what it returns.
How language models use tools What "the model calls a tool" actually means, and why descriptions matter so much.
OAuth basics Tokens, scopes, and the authorization code flow behind remote-server auth.
API contracts and versioning Which changes keep a promise to other programs and which break it.
Trust boundaries and threat models How to think about untrusted input when the reader is a model.

Conventions used across this cluster

  • Spec revision 2026-07-28. Where older revisions behaved differently, a page says so in one sentence starting "Older servers". Roots, Sampling, and Logging are deprecated in this revision; pages mention them only to say what replaces them.
  • Roles: the host is the app the person uses, a client is the host's connection to one server, a server offers tools, resources, and prompts, and the model is the language model inside the host.
  • Code is Python with the official MCP SDK, version 2. Every sample ran before it was published, and each shows the command that runs it and the output it printed. Python attribute names are snake_case (input_schema) while the wire format is camelCase (inputSchema).
  • Wire messages are shown as pretty-printed JSON with field names exactly as the specification spells them.
  • No shared running example yet. Each page uses a small illustration of its own (a unit converter, a notes store, a weather lookup). The server, client, and testing pages share one unit-converter server so the later pages have something real to drive.

Names only, no links: names stay stable and download pages do not.

Job Pick Why Also fine
Writing servers and clients The official MCP Python SDK (package mcp, version 2) Speaks the 2026-07-28 revision and still serves older clients. Builds schemas from type hints. The official SDK for TypeScript, or for another language you already use
Poking at a server by hand MCP Inspector Connects to a server over stdio or HTTP and lets you list and call everything it offers, with the raw messages visible. A short script using the SDK's client
Using a server from a real assistant Any MCP host, such as Claude Desktop, Claude Code, or VS Code Shows how a model actually picks and calls your tools. Any other host that supports MCP
Python environments uv Creates the virtual environment and installs the SDK in one step. Python's built-in venv and pip
Testing pytest with pytest-asyncio The SDK's client is async, and these run async tests directly.

How to read this cluster

The learning path below is sorted so that each row depends only on the rows above it. If you already write Python and know HTTP, skip to Anatomy of an MCP request. If you only build hosts, the server-building pages are still worth a skim: most host bugs are a misunderstanding of what the server promised.

Learning path

Each row depends only on rows above it. Read top to bottom, or jump to a technique and follow its "Before this" links downward.