How to version MCP server
Quick answer
Version your
MCP server by embedding a version identifier in your server's metadata or protocol handshake, typically via the Server class in the official mcp Python SDK. This allows clients and tools to detect and adapt to server capabilities and changes reliably.PREREQUISITES
Python 3.8+pip install mcpBasic knowledge of MCP protocol and Python
Setup MCP environment
Install the official mcp Python SDK and prepare your environment to run an MCP server.
pip install mcp Step by step versioning example
Create an MCP server with explicit versioning by adding a version attribute or responding with version info during handshake. This example uses the mcp.server.Server class and stdio_server transport.
from mcp.server import Server
from mcp.server.stdio import stdio_server
class VersionedMCPServer(Server):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.version = "1.0.0" # Define your server version here
async def on_handshake(self, handshake_data):
# Include version info in handshake response
handshake_data["server_version"] = self.version
return await super().on_handshake(handshake_data)
if __name__ == "__main__":
server = VersionedMCPServer()
stdio_server(server) # Runs the MCP server on stdio transport
# Output when client connects:
# The handshake response will include 'server_version': '1.0.0' allowing clients to detect server version. output
Running MCP server on stdio transport... Client handshake received, responding with server_version: 1.0.0
Common variations
- Use different transports like SSE or TCP instead of stdio.
- Implement semantic versioning (e.g., 1.0.0, 1.1.0) for backward compatibility.
- Expose version info via a dedicated MCP method or metadata endpoint.
- Use async MCP server implementations for concurrency.
Troubleshooting version mismatches
If clients fail to detect the server version, ensure your on_handshake method correctly injects the version info and that clients parse it properly. Also, verify the MCP transport is correctly established and no data is lost during handshake.
Key Takeaways
- Embed version info in MCP server handshake for reliable client detection.
- Use the official
mcpPython SDK'sServerclass to customize versioning. - Semantic versioning helps maintain backward compatibility across MCP server updates.