MCP: Model Context ProtocolBeginnerModule 04 — MCP protocol lifecycle
How does MCP protocol version negotiation work?
Question 30 of 43 · Updated
On this page
- Direct answer
- 1. What exactly is a protocol revision?
- 2. Local supported-version sets versus the wire exchange
- 3. Server selection rules
- 4. Why overlapping sets do not guarantee negotiation success
- 5. Client acceptance is an independent step
- 6. Persist the selected revision in trusted session state
- 7. What changes when a revision changes?
- 8. Transport version headers are separate from protocolVersion
- 9. Compatibility does not imply authorization or security
- 10. Tested Python example: model the version selection rules
- Step-by-step explanation
- What was genuinely tested
- Deliberate limitations
- 11. Practical production example: independently upgraded services
- 12. Common implementation mistakes
- Interview-ready answer
Direct answer#
MCP protocol version negotiation establishes which specification revision governs a client-server relationship. In the historical session-oriented 2025-06-18 revision, the client proposes one supported revision in initialize.params.protocolVersion. If the server supports that revision, it must return the same revision in its initialization result. Otherwise, it must return another revision that it supports, preferably its latest supported revision. The client checks whether it supports the returned revision and should disconnect if it does not.
This is a proposal-and-selection exchange, not a wire-level exchange of complete supported-version lists. The server's response is a selected revision, not proof that the client can implement it. Both participants must actually honor the resulting contract before ordinary communication proceeds.
An application can impose a stricter local compatibility policy, for example declining older revisions that do not meet its deployment requirements. That policy must not be confused with the protocol's revision-selection rules.
Learning continuity: Q36 explained the initialize request, result and initialized notification. Q37 concentrates on version selection, supported-version sets, exact compatibility and consequences for message contracts. Q38 develops failure handling and safe cleanup in depth. Q39–41 address capabilities and method gating; Q44, Q94 and Q275–284 address lifecycle differences, transports and broader compatibility engineering.
Verification scope: Prepared using authorized offline research and changelog exceptions. The historical 2025-06-18 MCP specification is the reference baseline, based on established technical knowledge rather than a fresh live specification review. No newer revision or latest SDK behavior is asserted. The standard-library Python fixture was syntax-compiled and executed locally on Python 3.13.5 with warnings treated as errors: all 15 unittest tests passed. It models version-selection logic and a narrow HTTP header adapter, not an actual MCP client or server. The local MCP SDK and Mermaid CLI were unavailable. Live references, SDK interoperability, actual HTTP behavior and diagram/page rendering remain unverified.
1. What exactly is a protocol revision?#
A protocol revision is a particular set of normative communication contracts. It determines the supported message categories, lifecycle, schemas, method semantics and transport rules that apply to implementations using that revision.
MCP historical revisions use date-shaped identifiers. Examples include 2024-11-05, 2025-03-26 and 2025-06-18. These identifiers are not arbitrary dates supplied by a client and do not mean that all preceding or subsequent behavior is automatically supported.
There are several distinct kinds of version information in an integration:
| Version | Example | Meaning |
|---|---|---|
| JSON-RPC version | 2.0 | Message framework |
| MCP protocol revision | 2025-06-18 | Specification contract being proposed or used |
| Client implementation version | 1.2.0 | Client software's reported release |
| Server implementation version | 3.4.0 | Server software's reported release |
| SDK package version | A pinned package release | Installed library implementation |
| Tool/business contract version | inventory.stock.v2, a local example | Application-specific schema and semantics |
The examples of implementation and business versions are fictional. A client using one SDK release can communicate with a server using a different SDK or programming language if the relevant protocol, transport and capability contracts are compatible.
Do not infer supported MCP revisions by comparing SDK package numbers. The appropriate evidence is the library's actual implemented and documented protocol support, tested with the intended peer.
2. Local supported-version sets versus the wire exchange#
Suppose a client implements two revisions, 2025-06-18 and 2025-03-26, while an inventory server implements only 2025-03-26.
Represent these supported revisions internally as sets, together with a preference order if needed. The sets describe genuine implemented support, not merely identifiers that the parser recognizes.
In the historical initialize exchange, the client sends one protocolVersion string. It does not send a standardized array of all versions it supports.
JSON{ "jsonrpc": "2.0", "id": "init-1", "method": "initialize", "params": { "protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": { "name": "retail-support-client", "version": "1.2.0" } } }
The historical client should send the latest revision that it supports. Its local implementation must know which revision that is. In a controlled deployment, an explicit preference policy can determine what the application is willing to offer; it should not advertise unimplemented support.
The server sees the proposal, not the complete client set. A fallback response does not therefore imply that the server has calculated an intersection of every revision supported by both parties.
3. Server selection rules#
The historical lifecycle specifies the following selection behavior:
- When the server supports the proposed revision, it must respond with the same revision.
- When the server does not support the proposed revision, it must respond with another revision it supports. The server should choose its latest supported revision.
- The client then checks the returned revision against its own implemented support. If it does not support the returned revision, it should disconnect.
For example, a server that implements 2025-03-26 rather than 2025-06-18 may return this illustrative result:
JSON{ "jsonrpc": "2.0", "id": "init-1", "result": { "protocolVersion": "2025-03-26", "capabilities": { "tools": {} }, "serverInfo": { "name": "inventory-server", "version": "3.4.0" } } }
This example illustrates the historical selection rule; it does not demonstrate actual interoperability with an older SDK. A real implementation must encode its result consistently with the applicable revision and check the corresponding schemas.
A server that supports the proposal must not replace it with a different revision merely because it personally prefers that other revision. The preference rule becomes relevant when the proposal is unsupported.
The last decision includes the client's optional local policy as well as its protocol support check. The diagram is a conceptual summary, not a new protocol state machine or a complete failure-recovery algorithm.
4. Why overlapping sets do not guarantee negotiation success#
Let C be the set of revisions implemented by the client and S the set implemented by the server. A necessary condition for mutual revision support is that their intersection is nonempty.
However, the historical exchange communicates only one proposed revision and one selected revision. A nonempty intersection does not guarantee that the server will select a member of that intersection when the proposal is unsupported.
Consider these fictional configurations. Here A, B and C stand for historical revision identifiers in ascending chronological order: A = 2024-11-05, B = 2025-03-26 and C = 2025-06-18. Each row assumes that the client proposes its latest supported revision and the server chooses its latest supported revision when it cannot honor the proposal.
| Client support | Server support | Proposal | Selection | Client compatibility |
|---|---|---|---|---|
| C | C | C | C | Compatible |
| C, B | B | C | B | Compatible fallback |
| C | B | C | B | Incompatible |
| C, A | B, A | C | B | Incompatible despite common A |
| B | C, B | B | B | Compatible; server must honor B |
The fourth row is especially important. Although both sides implement A, the server does not know the client's complete supported-version set. When C is unsupported, it selects B, which the client cannot use. The exchange fails.
This is not permission to invent an automatic repeated initialize loop or to try every possible revision on an existing session. Recovery behavior and any decision to create a new connection must follow the applicable lifecycle and local policy. Q38 examines that problem separately.
An out-of-band compatibility manifest can help administrators configure tested combinations before connection establishment. Such a manifest is not a standardized field in the historical initialize request.
5. Client acceptance is an independent step#
After receiving the initialization response, the client should validate:
- The response belongs to the outstanding initialize request.
- It contains an appropriate successful initialization result, rather than an error or malformed envelope.
- The protocolVersion value has the expected type and exact supported identifier.
- The client actually implements that revision and can select the corresponding schemas and behavior.
- The revision satisfies any independent local deployment requirements.
- The remaining initialization result fields can be accepted under the applicable contract.
Only then should the client proceed with the remaining initialization steps described in Q36.
Avoid partial string matching. A fictional identifier 2025-06-18-draft is not automatically compatible with 2025-06-18 simply because it shares a prefix. Similarly, a numerically or lexicographically greater date string is not proof that a revision extends another without breaking changes.
An implementation can parse a known historical date-shaped identifier for release-management purposes, but revision acceptance should rely on exact recognized and implemented contracts rather than a generic greater-than test.
A valid selected revision does not by itself prove that the full result is valid. The peer might provide incorrect capability fields or implementation information. Version selection is one validation decision within initialization, not a substitute for the entire handshake.
6. Persist the selected revision in trusted session state#
The proposal may differ from the accepted selection. After successful negotiation, the relevant client and server implementations must communicate using the accepted contract rather than continue assuming their original preferred revision.
The diagram illustrates historical negotiation with a compatible fallback option. It omits transport details and assumes the complete initialization response is validated.
A useful local connection record could contain:
JSON{ "proposedRevision": "2025-06-18", "selectedRevision": "2025-03-26", "clientImplementation": "retail-support-client", "serverImplementation": "inventory-server", "initializationState": "ready" }
These are invented internal record fields, not an MCP wire message. They can support diagnostics, schema selection and compatibility-aware behavior.
Keep the record scoped to the trusted relationship. One client's negotiation with the inventory server must not globally overwrite the revision used by its separate connection to a policy server. Q21 established the importance of connection isolation.
If the transport connection is interrupted, do not assume that a new socket necessarily means a new logical session or permits arbitrary renegotiation. Apply the actual lifecycle and session rules.
7. What changes when a revision changes?#
Different revisions can define different schemas, supported methods, transports, metadata rules or lifecycle assumptions. A client that claims to support two revisions needs to support their relevant behavior, not simply accept either date string.
One concrete historical example is the transition from the legacy HTTP+SSE transport to Streamable HTTP in the 2025-03-26 revision. The 2025-06-18 revision also removed JSON-RPC batching support and introduced structured tool output support. These are established historical examples, not an exhaustive change log or live verification of every version's behavior.
Consider a client that accepts a historical older revision but always constructs newer structured-output requests or relies on newer result fields. The version comparison may pass, yet its actual message handling may be incompatible.
A practical implementation should separate:
- Revision-specific protocol schemas: Which fields, types and message forms belong to the selected specification.
- Negotiated capability declarations: Which optional features the particular peer supports under that revision.
- Business schemas: Which application-specific arguments and outputs a tool defines.
- Transport contracts: How those messages are sent and associated with the relationship.
- Local policy: Which otherwise supported operations are permitted in the deployment.
For instance, a revision that defines a feature does not require every server to implement that optional feature. After selecting a revision, the host must still inspect the relevant capability declaration and tool contracts.
Conversely, seeing an unfamiliar capability name cannot be used to invent support for an unnegotiated newer specification. Interpret extensions according to the applicable rules and verified implementation support.
8. Transport version headers are separate from protocolVersion#
In the historical 2025-06-18 Streamable HTTP contract, the client must include the negotiated protocol version in the MCP-Protocol-Version HTTP header on subsequent HTTP requests after initialization.
For a connection that negotiated 2025-06-18, a header fragment is:
HTTPMCP-Protocol-Version: 2025-06-18
This fragment is not a complete HTTP request. Other required headers, method, endpoint, content negotiation and authorization information depend on the applicable transport.
If the server assigned an MCP-Session-Id in the initialization HTTP response, the client must include that session identifier on subsequent applicable requests. The two headers serve different purposes:
| Field | Meaning |
|---|---|
| initialize.params.protocolVersion | Proposed MCP revision in a JSON-RPC request |
| initialize.result.protocolVersion | Selected MCP revision in the correlated result |
| MCP-Protocol-Version | Applicable HTTP protocol revision header after initialization |
| MCP-Session-Id | Optional server-assigned HTTP session identifier, when used |
| JSON-RPC id | Correlation of one protocol request and response |
In that historical HTTP specification, when a server receives a request without the version header and has no other means of identifying the version, it should assume 2025-03-26 for backward compatibility. An invalid or unsupported version in the header requires an HTTP 400 Bad Request response. These statements concern the historical transport contract, not general behavior of all MCP implementations.
Do not rely on that missing-header fallback instead of sending the required header. It exists for compatibility and cannot establish that an omitted header is safe for every deployment.
STDIO has no HTTP headers. The client and server still use the applicable selected protocol semantics. Do not insert an HTTP header line into a stdio JSON-RPC stream.
For a different selected revision, consult that revision's actual transport contract before constructing headers. The example below models the 2025-06-18 subsequent-request header only; it intentionally refuses to guess the header policy for other revisions.
9. Compatibility does not imply authorization or security#
Protocol version negotiation determines which communication contract is used. It does not authenticate the peer, grant permission to call tools, or verify that a server's instructions are trustworthy.
Suppose the server selects an older revision that a client technically supports. An organization's policy may still disallow that revision because its deployed security requirements, audited controls or required features are not met. This is a local allowlist decision; do not claim that all older revisions are inherently insecure.
Maintain a distinction between implemented support and allowed support. The safest configuration is to avoid proposing a revision that local policy already forbids, and to verify returned selections independently. The fixture demonstrates rejection of a returned revision that is implemented but not allowed.
Use trusted configuration, authenticated transport where appropriate and verified peer identity. Do not allow untrusted tool content or a model's suggestion to change the accepted revision or bypass local policy.
Capability negotiation, token validation, resource ownership and human approval remain independent controls.
10. Tested Python example: model the version selection rules#
This standard-library program models the selection and client acceptance part of historical negotiation. The three historical dates identify illustrative configured supported-version sets; the code does not implement those revisions' actual schemas or transports.
The tuples are explicit preference orders. In real historical negotiation, the client should propose its latest supported revision, and a server returning an alternative should prefer its latest supported revision. The fixture's selection function honors the first entry as local configured preference, making the policy visible. The test with an older-first preference demonstrates that configuration, not a claim that it is the recommended historical default.
Save as mcp_q37.py:
PYTHONimport json import unittest V1 = '2024-11-05' V2 = '2025-03-26' V3 = '2025-06-18' def propose(supported): if not supported: raise ValueError('No supported revision') return supported[0] # Explicit local preference order. def select(proposal, supported): if type(proposal) is not str or not supported: raise ValueError('Invalid version configuration or proposal') return proposal if proposal in supported else supported[0] def accept(selected, supported, allowed): if type(selected) is not str or selected not in supported: raise ValueError('Unsupported selected revision') if selected not in allowed: raise ValueError('Selected revision disallowed by local policy') return selected def exchange(client, server, allowed=None): request = json.loads(json.dumps({'protocolVersion': propose(client)})) response = json.loads(json.dumps({'protocolVersion': select( request['protocolVersion'], server)})) return accept(response['protocolVersion'], client, client if allowed is None else allowed) def subsequent_header(selected): # Only the historical 2025-06-18 HTTP contract is modeled here. if selected != V3: raise ValueError('HTTP adapter not implemented for revision') return {'MCP-Protocol-Version': selected} class NegotiationTests(unittest.TestCase): def test_exact_match(self): self.assertEqual(exchange((V3,), (V3,)), V3) def test_server_honors_proposal(self): self.assertEqual(select(V2, (V3, V2)), V2) def test_compatible_fallback(self): self.assertEqual(exchange((V3, V2), (V2,)), V2) def test_no_common_revision(self): with self.assertRaises(ValueError): exchange((V3,), (V2,)) def test_overlap_does_not_guarantee_success(self): with self.assertRaises(ValueError): exchange((V3, V1), (V2, V1)) def test_policy_disallows_fallback(self): with self.assertRaises(ValueError): exchange((V3, V2), (V2,), (V3,)) def test_server_preference_is_explicit(self): self.assertEqual(select(V3, (V1, V2)), V1) def test_unknown_selection(self): with self.assertRaises(ValueError): accept('unknown', (V3,), (V3,)) def test_nonstring_selection(self): with self.assertRaises(ValueError): accept(20250618, (V3,), (V3,)) def test_nonstring_proposal(self): with self.assertRaises(ValueError): select(None, (V3,)) def test_empty_client(self): with self.assertRaises(ValueError): propose(()) def test_empty_server(self): with self.assertRaises(ValueError): select(V3, ()) def test_exact_revision_not_prefix(self): with self.assertRaises(ValueError): accept(V3 + '-draft', (V3,), (V3,)) def test_http_header(self): self.assertEqual(subsequent_header(V3), {'MCP-Protocol-Version': V3}) def test_no_unverified_older_header_contract(self): with self.assertRaises(ValueError): subsequent_header(V2) if __name__ == '__main__': unittest.main(verbosity=2)
Run:
BASHpython -m py_compile mcp_q37.py python -W error mcp_q37.py
Actual local output summary on Python 3.13.5:
Ran 15 tests in 0.001s
OKStep-by-step explanation#
The propose function selects one revision from trusted configuration. The select function returns the exact proposal if the server supports it; otherwise it selects a configured supported alternative. The accept function verifies that the client implements the selected revision and permits it under its local policy.
The exchange function performs actual JSON serialization and decoding of simplified version fragments. It intentionally does not build the full initialization envelopes already examined in Q36.
The subsequent_header function constructs the version header only for the historical transport contract that the fixture models. It does not use the proposed revision as a substitute for the selected one, and refuses to imply that it has implemented an older revision's transport adapter.
What was genuinely tested#
The 15 named unittest cases establish:
| Group | Tests |
|---|---|
| Exact match, proposal honored, compatible fallback | 3 |
| No common revision and overlap without successful selection | 2 |
| Policy rejection and explicit preference behavior | 2 |
| Unknown, non-string or prefix-matching identifiers | 4 |
| Empty local supported-version configurations | 2 |
| Historical header construction and rejection of unimplemented adapter | 2 |
No exceptions are counted as successful tests unless the expected ValueError is raised or the specified result matches. The standard-library unittest runner actually executed all 15 cases. The reported timing is only this local run, not a negotiation latency benchmark.
Deliberate limitations#
This is a pure in-memory educational fixture with trusted configuration. It does not verify that the supplied supported-version tuples are valid, distinct or ordered by actual release preference, and does not filter the proposal by the local allowed set. The caller must supply a policy-compatible proposal in a real deployment. The code demonstrates acceptance policy independently.
It does not implement complete initialize envelopes, request ID correlation, error response processing, capability negotiation, authenticated connection state, version-specific schema engines, real HTTP requests, reconnects or cancellation. The version strings are illustrative historical identifiers, not proof that the code implements any actual MCP revision. The HTTP adapter demonstrates only construction of one header for an already accepted 2025-06-18 revision; it does not validate server-side HTTP responses, missing headers or session IDs.
Use the selected compatible MCP SDK in production and test actual supported client-server revision pairs over their intended transports. The unit tests establish the listed selection and policy behavior, not live MCP protocol conformance.
11. Practical production example: independently upgraded services#
Imagine a support host integrating with two servers:
- Inventory has been upgraded and supports the host's preferred revision.
- Returns policy still runs an older audited implementation.
If the host genuinely implements the necessary older revision and its policy allows it, it can negotiate separate contracts with these independent relationships. It should store each selected revision and associated capability declarations separately.
If the older server selects a revision the client cannot implement, the host should not pretend that parsing its basic JSON-RPC response is sufficient. It should mark that particular integration unavailable to ordinary requests and surface an appropriate compatibility diagnostic. Other independently working integrations may continue according to host policy.
A practical compatibility test record can include client software release, client SDK package, server software release, server SDK package, supported transport, proposal, returned revision, acceptance and observed feature tests.
When upgrading, pin dependencies, test actual client/server combinations, record accepted revisions and verify representative requests and results. A passing initialize exchange is necessary for the historical lifecycle but not sufficient to establish every optional feature or business operation.
12. Common implementation mistakes#
| Mistake | Correct principle |
|---|---|
| Send an array as protocolVersion | Historical initialize proposes one revision string |
| Assume the server knows all client-supported versions | It sees the proposal, not a full support set |
| Return a preferred alternative when the proposal is supported | Honor the supported proposal |
| Assume any shared version guarantees success | Check the actual selection |
| Compare SDK versions as protocol revisions | Verify implemented specification support |
| Accept every date older than a supported date | Use exact implemented revision identifiers |
| Keep using the proposal after a fallback | Bind and use the accepted revision |
| Apply newer schema requirements to all revisions | Select the applicable contract |
| Copy version headers into stdio messages | Respect the transport boundary |
| Treat compatible revision as tool permission | Enforce features and authorization independently |
For diagnostics, record proposed and selected revisions, trusted peer identity, applicable transport and a safe outcome category. Avoid disclosing private configuration or credentials. Q38 addresses failed negotiation, lifecycle cleanup and appropriate user-facing errors in depth.
Interview-ready answer#
In the historical session-oriented MCP lifecycle, the client proposes one supported protocolVersion in the initialize request, normally its latest supported revision. The server must return that same revision if it supports it; otherwise it returns another supported revision, preferably its latest. The client independently checks the selected revision and should disconnect if unsupported. The selection is not a full supported-version intersection, so shared versions do not guarantee success. Once accepted, the selected revision governs the relevant schemas and transport behavior for that relationship. MCP protocol revisions are distinct from JSON-RPC and SDK package versions. Capability checks and application authorization remain separate.
Next lesson: Q38 develops safe client behavior when protocol version negotiation fails, including compatibility diagnostics, prevention of premature dispatch and cleanup of incomplete relationships.
References
- 1.MCP historical specification (2025-06-18)modelcontextprotocol.io
- 2.MCP lifecycle (2025-06-18)modelcontextprotocol.io
- 3.MCP transports (2025-06-18)modelcontextprotocol.io
- 4.MCP base protocol (2025-06-18)modelcontextprotocol.io
- 5.MCP historical specification (2025-03-26)modelcontextprotocol.io
- 6.MCP historical specification (2024-11-05)modelcontextprotocol.io
- 7.MCP tools (2025-06-18)modelcontextprotocol.io
- 8.JSON-RPC 2.0 specificationjsonrpc.org
- 9.Official MCP Python SDKgithub.com
- 10.Python unittest documentationdocs.python.org
Related questions
Explore other topics:Forward Deployed EngineeringAI AgentsLarge Language ModelsRetrieval-Augmented Generation