Commit ed5868d
committed
fix(server): normalize bare-boolean subschemas in generated tool schemas
`schemars` emits `true.into()` for `serde_json::Value::json_schema()`, so
`Value` / `Vec<Value>` / `BTreeMap<_, Value>` / `#[serde(deny_unknown_fields)]`
fields produce bare boolean subschemas (`"<name>": true`, `"items": true`,
`additionalProperties: true`/`false`). JSON Schema 2020-12 §4.3.2 explicitly
permits these as `{}` / `{"not": {}}` shortcuts, but Claude Code's
`LocalMcpServerManager` schema walker throws
TypeError: Cannot use 'in' operator to search for 'properties' in true
while building the per-server proxy after `tools/list` parses successfully,
silently dropping the entire server's tool list for the session
(anthropics/claude-code#50194 — Grafana MCP, current as of CC 2.1.111;
also #25081, #10606, #28620). The TypeScript SDK's Zod validator accepts
bare booleans correctly; the failure is a Claude Code walker defect.
Apply `schemars::transform::ReplaceBoolSchemas::default()` via
`transform_subschemas` (not `SchemaSettings::with_transform`) so
- bool subschemas in `properties.*`, `items`, `additionalProperties`,
`prefixItems[*]`, `oneOf`/`anyOf`/`allOf[*]`, `not`/`if`/`then`/`else`,
`contains`, `propertyNames`, `additionalItems`, `$defs.*`,
`definitions.*`, `patternProperties.*` are normalized to object form
- degenerate `Json<serde_json::Value>` roots stay non-`"type":"object"`
and the existing `schema_for_output` root-type rejection still fires
Patched both `handler::server::common::schema_for_type` (the funnel for
tool/prompt schemas, `Tool::with_input_schema`, `with_output_schema`,
`schema_for_output`, `cached_arguments_from_schema`, and the `#[tool]`
macro default code-gen) and `model::elicitation_schema::ElicitationSchema::from_type`
(the parallel funnel for elicitation prompts). 10 new unit tests pin the
contract: every documented schemars field shape, idempotency, the
canonical #50194 reproducer (`BTreeMap<_, Value>`), and the degenerate
root rejection.1 parent dd2cf24 commit ed5868d
10 files changed
Lines changed: 370 additions & 15 deletions
File tree
- conformance
- crates
- rmcp-macros
- rmcp
- src
- handler/server
- model
- examples
- clients
- servers
- simple-chat-client
- transport
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
93 | 92 | | |
94 | 93 | | |
95 | 94 | | |
| |||
136 | 135 | | |
137 | 136 | | |
138 | 137 | | |
139 | | - | |
140 | 138 | | |
141 | 139 | | |
142 | 140 | | |
| |||
0 commit comments