-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat: Add output schema generation for tools and update documentation #757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add proper spacing, fix indentation, and add trailing commas
…metadata detection
…ols and low-level server tests
The failing test seems a bit flaky to me, could someone please rerun the failing test? I think it might pass on retry |
Hi @PratyushNag, thank you for your contribution! Apologies for the time it took to get back to this - this looks like a significant enhancement that should likely go through a SEP review to ensure we maintain parity between SDKs and only take on new features in the protocol that we have the capacity to maintain actively. If you wanted some lightweight feedback on your proposal first before investing time in a SEP, you could make a post and link to this PR in the community discord so the maintainer group could take a look for some directional feedback? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting changes for now to put in your queue for a response on SEPs - feel free to ask questions if anything is unclear on next steps here.
Closing this one for now as it's been a while - we're currently going through older PRs to ensure we prioritize limited maintainer time appropriately. |
Apologies for the delay @felixweinberger would it be possible to go through a SEP review now? |
Hi @PratyushNag no worries - yes, if you just put up an issue on this repo first that would be a good start - this is a major refactor and change, so it's worth getting some feedback first. Maintainers only have limited resources to review all the inbound, so for large changes like this it's best to get agreement first before submitting large changes like this one. I'd recommend for now to limit your time used to the absolute core changes you're proposing and motivation for why it's valuable to have this feature in the protocol without heavy implementation details. You can link to this PR here. |
Output Schema Support with Semantic Metadata Enhancement
This PR adds automatic JSON Schema generation for tool return types with intelligent semantic metadata enhancement, enabling LLMs and client applications to understand both the structure and semantic meaning of data they'll receive from tools.
Motivation and Context
Implementation Details
Core Schema Enhancement System
python-sdk/src/mcp/server/fastmcp/utilities/schema.py
detect_semantic_format()
: Analyzes field names and types to detect semantic meaningenhance_output_schema()
: Embeds semantic metadata within JSON Schema propertiesSupported Semantic Types
email
,url
(including uri, link, href variations)datetime
with subtypes (date_only
,time_only
,datetime
)audio
,video
,image
with format detection (audio_file
,video_file
,image_file
)file_path
,identifier
(id, uuid, guid),status
,color
currency
,percentage
(validated for numeric types only)Automatic Integration
tools/base.py
viaTool.from_function()
How Has This Been Tested?
Comprehensive Test Suite (29 Total Tests)
test_schema_utilities.py
): 21 tests covering all semantic detection scenariostest_tool_manager.py
): 8 tests inTestOutputSchema
classSchema Enhancement Examples
Before and After Transformations
Client Application Benefits
Breaking Changes
Types of changes
Checklist
Additional Context and Implementation Notes
Core Architecture
Design Decisions
Performance Considerations
Future Extensibility
Fixes #754