Skip to content

fix: detect context on callable tool instances#2623

Open
pragnyanramtha wants to merge 1 commit into
modelcontextprotocol:mainfrom
pragnyanramtha:pragnyan/callable-context-1974
Open

fix: detect context on callable tool instances#2623
pragnyanramtha wants to merge 1 commit into
modelcontextprotocol:mainfrom
pragnyanramtha:pragnyan/callable-context-1974

Conversation

@pragnyanramtha
Copy link
Copy Markdown

Summary

  • Fix find_context_parameter() so callable object instances are inspected through their bound __call__ method.
  • Prevent callable tool instance Context parameters from appearing in generated tool input schemas.
  • Add a regression test that verifies schema omission and runtime context injection for an async callable object tool.

Fixes #1974.

Validation

  • uv run pytest tests/server/mcpserver/test_tool_manager.py -q
  • uv run ruff check src/mcp/server/mcpserver/utilities/context_injection.py tests/server/mcpserver/test_tool_manager.py
  • uv run ruff format --check src/mcp/server/mcpserver/utilities/context_injection.py tests/server/mcpserver/test_tool_manager.py
  • uv run pyright src/mcp/server/mcpserver/utilities/context_injection.py tests/server/mcpserver/test_tool_manager.py

@pragnyanramtha pragnyanramtha marked this pull request as ready for review May 17, 2026 03:51
Copilot AI review requested due to automatic review settings May 17, 2026 03:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@BossChaos
Copy link
Copy Markdown

Code Review

PR: fix: detect context on callable tool instances by @pragnyanramtha

  • ✅ Bug fix

Wallet: 0xdaE5d307339074A24F579dB48e7c639359D94904

Code review for MCP Python SDK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

find_context_parameter() fails to detect Context parameter in callable class instances

3 participants