Commit f5c406f
committed
fix(mcpserver): preserve Annotated/Field metadata for dict[str, T] return types
When a tool returns `Annotated[dict[str, T], Field(description="...")]`, the
`_try_create_model_and_schema` dict branch was passing the unwrapped `type_expr`
(i.e. `dict[str, T]`) to `_create_dict_model` instead of `original_annotation`,
so any `Field` description or other Pydantic metadata was dropped from the output
schema. Fix by passing `original_annotation` so the `RootModel` picks it up.
Fixes #29351 parent 4472428 commit f5c406f
2 files changed
Lines changed: 28 additions & 3 deletions
File tree
- src/mcp/server/mcpserver/utilities
- tests/server/mcpserver
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
352 | | - | |
353 | | - | |
354 | | - | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
248 | 273 | | |
249 | 274 | | |
250 | 275 | | |
| |||
0 commit comments