Skip to content

Commit b92ea9b

Browse files
fix: restore original context passing behavior
Fixed a regression where Context parameter was only passed when it was not None. The original behavior was to always pass the context parameter when context_kwarg is set, even if the value is None. This fixes test_call_tool_with_complex_model which calls a tool that requires Context but provides None. Root Cause: - Changed `if context_kwarg is not None and context is not None` to `if context_kwarg is not None` to match original behavior Impact: - Fixes failing test that expects Context parameter even when value is None - Maintains backward compatibility with existing code
1 parent ef0628f commit b92ea9b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • src/mcp/server/mcpserver/tools

src/mcp/server/mcpserver/tools/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ async def run(
116116
try:
117117
# Build direct args (context and dependencies)
118118
direct_args = {}
119-
if self.context_kwarg is not None and context is not None:
119+
if self.context_kwarg is not None:
120120
direct_args[self.context_kwarg] = context
121121

122122
# Resolve dependencies if a resolver is provided

0 commit comments

Comments
 (0)