Skip to content

fix(types): type converted MCPServer handler results#2228

Open
lavish0000 wants to merge 2 commits intomodelcontextprotocol:mainfrom
lavish0000:fix/mcpserver-handler-types-2202
Open

fix(types): type converted MCPServer handler results#2228
lavish0000 wants to merge 2 commits intomodelcontextprotocol:mainfrom
lavish0000:fix/mcpserver-handler-types-2202

Conversation

@lavish0000
Copy link

Summary

  • model converted Tool.run() and ToolManager.call_tool() return types precisely when convert_result=True
  • align MCPServer.call_tool() with the converted return shape it actually produces
  • tighten a few related helper annotations so pyright no longer reports the current handler mismatches

Testing

  • python3 -m uv run pytest tests/server/mcpserver/test_tool_manager.py -k 'call_tool or structured'
  • python3 -m uv run ruff check src/mcp/server/mcpserver/utilities/func_metadata.py src/mcp/server/mcpserver/tools/base.py src/mcp/server/mcpserver/tools/tool_manager.py src/mcp/server/mcpserver/server.py src/mcp/server/mcpserver/prompts/base.py src/mcp/server/mcpserver/resources/templates.py
  • python3 -m uv run ruff format --check src/mcp/server/mcpserver/utilities/func_metadata.py src/mcp/server/mcpserver/tools/base.py src/mcp/server/mcpserver/tools/tool_manager.py src/mcp/server/mcpserver/server.py src/mcp/server/mcpserver/prompts/base.py src/mcp/server/mcpserver/resources/templates.py
  • python3 -m uv run pyright src/mcp/server/mcpserver/utilities/func_metadata.py src/mcp/server/mcpserver/tools/base.py src/mcp/server/mcpserver/tools/tool_manager.py src/mcp/server/mcpserver/server.py src/mcp/server/mcpserver/prompts/base.py src/mcp/server/mcpserver/resources/templates.py

Fixes #2202

@maxisbey maxisbey added enhancement Request for a new feature that's not currently supported v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes P2 Moderate issues affecting some users, edge cases, potentially valuable feature needs confirmation Needs confirmation that the PR is actually required or needed. labels Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Request for a new feature that's not currently supported needs confirmation Needs confirmation that the PR is actually required or needed. P2 Moderate issues affecting some users, edge cases, potentially valuable feature v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type the MCPServer handler pipeline: tool/resource/prompt return types

2 participants