MCP parameter validation fails for integer in anyOf [integer, null] schemas

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Cursor’s MCP parameter validation rejects certain integer values with error “Parameter ‘X’ must be one of types [integer, null], got number”

OBSERVED BEHAVIOR:

  • Parameters with schema {“type”: “integer”} appear to work
  • Parameters with schema {“anyOf”: [{“type”: “integer”}, {“type”: “null”}]} fail validation

TEST CASE:
Testing two integer parameters in the same MCP tool:

  • Parameter A: {“type”: “integer”} - accepted by Cursor
  • Parameter B: {“anyOf”: [{“type”: “integer”}, {“type”: “null”}]} - rejected by Cursor

When testing the same parameters via direct MCP JSON-RPC protocol (bypassing Cursor), both work correctly.

This suggests the issue may be related to how Cursor validates anyOf type unions with an integer type.

Steps to Reproduce

  1. Configure any MCP server with a tool having an integer parameter using anyOf schema:
    {“anyOf”: [{“type”: “integer”}, {“type”: “null”}]}

  2. Attempt to call the tool from Cursor AI chat with an integer value (e.g., 100)

  3. Observe validation error: “got number”

COMPARISON TEST:

  • Same MCP server, parameter with {“type”: “integer”} only: Works
  • Parameter with {“anyOf”: [{“type”: “integer”}, {“type”: “null”}]}: Fails

DIRECT PROTOCOL TEST:
Sending the same request directly via MCP JSON-RPC bypassing Cursor:
echo ‘{“jsonrpc”:“2.0”,“method”:“tools/call”,“params”:{“name”:“test-tool”,“arguments”:{“testParam”:100}},“id”:2}’ | mcp-server-command
Result: Success (returns data)

This suggests the validation occurs in Cursor’s layer before reaching the MCP server.

Expected Behavior

Per JSON Schema specification, numeric values without fractional parts should match type “integer” in all contexts, including within anyOf type unions.

Expected: Both schemas should accept integer values like 100

  • {“type”: “integer”}
  • {“anyOf”: [{“type”: “integer”}, {“type”: “null”}]}

Operating System

Linux

Current Cursor Version (Menu → About Cursor → Copy)

Version: 2.0.54 (user setup)
VSCode Version: 1.99.3
Commit: 7a31bffd467aa2d9adfda69076eb924e9062cb20
Date: 2025-11-03T22:40:44.657Z
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Windows_NT x64 10.0.26100

For AI issues: which model did you use?

N/A - This is an MCP parameter validation bug, not model-specific

For AI issues: add Request ID with privacy disabled

N/A - Issue occurs in parameter validation

TEST RESULTS:

  • Simple integer type: Passes validation
  • anyOf [integer, null]: Fails validation
  • Direct MCP protocol: Both work

This pattern suggests a possible issue with anyOf type union handling.

Related forum discussion: Problem with cursor MCP schema validation numeric vs integer

Does this stop you from using Cursor

No - Cursor works, but with this issue