[SEP-1575] Changes to introduce Tool Versions #1427
[SEP-1575] Changes to introduce Tool Versions #1427malaykurwa wants to merge 2 commits intomodelcontextprotocol:mainfrom
Conversation
|
Thanks for driving modelcontextprotocol/modelcontextprotocol#1575 and for the detailed write-up – this is a very helpful feature for people running larger MCP servers. One aspect that might be worth making more explicit (either in Right now, many examples and tutorials show “all tools in a single
Given the design in this PR, a natural pattern for Python/FastMCP seems to be:
This pattern:
Given modelcontextprotocol/modelcontextprotocol#986 is also standardizing tool-name format, it might be helpful to:
If you think this belongs more in the general docs than in |
This PR implements SEP-1575 Tool Versioning support, enabling MCP servers to declare semantic versions for their tools
and allowing clients to specify version constraints when making tool calls.
Motivation and Context
Currently, MCP tools lack versioning support, which can lead to breaking changes when tools are updated. This creates instability for clients that depend on specific tool behaviors. The tool
versioning feature addresses this by:
How Has This Been Tested?
The implementation includes comprehensive testing:
Test files:
examples/test_versioning.py- Comprehensive test suite covering all versioning functionalityexamples/tool_versioning_example.py- Interactive demonstration of versioning featuresBreaking Changes
No breaking changes - This implementation is fully backwards compatible:
Types of changes
Checklist
Additional context
Key Implementation Details
Schema Updates:
versionfield to tool definitionstool_requirementsfield to tool call requestsUNSATISFIED_TOOL_VERSIONerror codeVersion Constraint Syntax:
^): Allows non-breaking updates (^1.2.3≡>=1.2.3 <2.0.0)~): Allows patch-level updates (~1.2.3≡>=1.2.3 <1.3.0)>,>=,<,<="1.2.3"(no operator)New Files:
src/mcp/server/fastmcp/utilities/versioning.py- Core versioning utilitiesexamples/test_versioning.py- Comprehensive test suiteexamples/tool_versioning_example.py- Interactive examplesTOOL_VERSIONING.md- Complete implementation documentationModified Files:
src/mcp/types.py- Added version fields and error codessrc/mcp/server/fastmcp/tools/base.py- Updated Tool class with version supportsrc/mcp/server/fastmcp/tools/tool_manager.py- Enhanced tool management with versioningsrc/mcp/server/fastmcp/server.py- Updated FastMCP API with version parameterssrc/mcp/server/lowlevel/server.py- Low-level server versioning supportUsage Examples
Server-side (creating versioned tools):
Client-side (using version constraints):
This implementation provides a solid foundation for tool versioning while maintaining full backwards compatibility with existing MCP deployments.
This PR description provides a comprehensive overview of your tool versioning implementation, highlighting the key features, testing approach, backwards compatibility, and technical details that
reviewers will need to understand the changes.