How MCP Servers Work: Message Flow and Transports
An MCP server is reached through a client the host creates for it, exchanging JSON-RPC messages over stdio or Streamable HTTP. Here is the flow.
Updated · Markdown version
An MCP server is a program that offers tools, resources and prompts to an AI application, and the application reaches it through a client object created for that server. The two sides exchange JSON-RPC 2.0 messages over one of the two standard transports: stdio for a host-launched local subprocess or Streamable HTTP for an independently running HTTP endpoint. The 2025-06-18 specification also permits custom transports that preserve MCP's message and lifecycle requirements.
The three participants
The host is the AI app itself, for example Claude Code or Claude Desktop. For each server the host connects to, it creates one client, and that client keeps a dedicated connection to its server. The server is the process that provides context. It may run on your own computer or on a hosted platform. A local stdio server typically serves one client. A remote Streamable HTTP server typically serves many clients at once.
Message flow in protocol version 2025-06-18
Steps 1–5 below are the normative connection lifecycle for protocol revision 2025-06-18. They do not describe the current 2026-07-28 architecture checked on 2026-11-25: that revision is stateless, carries protocol version and relevant capabilities in each request's _meta, and lets a client call the mandatory server method server/discover before other work, although making that discovery call is optional. Check which revision your SDK implements before copying either sequence.
- Initialize. The client sends an
initializerequest with the protocol version it supports and its capabilities. The server replies with the version it will use and its own capabilities. Until that reply arrives, the client should send only pings. - Confirm readiness. The client sends a
notifications/initializednotification. Normal operation starts after that. - Listing. The client sends
tools/listand gets back each tool's name, description, and a JSON Schema describing its inputs. The host adds those tools to the set of actions the model can request. - Calling. When the model picks a tool, the host routes the request to the client that owns it. That client sends
tools/callwith the exact listed name, such asweather_current, and anargumentsobject such as{"location": "San Francisco", "units": "imperial"}. The server returns acontentarray, and the host passes that result back into the conversation. - Change notices. A server that declared
listChangedfor tools should sendnotifications/tools/list_changedwhen its tool set changes. The client then sendstools/listagain.
Other server primitives have their own methods: clients list and read URI-addressed resources with resources/list and resources/read, list resource templates with resources/templates/list, and list and retrieve prompt templates with prompts/list and prompts/get.
Transport options
stdio runs the server as a child process. The host writes one JSON-RPC message per line to the server's stdin and reads replies from stdout. Server logs go to stderr.
Streamable HTTP in the 2025-06-18 specification exposes one endpoint supporting POST and GET. Each client message is a new POST; a request receives either one JSON response or an SSE stream, while an accepted notification or response receives HTTP 202 with no body. Authorization is optional, and the 2025 HTTP authorization specification defines an OAuth-based flow when it is supported. Separately, the current 2026-07-28 architecture notes that HTTP deployments can use standard methods such as bearer tokens, API keys or custom headers and recommends OAuth for obtaining tokens.
| Question | stdio | Streamable HTTP |
|---|---|---|
| Where the server runs | Same machine, as a subprocess | Local or remote, as an endpoint |
| Message framing | Newline-delimited JSON-RPC | HTTP POST bodies; responses as JSON or SSE |
| Clients per server | Typically one | Typically many |
| Session identifier | Not defined by the stdio transport | Mcp-Session-Id header, if the server issues one |
Decision rule: choose stdio for a local server launched by the host as a subprocess. Choose Streamable HTTP for an independently running endpoint reached over HTTP. An HTTP endpoint can be local or remote, and authorization is a separate design choice.
What MCP is not
MCP does not prescribe an application's tool-selection policy or how it manages an LLM and its context. In the current documented flow, the model selects a tool from those made available to it, while the host application controls exposure, approval and routing of the resulting call.
Pitfalls
- Corrupted stdio output. A stray
printin a stdio server writes non-protocol text to stdout, and the client reports parse errors at startup. Fix: send logs to stderr only. - Tool name mismatch.
tools/callmust use the exact name from the lasttools/listresponse. If you see unknown-tool errors after a rename, list the tools again and check the name. - Stale tool lists. Under 2025-06-18, a server that advertises the tools
listChangedcapability should sendnotifications/tools/list_changed, after which the client can refresh withtools/list. Under 2026-07-28, change notifications additionally require an opt-insubscriptions/listenstream and remain best-effort across reconnects, so clients should also poll to preserve freshness. - Open local HTTP port. Skipping the Origin check lets a web page reach a local server through DNS rebinding. Fix: validate Origin and bind to 127.0.0.1.
- Expired sessions. A 404 response to a request carrying
Mcp-Session-Idmeans the session ended. The client must start over with an initialize request that has no session ID.
When to use a skill instead
Connecting a host to a server is a protocol question, and a reusable skill helps when the work is building a server rather than understanding one. mcp-server-builder matters once you write the server yourself, since each tool you define needs an input schema, a bounded result and a clear error, and the transport has to suit where the server runs. Use it when you are writing tools for a server and want the same review each time. For a one-time question about the message flow, this guide is enough, and no skill is needed.
FAQ
What is an MCP server and how does it work? It is a program that offers tools, resources, and prompts to a host through a client. The host lists the available items, then calls them over JSON-RPC when the model requests one.
Does an MCP server run locally or remotely? Either. A local server usually runs as a stdio subprocess. A remote server runs at an HTTP endpoint that the host reaches over Streamable HTTP.
Can one host connect to several MCP servers? Yes. The host creates a separate client for each server, and each client keeps its own connection.
Related skills in this catalog
Platform Score is our assessment under a published method. It is not a safety guarantee.
Related guides
Terms this guide uses
This item is a worked example in the AI glossary for:
Sources
- https://modelcontextprotocol.io/docs/learn/architecture (accessed 2026-11-25)
- https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle (accessed 2026-11-25)
- https://modelcontextprotocol.io/specification/2025-06-18/server/tools (accessed 2026-11-25)
- https://modelcontextprotocol.io/specification/2025-06-18/server/resources (accessed 2026-11-25)
- https://modelcontextprotocol.io/specification/2025-06-18/basic/transports (accessed 2026-11-25)
- https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization (accessed 2026-11-25)
- https://modelcontextprotocol.io/docs/2026-07-28/learn/architecture (accessed 2026-11-25)