[SEP-1575] Changes to introduce Tool Versions #1427
Draft
+736
−23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
version
field to tool definitionstool_requirements
field to tool call requestsUNSATISFIED_TOOL_VERSION
error 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.