Commit 3eeae46
Sainikhil Juluri
fix(mcpserver): resolve TypedDict hints via typing_extensions for Python 3.10
`typing.get_type_hints` only strips the `Required`/`NotRequired` qualifier from
3.11 onwards. Below that the bare qualifier reached `create_model`, so on 3.10 --
a supported version -- ANY tool returning a TypedDict with `NotRequired` keys
failed at registration with PydanticForbiddenQualifier, before it could ever be
called. `typing_extensions.get_type_hints` strips it on every supported version.
Verified against unmodified upstream in a separate worktree: this crash predates
this branch and is not introduced by the structuredContent change.
Also switches the test module to `typing_extensions.TypedDict`, which pydantic
requires below 3.12 for `NotRequired` to be honoured.1 parent fa8b8cf commit 3eeae46
2 files changed
Lines changed: 10 additions & 4 deletions
File tree
- src/mcp/server/mcpserver/utilities
- tests/server/mcpserver
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
514 | 514 | | |
515 | 515 | | |
516 | 516 | | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
517 | 520 | | |
518 | 521 | | |
519 | 522 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
0 commit comments