Skip to content

[codex] Normalize MCP schema integer constraints - #420

Draft
lawyer112 wants to merge 1 commit into
leookun:mainfrom
lawyer112:codex/normalize-mcp-schema-integer-constraints
Draft

[codex] Normalize MCP schema integer constraints#420
lawyer112 wants to merge 1 commit into
leookun:mainfrom
lawyer112:codex/normalize-mcp-schema-integer-constraints

Conversation

@lawyer112

Copy link
Copy Markdown

Summary

  • canonicalize integer-valued JSON Schema constraints emitted by dynamic MCP tools before provider dispatch
  • recurse only through JSON Schema child-schema positions so examples, defaults, and unrelated numeric keywords are not rewritten
  • add a regression test for Cursor app-control's move_agent_to_cloned_root schema and a preservation test for non-integer values

Problem

Cursor app-control can send MCP input schemas through a protobuf Struct. Protobuf numbers are decoded as floating-point values, so integer-only JSON Schema keywords such as minItems: 1 can be serialized as minItems: 1.0.

Strict OpenAI Responses-compatible validators reject the entire tool definition before the model can answer. The observed failure was:

invalid constraint value at #/anyOf/1/properties/rootPaths: minItems must be an integer, got 1.0

The existing MCP normalizer already repairs the missing root type: object annotation used by this app-control schema, but returned before normalizing constraints on otherwise valid object schemas.

Fix

Normalize non-negative, integral floating-point values for JSON Schema's integer-only size/count keywords into integer JSON numbers. The traversal is schema-aware and covers nested schemas in properties, unions, definitions, array items, and related schema containers.

Fractional values and other numeric constraints such as minimum: 1.0 remain unchanged.

Validation

  • cargo test --package cursor-server --lib — 137 passed
  • cargo clippy --package cursor-server --all-targets -- -D warnings
  • cargo fmt --all -- --check
  • git diff --check

The full cargo test --package cursor-server run also passed all suites except every_captured_mode_owns_and_renders_its_runtime_template. That assertion expects LF-only prompt text and fails on this Windows checkout; the identical failure was reproduced in a separate, unmodified origin/main worktree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant