# How MCP Servers Work: Message Flow and Transports

> Canonical: https://skillalmanac.com/learn/how-mcp-servers-work | Updated: 2026-11-25 | Index status: index-eligible

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.

## Facts

- 2026-11-25 current-source check for the 2026-07-28 architecture: a host creates one MCP client per server, and each client maintains a dedicated connection to its corresponding server (https://modelcontextprotocol.io/docs/learn/architecture)
- 2025-06-18 normative frame, verified 2026-11-25: the client begins with initialize, waits for its response before sending requests other than pings, and then sends notifications/initialized (https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle)
- 2025-06-18 normative frame, verified 2026-11-25: a server advertising tools.listChanged should send notifications/tools/list_changed when its tool list changes (https://modelcontextprotocol.io/specification/2025-06-18/server/tools)
- 2025-06-18 normative frame, verified 2026-11-25: stdio messages are newline-delimited JSON-RPC with no embedded newlines, and a server must not write non-MCP text to stdout (https://modelcontextprotocol.io/specification/2025-06-18/basic/transports)
- 2025-06-18 normative frame, verified 2026-11-25: Streamable HTTP servers must validate Origin, should bind to localhost when local, and may use optional session identifiers (https://modelcontextprotocol.io/specification/2025-06-18/basic/transports)
- 2025-06-18 normative frame, verified 2026-11-25: HTTP 404 for a request carrying Mcp-Session-Id requires the client to start a new session with an InitializeRequest that carries no session ID (https://modelcontextprotocol.io/specification/2025-06-18/basic/transports)
- 2026-11-25 current-source check for protocol revision 2026-07-28: MCP is stateless, every request carries protocol and capability metadata, change notifications use opt-in subscription streams and are best-effort, and clients should also poll to preserve freshness (https://modelcontextprotocol.io/docs/learn/architecture)
- 2025-06-18 normative frame, verified 2026-11-25: authorization is optional; the defined authorization flow applies to HTTP transports rather than stdio (https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization)

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.

1. **Initialize.** The client sends an `initialize` request 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.
2. **Confirm readiness.** The client sends a `notifications/initialized` notification. Normal operation starts after that.
3. **Listing.** The client sends `tools/list` and 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.
4. **Calling.** When the model picks a tool, the host routes the request to the client that owns it. That client sends `tools/call` with the exact listed name, such as `weather_current`, and an `arguments` object such as `{"location": "San Francisco", "units": "imperial"}`. The server returns a `content` array, and the host passes that result back into the conversation.
5. **Change notices.** A server that declared `listChanged` for tools should send `notifications/tools/list_changed` when its tool set changes. The client then sends `tools/list` again.

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

1. **Corrupted stdio output.** A stray `print` in a stdio server writes non-protocol text to stdout, and the client reports parse errors at startup. Fix: send logs to stderr only.
2. **Tool name mismatch.** `tools/call` must use the exact name from the last `tools/list` response. If you see unknown-tool errors after a rename, list the tools again and check the name.
3. **Stale tool lists.** Under 2025-06-18, a server that advertises the tools `listChanged` capability should send `notifications/tools/list_changed`, after which the client can refresh with `tools/list`. Under 2026-07-28, change notifications additionally require an opt-in `subscriptions/listen` stream and remain best-effort across reconnects, so clients should also poll to preserve freshness.
4. **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.
5. **Expired sessions.** A 404 response to a request carrying `Mcp-Session-Id` means 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](/skills/skill-almanac/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

- [mcp-server-builder](https://skillalmanac.com/skills/skill-almanac/mcp-server-builder.md): Platform Score 56/100 (provisional)

## Related guides

- [Debug an MCP Server with MCP Inspector](https://skillalmanac.com/learn/debug-an-mcp-server-with-inspector.md)
- [MCP Tools, Resources, and Prompts: Which to Use](https://skillalmanac.com/learn/mcp-tools-resources-prompts.md)
- [What Are MCP Apps? Interactive UI in AI Chats](https://skillalmanac.com/learn/what-are-mcp-apps.md)
- [MCP Server Examples: Learning From a Reference Server](https://skillalmanac.com/learn/mcp-server-examples.md)
- [Cloudflare MCP servers: endpoints, access and permissions](https://skillalmanac.com/learn/cloudflare-mcp-guide.md)

## Sources

- https://modelcontextprotocol.io/docs/learn/architecture
- https://modelcontextprotocol.io/specification/2025-06-18/basic/lifecycle
- https://modelcontextprotocol.io/specification/2025-06-18/server/tools
- https://modelcontextprotocol.io/specification/2025-06-18/server/resources
- https://modelcontextprotocol.io/specification/2025-06-18/basic/transports
- https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization
- https://modelcontextprotocol.io/docs/2026-07-28/learn/architecture

Platform Scores report our assessment under a published method. They are not a safety guarantee.
