Repository navigation
Commit 3be803d
committed
fix(mcpserver): keep Annotated field constraints on ordinary-class structured output (#3712)
_create_output_model resolved an ordinary class's field hints with
get_type_hints(type_annotation), which drops Annotated metadata. A field
declared Annotated[int, Field(gt=0)] collapsed to a bare int: the generated
output schema lost exclusiveMinimum and convert_result accepted out-of-bound
values such as 0 without raising ValidationError.
Pass include_extras=True so the Annotated metadata is retained and carried
into the synthesized Pydantic model, matching the TypedDict path which
already resolves hints with extras.
Fixes #3712
Signed-off-by: Pratik Dhanave <i.pratikdhanave@gmail.com>1 parent af4c6f4 commit 3be803d
2 files changed
Lines changed: 38 additions & 1 deletion
File tree
- src/mcp/server/mcpserver/utilities
- tests/server/mcpserver
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
552 | 552 | | |
553 | 553 | | |
554 | 554 | | |
555 | | - | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
556 | 558 | | |
557 | 559 | | |
558 | 560 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
973 | 973 | | |
974 | 974 | | |
975 | 975 | | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
976 | 1011 | | |
977 | 1012 | | |
978 | 1013 | | |
| |||
0 commit comments