Repository navigation
Reject omitted and empty-object additionalProperties in MCP schema validator - #2557
Merged
Merged
Conversation
…lidator
check_schema_depth (validate_tool_schema's recursive worker in
packages/cli/src/commands/mcp.rs) only rejected additionalProperties: true.
Per the JSON Schema spec an omitted additionalProperties key defaults to
true, and additionalProperties: {} is an unconstrained schema -- both are
equally unbounded and were previously accepted.
check_schema_depth now flags true, {}, and an omitted key (on any fragment
that describes a JSON object, via describes_object_schema) as unbounded.
The real passthrough tool schema and its matching test fixture now carry
an explicit additionalProperties: false to stay valid under the tightened
check. Existing nesting-depth test fixtures gained explicit
additionalProperties: false at each level so they continue to exercise
only the depth check. Adds coverage for the omitted-key and empty-object
cases at both the top level and nested inside properties.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
3 tasks
Contributor
Author
|
Reviewed (adversarial pass): describes_object_schema's heuristic confirmed correct for this codebase's actual schema-authoring patterns (traced the untouched anyOf/items nesting tests through the new logic, no false positives). The real-schema consequence independently confirmed genuine — pre-PR tools_list_result() had type:object + properties + required but no additionalProperties key at all, so the loophole was real, and the added additionalProperties:false is semantically correct since extract_tool_call only ever reads arguments.args. Both spot-checked new tests confirmed to genuinely regress the old logic by hand-tracing. Scope clean, worktree-local gaps correctly excluded from the diff. Merging. |
This was referenced Sep 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
validate_tool_schema'scheck_schema_depth(packages/cli/src/commands/mcp.rs) enforces ADR-038's "no unboundedadditionalProperties" requirement, but previously only rejected the explicitadditionalProperties: truecase.Per the JSON Schema spec, an omitted
additionalPropertieskey defaults totrue(unbounded), andadditionalProperties: {}(an unconstrained schema) is equally unbounded. Neither was caught before this change.check_schema_depthnow rejectstrue,{}, and an omitted key on any schema fragment that describes a JSON object ("type": "object"or apropertiesmap) — via a newdescribes_object_schemahelper. The omitted-key case is scoped to object-describing fragments only, so a leaf like{"type": "string"}isn't wrongly required to carry anadditionalPropertieskey.tools_list_result) and its matching "accepts the real passthrough schema" test now carry an explicitadditionalProperties: false, since it previously relied on the now-closed omitted-key loophole...._rejects_excessive_nesting_depth,..._accepts_nesting_at_exactly_the_bound) gained explicitadditionalProperties: falseat each level so they continue to exercise only the depth check, not the new unbounded check.properties.Test plan
cargo test -p nodespace-cli --lib commands::mcp::— all 43 tests passbun run quality:fix— cleanbun run test:all— full suite green (239 vitest files + full Rust workspace incl. themcp_integrationend-to-end test)Closes #2553
🤖 Generated with Claude Code