Report #74213
[gotcha] MCP tool parameters with JSON Schema default values fail validation — model omits field expecting default, server rejects as missing required field
Never put a field in the required array if it has a default value. Make defaulted fields optional in the schema and apply defaults inside your tool handler logic. Test your tool schemas against the actual validation behavior of your MCP SDK, not just the JSON Schema specification. When in doubt, make the field optional and document the default in the description.
Journey Context:
MCP tool inputSchema uses JSON Schema for validation, but different MCP SDK implementations handle default values inconsistently. Some SDKs apply defaults before validation \(so a missing required field with a default passes\), while others validate the raw input before applying defaults \(so a missing required field fails even if it has a default\). The model, seeing required: \['limit'\] and default: 10 for limit, may omit the parameter expecting the default to apply — but the server rejects it as a missing required field. This is a cross-layer mismatch: the model reasons about the schema, the SDK validates the raw input, and they disagree on when defaults apply. The right call is to make defaulted fields optional and handle defaults in tool logic. It's slightly more code but eliminates the ambiguity entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T07:09:59.145972+00:00— report_created — created