feat: Add structured output support for tool functions by bhosmer-ant · Pull Request #993 · modelcontextprotocol/python-sdk

ihrpr

@ihrpr ihrpr changed the base branch from main to basil/lowlevel_schema_validation

June 25, 2025 07:32

ihrpr

ihrpr previously approved these changes Jun 25, 2025

ihrpr

Base automatically changed from basil/lowlevel_schema_validation to main

June 25, 2025 13:23
- Add support for tool functions to return structured data with validation
- Functions can now use structured_output=True to enable output validation
- Add outputSchema field to Tool type in MCP protocol
- Implement client-side validation of structured content
- Add comprehensive tests for all supported types
- Add documentation and examples

@bhosmer-ant

ihrpr

ihrpr previously approved these changes Jun 25, 2025

@bhosmer-ant

ihrpr

ihrpr previously approved these changes Jun 25, 2025

@bhosmer-ant

- strict serializability checking
- simpler, more consistent handling of return type detection and conversion
- centralized logic

@ihrpr ihrpr deleted the basil/structured_output branch

June 26, 2025 08:36

@ihrpr ihrpr linked an issue

Jun 26, 2025

that may be closed by this pull request

rongfengliang added a commit to rongfengliang/LitServe that referenced this pull request

Jul 2, 2025
From modelcontextprotocol/python-sdk#993, this PR removes _convert_to_content from utilities.func_metadata to support older versions of the MCP package (less than v1.10.0). Some checks will be included.

aniketmaurya pushed a commit to Lightning-AI/LitServe that referenced this pull request

Jul 2, 2025
* Update mcp.py

From modelcontextprotocol/python-sdk#993, this PR removes _convert_to_content from utilities.func_metadata to support older versions of the MCP package (less than v1.10.0). Some checks will be included.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

saidsef added a commit to saidsef/mcp-github-pr-issue-analyser that referenced this pull request

Jul 21, 2025

saidsef added a commit to saidsef/mcp-github-pr-issue-analyser that referenced this pull request

Jul 22, 2025

saidsef added a commit to saidsef/mcp-github-pr-issue-analyser that referenced this pull request

Jul 23, 2025