Summary
Replace the current ContextVar-based context access in MCPServer handlers with explicit parameter passing.
Problem
MCPServer currently uses a ContextVar to make context available to tool/resource/prompt handlers. This is implicit, hard to test, and doesn't compose well.
Options Under Consideration
- Two decorators:
app.tool() (no context) and app.tool_ctx() (receives context as first param)
- Single decorator with signature inspection:
app.tool() inspects the handler signature and injects context if a matching parameter is present
Design TBD.
This is a breaking change
Existing handlers that access context via ContextVar will need to be updated.
AI Disclaimer