Model Context Protocol (MCP) for Developers / Protocol Foundations

Versions, capabilities and the two eras

Lesson 5 of 29. Open to read. No account needed.

What You Will Build

The protocol revision you have been speaking, 2026-07-28, is a recent one, and much of the software you will meet still speaks the revision before it. The two differ in how a connection starts: the older one opens with a handshake called initialize and then treats the connection as a session; the current one has no handshake at all, and each request carries its own version and capabilities. The SDK's server serves both, and its client can open either. In this lesson you open the preview server in the client's three modes and read what each reports, then perform the older handshake by hand and watch the same server refuse a modern request on that connection. By the end you can look at any transcript and say which era it is in and what will happen next.

Why the Handshake Went Away

In the handshake era (revision 2025-11-25 and earlier), a client sent initialize with its version and capabilities, the server answered with its own, the client sent notifications/initialized, and from then on every message belonged to that session. Over HTTP the server minted a session id that the client had to send back on every request, and the server had to keep state for each live session (S35).

Revision 2026-07-28 removed the session. Every request now carries the protocol version and the client's capabilities in its _meta envelope, so a server can answer any request on its own, in any order, on any instance behind a load balancer. The handshake was replaced by server/discover, which any client may call to learn the server's supported versions, capabilities and instructions, and which a server must implement (S40, S50). A client that already knows what it needs can skip discovery and send its first real request straight away. The same change replaced other session-bound features: server-to-client requests became multi round-trip results, and the long-lived notification stream became subscriptions/listen, both of which later modules teach.

The versioning rules are simple (S43): a server that receives a version it does not support answers with -32022 and a supported list, which you saw in the last lesson; a client picks from that list. Over HTTP the version also travels in a request header, and a header that disagrees with the envelope is -32020 (the transports module). The specification's revision is dated, and 2026-07-28 is the current release (S76).

The Era of a Connection

A server built with this SDK is dual-era: it serves both revisions from one program. For a stdio connection, the first message decides which. The behaviour below was recorded against the preview server:

First message on the connectionEra the connection servesThen
Any request with a valid 2026-07-28 envelopeModernRequests with the envelope work; a request without one is -32602
initializeHandshakeSession requests without an envelope work; ping works; a request with the modern envelope is -32600
Anything else (no params, or _meta without the required keys)HandshakeThe first request is -32602, and the connection stays in the handshake era, so modern requests after it are -32600

The last row is the surprising one and the reason wire_errors.py in the previous lesson sent one good server/discover first. A connection whose first message was a malformed modern request is treated as a handshake-era connection, and every later modern request on it is refused with "this connection serves the handshake protocol era". When a client "works on the second run but not the first", this is the first thing to check. Over HTTP the choice is made per request by the version header instead, so there is no such lock-in (S35, S45).

Two timelines against one server. On the left, a modern client sends server/discover with the envelope and receives supportedVersions and capabilities, then sends independent requests, each carrying its own envelope. On the right, a legacy client sends initialize with protocolVersion 2025-11-25, receives the server's capabilities, sends notifications/initialized, then session requests without an envelope, including ping. A modern-envelope request sent on the legacy connection is marked refused with error -32600.

Two clients, one server. The first message fixes the era of a stdio connection, and a request from the other era is refused.

Exercise: Three Modes and a Handshake by Hand

Goal: open the preview server in the SDK client's auto, legacy and pinned modes, read what each reports, then perform the handshake by hand and watch a modern request refused on that connection.

Starting state: the course environment active; ~/mcp-practice/server-tour/preview_server.py.

Effects: creates a folder with a copy of the server and two scripts. Each script starts the server as a child process and stops it. No network is used.

  1. Create the folder and copy the server in. macOS and Linux:

    mkdir -p ~/mcp-practice/eras
    cd ~/mcp-practice/eras
    cp ~/mcp-practice/server-tour/preview_server.py .
    

    Windows PowerShell:

    mkdir $HOME\mcp-practice\eras
    cd $HOME\mcp-practice\eras
    copy $HOME\mcp-practice\server-tour\preview_server.py .
    
  2. Save this as modes.py:

    """Open the preview server in the client's three modes."""
    import asyncio
    import sys
    
    from mcp import Client, StdioServerParameters
    
    SERVER = StdioServerParameters(command=sys.executable, args=["preview_server.py"])
    
    
    async def show(label: str, **options) -> None:
        async with Client(SERVER, **options) as client:
            name = client.server_info.name if client.server_info else None
            tools = len((await client.list_tools()).tools)
            print(f"{label:<14} protocol {client.protocol_version}  server_info {name}  tools {tools}")
    
    
    async def main() -> None:
        await show("auto")
        await show("legacy", mode="legacy")
        await show("pinned", mode="2026-07-28")
    
    
    asyncio.run(main())
    
  3. Run it, keeping the server's log lines out of the way:

    python modes.py 2> server.log
    
    auto           protocol 2026-07-28  server_info inventory-preview  tools 3
    legacy         protocol 2025-11-25  server_info inventory-preview  tools 3
    pinned         protocol 2026-07-28  server_info None  tools 3
    
  4. Save this as legacy.py:

    """A legacy-era handshake by hand, then a modern request on the same connection."""
    import json
    import subprocess
    import sys
    
    server = subprocess.Popen([sys.executable, "preview_server.py"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True)
    
    
    def send(message: dict, expect_reply: bool = True) -> None:
        print(">>", json.dumps(message))
        server.stdin.write(json.dumps(message) + "\n")
        server.stdin.flush()
        if expect_reply:
            print("<<", server.stdout.readline().strip())
    
    
    send({"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-11-25", "capabilities": {}, "clientInfo": {"name": "legacy-by-hand", "version": "0.1"}}})
    send({"jsonrpc": "2.0", "method": "notifications/initialized"}, expect_reply=False)
    send({"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "stock_level", "arguments": {"sku": "belt-m6"}}})
    send({"jsonrpc": "2.0", "id": 3, "method": "ping"})
    send({"jsonrpc": "2.0", "id": 4, "method": "tools/list", "params": {"_meta": {"io.modelcontextprotocol/protocolVersion": "2026-07-28", "io.modelcontextprotocol/clientCapabilities": {}}}})
    server.stdin.close()
    server.wait(timeout=10)
    
  5. Run it:

    python legacy.py
    
    >> {"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-11-25", "capabilities": {}, "clientInfo": {"name": "legacy-by-hand", "version": "0.1"}}}
    << {"jsonrpc":"2.0","id":1,"result":{"capabilities":{"prompts":{"listChanged":false},"resources":{"listChanged":false,"subscribe":false},"tools":{"listChanged":false}},"instructions":"Read-only view of a workshop parts inventory.","protocolVersion":"2025-11-25","serverInfo":{"name":"inventory-preview","version":"0.1.0"}}}
    >> {"jsonrpc": "2.0", "method": "notifications/initialized"}
    >> {"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "stock_level", "arguments": {"sku": "belt-m6"}}}
    << {"jsonrpc":"2.0","id":2,"result":{"content":[{"text":"belt-m6: 7 each in bin B1","type":"text"}],"isError":false,"structuredContent":{"result":"belt-m6: 7 each in bin B1"}}}
    >> {"jsonrpc": "2.0", "id": 3, "method": "ping"}
    << {"jsonrpc":"2.0","id":3,"result":{}}
    >> {"jsonrpc": "2.0", "id": 4, "method": "tools/list", "params": {"_meta": {"io.modelcontextprotocol/protocolVersion": "2026-07-28", "io.modelcontextprotocol/clientCapabilities": {}}}}
    << {"jsonrpc":"2.0","id":4,"error":{"code":-32600,"message":"this connection serves the handshake protocol era; requests carrying the 2026-07-28 envelope are not accepted on it"}}
    

Success: the three mode lines as shown, with server_info None on the pinned line; the handshake result reports protocolVersion 2025-11-25; the tool call and ping succeed without any envelope; the final request is refused with -32600.

How the Three Modes Work

The client's mode argument chooses how it opens a connection (S31):

  • auto (the default, as in the tour lesson) sends server/discover first. A modern server answers it, so the client reports the modern version and fills server_info, instructions and server_capabilities from the result. Against a server that does not know server/discover, the client falls back to the handshake. This is the mode to use unless you have a reason not to.
  • legacy performs the handshake: initialize, then notifications/initialized. The negotiated version is 2025-11-25, and server_info comes from the initialize result. You need this mode for features that exist only in the handshake era, such as the SDK's push-style elicitation, which the asking-the-user lesson contrasts with the modern form.
  • A pinned version, here "2026-07-28", sends no discovery at all: the client assumes the version and goes straight to its first request. That is why server_info is None: the one message that would have carried the server's name was never sent, and the client does not read it out of later results' _meta. Pinning is for clients that already know the server; a handshake-era version cannot be pinned, as the independent task shows.

In every mode the client lists the same three tools: the server's offering does not change with the era, only the way the connection starts.

Reading the Handshake

The hand-written initialize carries protocolVersion, capabilities and clientInfo as top-level params, where the modern era puts them in _meta. The server's result mirrors it: protocolVersion (the version it will speak on this session), capabilities, serverInfo and instructions, with no resultType, ttlMs or cacheScope, which did not exist yet. Notice that the capability flags are all false on this path: the SDK's handshake-era service of this server does not promise list-change notifications or subscriptions, while the modern discover result advertised them. The notifications/initialized line has no id and gets no reply, which is why the script sends it with expect_reply=False. After that, requests carry no envelope, ping exists and answers with an empty result, and a tool call looks like the modern one without resultType. Then the cross-era request is refused.

The Compatibility Matrix

What happens when the two sides disagree, as recorded with this SDK and read from its documentation (S31, S35):

ClientSDK 2.x server (dual-era)Handshake-era-only server
autoModern: discover succeedsFalls back to the handshake
legacyHandshake era on that connectionHandshake
Pinned 2026-07-28Modern, no discover, server_info NoneFails: the server does not understand the envelope
Hand-written, modern firstModernFails
Hand-written, initialize firstHandshake era; modern requests refused with -32600Handshake

Hosts adopted the current revision at different times, and some you meet will still open with initialize. Because a server written with this SDK serves both eras, the server you build in this course works with either kind of host; the deployment lesson shows the HTTP side, where legacy sessions need a session id and sticky routing while modern requests need neither. For a client of your own, use auto.

The 2.x SDK itself is where the modern path arrived: version 2.0.0 (2026-07-28) renamed FastMCP to MCPServer, put one Client in front of the older session object and made the stateless era the default (S03). Over stdio the framing is the same in both eras, one JSON object per line (S44).

When It Goes Wrong

SymptomCauseFix
-32600 ... this connection serves the handshake protocol eraThe connection's first message was initialize or a malformed modern request; later modern requests are refusedStart a new connection and send a valid envelope first
-32022 Unsupported protocol versionThe envelope names a version the server lacksUse one from data.supported
-32602 params._meta must be an object carrying the required ...A modern connection received a request without the envelopeAdd _meta with the two required keys
ValueError: mode must be 'legacy', 'auto', or one of ['2026-07-28']; got '2025-11-25' ('2025-11-25' is a handshake-era version; use mode='legacy')A handshake-era version was pinnedUse mode="legacy"
server_info is NoneThe client is pinned, so it never sent server/discoverUse auto, or call server/discover yourself if you need the name

Your Turn: Pin the Wrong Era, Then Read Four Transcripts

  1. Predict what happens, then run this one-liner in the exercise folder:

    python -c "import sys; from mcp import Client, StdioServerParameters; Client(StdioServerParameters(command=sys.executable, args=['preview_server.py']), mode='2025-11-25')"
    
  2. For each transcript opening, say which era the connection is in and whether the next request described succeeds:

    (a) First message server/discover with a valid envelope; next, a tools/list with the envelope. (b) First message initialize at 2025-11-25; next, ping with no params. (c) First message tools/list with params: {}; next, tools/list with a valid envelope. (d) First message initialize; next, tools/call with a valid modern envelope.

  3. Explain in one sentence why ping worked in legacy.py but was -32601 in the previous lesson.

Reset and Clean Up

Both scripts start and stop their own server and can be rerun freely. This is the end of the protocol-foundations module, so remove both this lesson's folder and server-tour, which the next module no longer needs (the tools module has you write your own server). macOS and Linux:

cd ~/mcp-practice
ls
rm -r eras
rm -r server-tour
ls

Windows PowerShell:

cd $HOME\mcp-practice
ls
Remove-Item -Recurse eras
Remove-Item -Recurse server-tour
ls

.venv and data remain.

Check Your Understanding

  1. A transcript starts with {"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {"protocolVersion": "2025-11-25", ...}} and a result. The next line is a resources/list request whose params hold a 2026-07-28 _meta envelope. Write the reply's code and the gist of its message.
  2. A colleague's client pins "2026-07-28" and then prints client.server_info.name, which raises AttributeError: 'NoneType' object has no attribute 'name'. Explain the cause and give two fixes.
  3. Why can a modern server answer requests in any order on any instance, while a handshake-era server cannot?

Answer and Reasoning

Your turn

  1. The constructor refuses before any process starts: ValueError: mode must be 'legacy', 'auto', or one of ['2026-07-28']; got '2025-11-25' ('2025-11-25' is a handshake-era version; use mode='legacy'). A pinned mode skips discovery and assumes the modern envelope, which a handshake-era version cannot carry, so the SDK points you to mode="legacy" instead.
  2. (a) Modern; the next request succeeds. (b) Handshake; ping succeeds with {}. (c) Handshake, because the malformed first message fixed the era; the next request is refused with -32600. (d) Handshake; the modern-envelope call is refused with -32600.
  3. ping is a handshake-era method that the 2026-07-28 revision removed, so the server answers it only on a connection serving that era; on a modern connection it is -32601 Method not found.

Understanding check

  1. -32600, with the message that this connection serves the handshake protocol era and requests carrying the 2026-07-28 envelope are not accepted on it.
  2. Pinning sends no server/discover, and that is the only message whose result the client reads server_info from, so the attribute stays None. Either open with mode="auto" (one extra request, and the name, instructions and capabilities are filled in), or keep the pin and do not rely on server_info.
  3. Every modern request carries the version and the client's capabilities itself, so the server needs nothing from earlier messages to answer it; a handshake-era server learned those once, at initialize, and must remember them for the rest of the session, which ties the session to one process and one connection.

References

24 more lessons in the full course

Course access opens every lesson and adds revision notes, the Quick Reference, saved progress, bookmarks and your own notes.

INR 199 plus 18% GST. 90 days of online access. No auto-renewal.

Get the full course

This website is operated by VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED, operating as Vectametric.

Corporate Identity Number (CIN): U85499KA2026OPC229822. GSTIN: 29AAMCV8281D1ZS. Registered office: RS NO/38/2A/1 BASTAND, ROAD MAHANTESH NAGAR, Ramdurg, Ramdurg, Belgaum- 591123, Karnataka.

Queries and grievances: Prajval Honnungar, Grievance Officer and Data Protection Contact.

Telephone: +91 94800 09310. Support: support@vectametric.com. Grievances: support@vectametric.com.

Copyright 2026 VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED. All rights reserved.

Vectametric home · Roadmaps · Vecta IT Exams · Vecta Government Exams · Vecta Banking & Finance Exams · Vecta Entrance Exams · About us · Contact · Privacy Policy · Terms and Conditions · No-Refund Policy