Model Context Protocol › The lifecycle
Language AI HandbookAll chapters For a migration, write down the first message expected by each deployed peer. The older handshake moved an implementation into a point where both peers had exchanged information. In the modern request-oriented design, inspect the particular request for the revision and applicable client capabilities. Discovery is useful before choosing a method when you know little about a server. A client with a configured compatible revision can start with the operation it needs, then handle any revision error using the returned supported versions.
Keep the request vocabulary separate from application state. If the server persists a reading list, ownership and concurrency of updates still belong to the application. When a client reconnects and sends a valid read request, the server can resolve the requested record based on its current data and authorization. A separate request can safely reference the same record using the application's stable ID. The toy uses only read operations; for a service with writes, decide when retrying is safe based on the operation's semantics and application policy.
Version choice is a useful first deployment test because each side can have more than one supported revision. Here the inputs are ordered by client preference. The intersection produces a choice for a client that includes the modern date and no choice for a client with only an older date. This is a local selection example. A real integration still needs a client implementation for each revision it is prepared to use.
PythonIn [6]Expand
catalog_supported_versions = (PROTOCOL,)
preferred_versions = (PROTOCOL, "2025-11-25")
older_only_versions = ("2025-11-25",)
def preferred_match(preferences, server_supported):
return next(
(version for version in preferences if version in server_supported),
None,
)
version_choices = (
preferred_match(preferred_versions, catalog_supported_versions),
preferred_match(older_only_versions, catalog_supported_versions),
)
assert version_choices == (PROTOCOL, None)
print("Compatible choice:", version_choices[0])
print("Older-only choice:", version_choices[1])ConsoleOut [6]Expand
Compatible choice: 2026-07-28 Older-only choice: None
If the second case occurs during a migration, the useful message names the observed mismatch and directs the owner to the version configuration. Debugging an argument on a method the peers have yet to agree to interpret wastes time. Keep a test for ordinary compatible requests and a separate one for incompatible versions, because the two should lead to distinct messages in the host.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!