Commit 978fd75
committed
fix: pass through JSON Schemas without a "properties" key in create_sdk_mcp_server
tool()/create_sdk_mcp_server document that input_schema may be "A JSON Schema
dictionary for full validation", and _build_schema has a passthrough branch for
it. But it only recognized a dict as a pre-built JSON Schema when it contained
BOTH "type" AND "properties". A valid JSON Schema that omits "properties" -
e.g. {"type": "object"}, an open object
{"type": "object", "additionalProperties": true}, or an array schema
{"type": "array", "items": {...}} - failed that test and was misinterpreted as
a {param_name: python_type} mapping, turning its schema keywords into fake
required string parameters. The model then saw a corrupted tool schema.
Detect a JSON Schema by a string-valued "type" alone. "properties" is optional
in JSON Schema, and a {name: type} mapping never matches because its values are
Python types (isinstance(input_schema["type"], str) is False even for a param
literally named "type"). Adds regression tests for the passthrough cases and a
guard test for the "param named type" edge case.1 parent 5513b20 commit 978fd75
2 files changed
Lines changed: 54 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
409 | 414 | | |
410 | 415 | | |
411 | 416 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1077 | 1077 | | |
1078 | 1078 | | |
1079 | 1079 | | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
1080 | 1125 | | |
1081 | 1126 | | |
1082 | 1127 | | |
| |||
0 commit comments