MCP Architecture: Hosts, Clients, Servers and the Connect Phase
An editor can use a calculator and search a document collection through MCP. The editor is the host. It creates one client for each server and decides which calls its user may make.
Editor (host)
├─ Calculator client ⇄ Calculator server
└─ Search client ⇄ Document serverWhen the user asks for a sum, the host checks permission and sends the arguments through the calculator client. That client calls the calculator server with tools/call and returns the result to the host. The document server receives neither the arguments nor the result. The host controls what each server can see.
The data layer defines messages such as a tool call and its result. The transport layer carries those messages between a client and a server. For example, the calculator client can send the same tool call over stdio to a local process or over Streamable HTTP to a remote endpoint.
Through revision 2025-11-25 the client began with initialize. Revision 2026-07-28 removed that handshake. The examples below show how to recognize each exchange. The versioned architecture overview defines the protocol layers.
To see what each client really declares, read MCP clients. For what a server offers, read tools, resources and prompts; for the order in which to learn all of this, read the learning path.
1. Three roles, one connection each
| Role | What it is | What the spec gives it | What it does not do |
|---|---|---|---|
| Host | The application the user runs: an editor, a chat app | Creates and manages the clients; controls their permissions and lifecycle; enforces consent and security policy; coordinates the model and aggregates context across clients | Hand a server the whole conversation, or let one server see into another |
| Client | A connector the host creates, one per server | “Communicates with exactly one server”; attaches protocol version and capabilities to every request (2026-07-28); routes messages both ways; manages subscriptions and notifications | Serve two servers over one connection: the spec states a 1:1 relationship |
| Server | A local process or a remote service | Exposes resources, tools and prompts; “Request client input (sampling, elicitation, roots) via InputRequiredResult within a reply” (2026-07-28) | Rely on anything the client did not declare, or read the conversation |
The design principle behind the right-hand column is the third of four: “Servers should not be able to read the whole conversation, nor “see into” other servers”. The host keeps the conversation, decides what each client may pass on, and is the only party that sees all the servers. A server that needs more context asks the client for it, and the client, which means the host, may refuse.
2. Two eras under one name
The spec names the two families itself: modern versions “convey version, identity, and capabilities as per-request metadata” (2026-07-28 and later), legacy versions “establish a session with an initialize handshake” (2025-11-25 and earlier), and a dual-era implementation supports both. The architecture page of every revision from 2024-11-05 to 2025-11-25 calls MCP “a stateful session protocol” with “one stateful session per server”; the 2026-07-28 page calls it “a stateless protocol: every request is self-contained”.
| Legacy (2024-11-05 to 2025-11-25) | Modern (2026-07-28) | |
|---|---|---|
| First message | initialize, which MUST be the first interaction | None required. server/discover is optional for the client; every server MUST implement it |
| Where version and capabilities are declared | Once, in initialize; on HTTP the MCP-Protocol-Version header repeats the version on later requests | In the _meta of every request: protocolVersion and clientCapabilities required, clientInfo recommended |
| Signal that the session is ready | notifications/initialized, which the client MUST send | None: the handshake and the notification are gone |
| A request that lacks the declaration | Not applicable: the server remembers the session | Rejected with -32602 (HTTP 400); a header that differs from _meta gets HeaderMismatch (HTTP 400) |
| How a server asks the client for something | A request of its own: roots/list, sampling/createMessage, elicitation/create | An InputRequiredResult inside the reply; the client answers in inputResponses on a retry of the original request |
| What a server must hold between requests | A session per client | Nothing: each request carries what it needs |
Two consequences follow from “self-contained”. A modern server needs no session to understand a request. And it reads the capabilities from the request in front of it, which the spec describes as the capabilities “relevant to this request”, so do not cache the first declaration you see from a client.
3. Meeting a server of the other era
Era is “a property of the server, not of an individual request”. A client that speaks both finds out by probing, and the spec gives the stdio rule in full: probe with server/discover before any other request, and treat three outcomes differently. A DiscoverResult means the server is modern. A recognized modern error such as UnsupportedProtocolVersionError also means modern: pick a version from its supported list and do not fall back. Any other error, or no answer in a reasonable time, means the server is legacy and the client falls back to initialize. The fallback “MUST NOT be keyed to one specific error code”, because legacy servers answer an unknown pre-initialize request with -32601, -32602 or nothing at all.
The spec summarizes every pairing in one matrix. The last column shows which pairings the recorded traces of section 4 cover.
| Client | Server | Spec outcome | Seen in the recorded traces |
|---|---|---|---|
| Modern | Modern | Works | — |
| Modern | Legacy | Fails | — |
| Dual-era | Modern | Works | yes |
| Dual-era | Legacy | Works | yes |
| Legacy | Modern | Fails | — |
| Legacy | Dual-era | Works | — |
| Legacy | Legacy | Works | — |
Both clients behave the way the spec asks of a dual-era client. In the legacy trace the first request is server/discover, which the legacy probe refuses; the next is initialize. A connect phase therefore has two shapes:
| Step | Legacy server | Modern server |
|---|---|---|
| 1 | server/discover is refused, then the client sends initialize with protocol version, capabilities and clientInfo | server/discover (optional), or straight to the first request |
| 2 | The server answers initialize with its own version and capabilities | The server answers; server/discover returns its capabilities |
| 3 | The client sends notifications/initialized | Nothing to acknowledge |
| 4 | Operation: later requests carry the MCP-Protocol-Version header | Operation: every request carries _meta and the header |
4. Checking a recorded connection
A trace is the list of requests a server saw from one client, each with its method, the MCP-Protocol-Version header, and what the client declared. lifecycle_check.py reads a trace and tests it against the rules of its era. It decides the era from the trace: a trace that contains initialize is legacy, any other is modern. A leading server/discover is not held against a legacy client, because the spec asks a dual-era client to open with it. The rules, and the spec wording each rests on:
| Check | Era | Level | Spec wording it rests on |
|---|---|---|---|
trace-not-empty | both | FAIL | none: a precondition for every other check |
initialize-first | legacy | FAIL | “The initialization phase MUST be the first interaction between client and server.” (2025-11-25, lifecycle) |
initialize-fields | legacy | FAIL | “The client MUST initiate this phase by sending an initialize request containing:” (2025-11-25, lifecycle) |
initialized-sent | legacy | FAIL | “After successful initialization, the client MUST send an initialized notification” (2025-11-25, lifecycle) |
initialized-before-requests | legacy | WARN | “The client SHOULD NOT send requests other than” (2025-11-25, lifecycle) |
version-header | legacy | FAIL | “If using HTTP, the client MUST include the MCP-Protocol-Version: <protocol-version> HTTP header on all subsequent requests” (2025-11-25, lifecycle) |
no-handshake-notification | modern | FAIL | “Make MCP stateless: remove the initialize/notifications/initialized handshake.” (2026-07-28, changelog) |
version-in-meta | modern | FAIL | “fields marked as required MUST be included on every request” (2026-07-28, basic; protocolVersion is marked required) |
capabilities-in-meta | modern | FAIL | “fields marked as required MUST be included on every request” (2026-07-28, basic; clientCapabilities is marked required) |
client-info-in-meta | modern | WARN | “Clients SHOULD include io.modelcontextprotocol/clientInfo on every request” (2026-07-28, basic) |
header-matches-meta | modern | FAIL | “The header value MUST match the io.modelcontextprotocol/protocolVersion field” (2026-07-28, streamable-http) |
A FAIL is a rule the spec states with “MUST” (for the removed handshake: as a change in its changelog); a WARN is one it states with “SHOULD”. lifecycle_runs.py runs the checker twice over. First over four real traces, which must all pass; then over twelve traces that were broken on purpose, each of which must be flagged by exactly the checks listed for it. A checker that never fails proves nothing, and the second half is the proof that this one can.
lifecycle_check.py
#!/usr/bin/env python3
"""Check the connect phase of a recorded client trace against the lifecycle rules of the two protocol eras.
Usage: lifecycle_check.py TRACE TRACE = a file of JSON lines as printed by client_probe_server.py, a JSON array, or -
Exit code: 0 = no FAIL (WARN is allowed), 1 = at least one FAIL, 2 = the trace cannot be read.
A record holds: method, protocol (the MCP-Protocol-Version header, or the version offered in `initialize`),
version (the protocolVersion in the `_meta` of a modern request), client ({name, version}), capabilities.
Era: a trace that contains `initialize` is legacy-era (2024-11-05 to 2025-11-25); any other trace is modern-era
(2026-07-28). A leading `server/discover` is not counted against "initialize first": the spec asks a dual-era client to probe
with it before anything else and to fall back to `initialize` when the server is legacy.
Rules, with the spec wording they rest on, are listed in the table of the architecture page.
"""
import json
import sys
LEGACY = "legacy"
MODERN = "modern"
def is_request(record):
return not record.get("method", "").startswith("notifications/")
def run_checks(records):
"""List of (level, name, detail); level is PASS, WARN or FAIL."""
out = []
def add(ok, name, detail, level="FAIL"):
out.append(("PASS" if ok else level, name, detail))
add(bool(records), "trace-not-empty", "%d records" % len(records))
if not records:
return out
methods = [r.get("method") for r in records]
era = LEGACY if "initialize" in methods else MODERN
out.append(("PASS", "era", "%s (%s `initialize`)" % (era, "has" if era == LEGACY else "no")))
if era == LEGACY:
i = methods.index("initialize")
before = [m for m in methods[:i] if m != "server/discover"]
add(not before, "initialize-first", "first interaction is `initialize`" if not before else "%s came first" % before[0])
init = records[i]
client = init.get("client") if isinstance(init.get("client"), dict) else {}
missing = [k for k, ok in (("protocol", init.get("protocol")), ("client.name", client.get("name")),
("client.version", client.get("version")),
("capabilities", isinstance(init.get("capabilities"), dict))) if not ok]
add(not missing, "initialize-fields", "protocol, clientInfo, capabilities present" if not missing else "missing " + ", ".join(missing))
after = methods[i + 1:]
add("notifications/initialized" in after, "initialized-sent", "`notifications/initialized` follows `initialize`")
if "notifications/initialized" in after:
early = [m for m in after[:after.index("notifications/initialized")] if m != "ping"]
add(not early, "initialized-before-requests", "no request before the notification" if not early
else "%s sent before it" % early[0], level="WARN")
versions = {r.get("protocol") for r in records[i + 1:]}
add(bool(records[i + 1:]) and None not in versions and len(versions) == 1, "version-header",
"every later request carries one MCP-Protocol-Version (%s)" % ", ".join(sorted(str(v) for v in versions)))
else:
requests = [r for r in records if is_request(r)]
add("notifications/initialized" not in methods, "no-handshake-notification", "no `notifications/initialized` in 2026-07-28")
for key, label, name, level in (("version", "`_meta` protocolVersion", "version-in-meta", "FAIL"),
("capabilities", "`_meta` clientCapabilities", "capabilities-in-meta", "FAIL"),
("client", "`_meta` clientInfo", "client-info-in-meta", "WARN")):
lacking = [r.get("method") for r in requests if not isinstance(r.get(key), (str, dict))]
add(not lacking, name, "every request carries %s" % label if not lacking else "%s lacks it" % lacking[0], level=level)
mismatched = [r.get("method") for r in requests if r.get("protocol") != r.get("version")]
add(not mismatched, "header-matches-meta", "MCP-Protocol-Version equals `_meta` protocolVersion" if not mismatched
else "%s differs" % mismatched[0])
return out
def load(source):
text = sys.stdin.read() if source == "-" else open(source, encoding="utf-8").read()
text = text.strip()
if text.startswith("["):
return json.loads(text)
return [json.loads(line) for line in text.splitlines() if line.strip()]
def summary(results):
return tuple(sum(1 for r in results if r[0] == level) for level in ("PASS", "WARN", "FAIL"))
def main():
if len(sys.argv) != 2:
print(__doc__.split("\n\n")[0], file=sys.stderr)
return 2
try:
records = load(sys.argv[1])
if not isinstance(records, list) or not all(isinstance(r, dict) and isinstance(r.get("method"), str) for r in records):
raise ValueError("a trace is a list of records, and every record is an object with a `method`")
except (OSError, ValueError) as exc:
print("cannot read the trace: %s" % exc, file=sys.stderr)
return 2
results = run_checks(records)
for level, name, detail in results:
print("%s %s: %s" % (level, name, detail))
passed, warned, failed = summary(results)
print("\n%d pass, %d warn, %d fail" % (passed, warned, failed))
return 1 if failed else 0
if __name__ == "__main__":
sys.exit(main())lifecycle_runs.py
#!/usr/bin/env python3
"""Run lifecycle_check over real traces and over twelve traces that were broken on purpose.
Real traces: the official Python SDK (mcp==2.3.0) against the probe of the clients page, in both eras, and the
recorded traces of Claude Code 2.1.292 (trace-claude-code.json, made by `claude_code_probe.py --save`).
Usage: lifecycle_runs.py Exit code 0 = every real trace passes and every broken trace is flagged as listed.
"""
import json
import sys
from pathlib import Path
HERE = Path(__file__).resolve().parent
sys.path.insert(0, str(HERE))
sys.path.insert(0, str(HERE.parent / "clients-check"))
import lifecycle_check as lc # noqa: E402
import probe_runs # noqa: E402
CLIENT = {"name": "demo", "version": "1"}
def rec(method, protocol=None, version=None, client=None, capabilities=None):
fields = {"method": method, "protocol": protocol, "version": version, "client": client, "capabilities": capabilities}
return {k: v for k, v in fields.items() if v is not None}
def legacy(*changes):
"""A correct legacy trace; each change is (index, record or None) that replaces or removes a record."""
base = [rec("initialize", "2025-11-25", client=CLIENT, capabilities={}), rec("notifications/initialized", "2025-11-25"),
rec("tools/list", "2025-11-25"), rec("resources/list", "2025-11-25")]
for index, record in changes:
if record is None:
base[index] = None
else:
base[index] = record
return [r for r in base if r is not None]
def modern(**drop):
"""A correct modern trace; keyword `drop` names the field to remove from the second request."""
first = rec("server/discover", "2026-07-28", "2026-07-28", CLIENT, {})
second = rec("tools/list", "2026-07-28", "2026-07-28", CLIENT, {})
for key in drop:
second.pop(key, None)
return [first, second]
BROKEN = [
("empty trace", [], [("FAIL", "trace-not-empty")]),
("legacy: a request before initialize", [rec("tools/list", "2025-11-25")] + legacy(), [("FAIL", "initialize-first")]),
("legacy: initialize without capabilities", legacy((0, rec("initialize", "2025-11-25", client=CLIENT))), [("FAIL", "initialize-fields")]),
("legacy: no initialized notification", legacy((1, None)), [("FAIL", "initialized-sent")]),
("legacy: a request before initialized", [legacy()[0], legacy()[2], legacy()[1], legacy()[3]], [("WARN", "initialized-before-requests")]),
("legacy: no protocol header later", legacy((2, rec("tools/list"))), [("FAIL", "version-header")]),
("legacy: the header changes", legacy((3, rec("resources/list", "2025-06-18"))), [("FAIL", "version-header")]),
("modern: no protocolVersion in _meta", modern(version=None), [("FAIL", "version-in-meta"), ("FAIL", "header-matches-meta")]),
("modern: no clientCapabilities in _meta", modern(capabilities=None), [("FAIL", "capabilities-in-meta")]),
("modern: header differs from _meta", [modern()[0], rec("tools/list", "2025-11-25", "2026-07-28", CLIENT, {})], [("FAIL", "header-matches-meta")]),
("modern: no clientInfo in _meta", modern(client=None), [("WARN", "client-info-in-meta")]),
("modern: a leftover initialized notification", modern() + [rec("notifications/initialized", "2026-07-28")], [("FAIL", "no-handshake-notification")]),
]
def main():
bad = 0
recorded = json.loads((HERE / "trace-claude-code.json").read_text(encoding="utf-8"))
real = [("official Python SDK, modern probe", probe_runs.run("modern", False)),
("official Python SDK, legacy probe", probe_runs.run("legacy", False)),
("Claude Code %s, modern probe" % recorded["version"].split()[0], recorded["modern"]),
("Claude Code %s, legacy probe" % recorded["version"].split()[0], recorded["legacy"])]
print("real traces:")
for name, records in real:
passed, warned, failed = lc.summary(lc.run_checks(records))
print(" %-38s %d pass, %d warn, %d fail" % (name, passed, warned, failed))
bad += failed + warned
print("\none run in detail (%s):" % real[1][0])
for level, check, detail in lc.run_checks(real[1][1]):
print(" %s %s: %s" % (level, check, detail))
print("\ntraces broken on purpose:")
for name, records, expected in BROKEN:
found = [(level, check) for level, check, _ in lc.run_checks(records) if level != "PASS"]
print(" %-44s %s" % (name, ", ".join("%s %s" % pair for pair in found) or "nothing flagged"))
bad += 0 if sorted(found) == sorted(expected) else 1
print("\n%s" % ("every real trace passes and every broken trace is flagged as listed" if not bad else "MISMATCH"))
return 1 if bad else 0
if __name__ == "__main__":
sys.exit(main())Recorded output: lifecycle_runs.py
real traces:
official Python SDK, modern probe 7 pass, 0 warn, 0 fail
official Python SDK, legacy probe 7 pass, 0 warn, 0 fail
Claude Code 2.1.292, modern probe 7 pass, 0 warn, 0 fail
Claude Code 2.1.292, legacy probe 7 pass, 0 warn, 0 fail
one run in detail (official Python SDK, legacy probe):
PASS trace-not-empty: 6 records
PASS era: legacy (has `initialize`)
PASS initialize-first: first interaction is `initialize`
PASS initialize-fields: protocol, clientInfo, capabilities present
PASS initialized-sent: `notifications/initialized` follows `initialize`
PASS initialized-before-requests: no request before the notification
PASS version-header: every later request carries one MCP-Protocol-Version (2025-11-25)
traces broken on purpose:
empty trace FAIL trace-not-empty
legacy: a request before initialize FAIL initialize-first
legacy: initialize without capabilities FAIL initialize-fields
legacy: no initialized notification FAIL initialized-sent
legacy: a request before initialized WARN initialized-before-requests
legacy: no protocol header later FAIL version-header
legacy: the header changes FAIL version-header
modern: no protocolVersion in _meta FAIL version-in-meta, FAIL header-matches-meta
modern: no clientCapabilities in _meta FAIL capabilities-in-meta
modern: header differs from _meta FAIL header-matches-meta
modern: no clientInfo in _meta WARN client-info-in-meta
modern: a leftover initialized notification FAIL no-handshake-notification
every real trace passes and every broken trace is flagged as listedFour things to read from that output:
- All four real traces pass all seven checks, in both eras, for both clients. Neither the SDK nor Claude Code 2.1.292 needed any allowance beyond the leading
server/discover. - The legacy trace shows the whole handshake:
initialize, thennotifications/initialized, then the list requests, each withMCP-Protocol-Version: 2025-11-25. - A modern request that lacks
protocolVersionfails two checks at once,version-in-metaandheader-matches-meta: with no_metavalue there is nothing for the header to match. - Two of the broken traces only warn: a legacy client that sends a request before
notifications/initialized, and a modern request withoutclientInfo. Both break a “SHOULD”, and a server will usually still serve them.
To check a trace of your own, save the requests a server saw as JSON lines, or as one JSON array, with the fields described at the top of lifecycle_check.py, and run python3 lifecycle_check.py trace.jsonl. The exit code is 0 when nothing failed, 1 when a check failed and 2 when the trace cannot be read.
5. Roots
Roots are the part of the client that the architecture change touched most. Roots let a client “expose filesystem roots to servers” so that servers know which directories and files the client considers relevant; the URI of a root MUST be a file:// URI in the current spec. The 2026-07-28 spec calls roots “informational guidance rather than an access-control mechanism” and adds that the protocol does not enforce that servers stay within them, so a root is not a sandbox. If a server must stay inside a directory, enforce that in the server or in the host’s permission layer, not in the list a client sends.
| 2024-11-05 to 2025-11-25 | 2026-07-28 | |
|---|---|---|
| Who asks | The server sends roots/list | The server returns an InputRequiredResult that holds the roots/list request, and the client sends the roots in inputResponses on a retry of its original request |
| How the client declares support | roots in the capabilities of initialize, with listChanged if it will notify | roots in _meta.io.modelcontextprotocol/clientCapabilities on each request (the schema gives it no fields) |
| Change notification | notifications/roots/list_changed, which a client that declares listChanged MUST send | Removed |
| Status | Part of the revision | Deprecated by SEP-2577: new implementations SHOULD NOT adopt it; it stays in the spec for at least twelve months |
If you are building a server today, do not depend on roots: the spec tells existing implementations to migrate to passing directories or files via tool parameters, resource URIs or server configuration. If you are building a client that must keep serving older servers, keep answering roots/list as before, and treat a root as a hint. MCP clients shows which clients declare roots and which say so on their own pages.
6. Failure modes
| Mistake | What goes wrong | What the spec says or the checker shows |
|---|---|---|
| Treating a modern request like part of a session | A server that keeps the first request’s capabilities misses a later change, or rejects a request that has none | Every request carries its own version and capabilities and is “self-contained” |
Leaving _meta fields out | The server cannot serve the request | A missing required field gives -32602 and HTTP 400; the checker’s version-in-meta and capabilities-in-meta fail |
A header that differs from _meta | HTTP 400 with HeaderMismatch | The header value MUST match protocolVersion; header-matches-meta fails |
Sending initialize to a modern-only server | The server rejects it, with an error code the spec leaves open | Legacy client against modern server “Fails”; a dual-era client probes first |
Falling back to initialize on one specific error code | A legacy server that answers with another code is not recognized as legacy | The fallback “MUST NOT be keyed to one specific error code” |
Skipping notifications/initialized in a legacy session | The server holds back its own requests: it SHOULD NOT send any but pings and logging before it | The client MUST send it; initialized-sent fails, and initialized-before-requests warns when a request comes first |
| Using a capability nobody declared | An error, or an answer built on a wrong assumption | A modern server returns MissingRequiredClientCapabilityError (-32021), HTTP 400 |
| Building new work on roots | Depends on a feature scheduled for removal | Deprecated in 2026-07-28; new implementations SHOULD NOT adopt it |
| Sharing one client between two servers | Breaks the isolation the design rests on | The relationship is 1:1; a server must not see into another |
7. Before you ship
- Decide which eras you support. A server that serves both selects its behavior from how the client opens: a request with
_metais served statelessly, aninitializerequest selects legacy semantics. A server that serves only modern clients SHOULD name the versions it supports in the error it returns toinitialize. - Run
lifecycle_check.pyover a trace of every client you target, in every era you support, and keep the traces with your tests. - Declare only what you will answer: a client that declares
rootsmust answerroots/list. - Re-check these conclusions when a new revision is published or when Claude Code or the SDK changes its version; the recorded traces name both versions.
Versions and Verification
Spec wording comes from one pinned commit of the official repository (dae694f6; revision 2026-07-28 and the four before it). The traces were recorded on 2026-10-26: the official Python SDK (mcp==2.3.0, Python 3.14, macOS) and the Claude Code CLI 2.1.292 connected to the probe server of the clients page, once in each era. What to re-check when a revision or a client changes is listed in section 7.
Sources
- Architecture, 2025-11-25 and 2026-07-28:
docs/specification/{2025-11-25,2026-07-28}/architecture/index.mdx. - Lifecycle, 2025-11-25:
docs/specification/2025-11-25/basic/lifecycle.mdx. - Per-request fields, 2026-07-28:
docs/specification/2026-07-28/basic/index.mdx; header rules:basic/transports/streamable-http.mdx; probing and fallback:basic/transports/stdio.mdxandbasic/versioning.mdx; changes:changelog.mdx. - Roots:
docs/specification/{2025-11-25,2026-07-28}/client/roots.mdx; deprecation:docs/specification/2026-07-28/deprecated.mdx. - All of the above at commit
dae694f61a31f7a3ec2af3aff709e11f70f61e48of modelcontextprotocol/modelcontextprotocol.