Commit 9a38150
fix: detect Context parameter in callable class instances
find_context_parameter() uses typing.get_type_hints(fn) to find
Context-typed parameters. However, get_type_hints() doesn't introspect
the __call__ method of callable class instances, so ctx: Context is
exposed as a visible tool parameter instead of being injected by the
framework.
The fix checks if fn is a callable class instance (not a function or
method) and inspects fn.__call__ instead.
Fixes #1974
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 62575ed commit 9a38150
2 files changed
Lines changed: 43 additions & 1 deletion
File tree
- src/mcp/server/mcpserver/utilities
- tests/server/mcpserver
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
25 | 31 | | |
26 | 32 | | |
27 | | - | |
| 33 | + | |
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
416 | 452 | | |
417 | 453 | | |
418 | 454 | | |
| |||
0 commit comments