Commit 4f099bf
committed
func_metadata: re-inspect residual after stripping InputRequiredResult; fix migration.md call_tool return
Stripping InputRequiredResult arms rebound return_type_expr but not
inspected_return_ann, so a single-arm residual that was itself an
Annotated[...] (e.g. -> Annotated[CallToolResult, Model] | InputRequiredResult,
the documented pattern in README.v2.md) skipped the CallToolResult-with-
metadata special case: isinstance(Annotated[...], type) is False and
.metadata was still the union's empty tuple. It fell through to
_create_wrapped_model, advertising {result: CallToolResult} and raising
ValidationError on every successful return.
Re-run inspect_annotation on the residual so the post-strip state is
indistinguishable from a fresh call without InputRequiredResult — the
existing dispatch then handles every case unchanged. This also restores
Annotated metadata for the simpler Annotated[X, meta] | InputRequiredResult
case.
Also: docs/migration.md still said MCPServer.call_tool() 'always returns a
CallToolResult'; amend to note the InputRequiredResult arm.1 parent 3507ce7 commit 4f099bf
3 files changed
Lines changed: 31 additions & 3 deletions
File tree
- docs
- src/mcp/server/mcpserver/utilities
- tests/server/mcpserver
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
297 | | - | |
298 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
299 | 303 | | |
300 | 304 | | |
301 | 305 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
862 | 862 | | |
863 | 863 | | |
864 | 864 | | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
865 | 888 | | |
866 | 889 | | |
867 | 890 | | |
| |||
0 commit comments