Report #84400
[gotcha] MCP tool call fails because LLM sends string '5' instead of integer 5, or extra properties not in schema
Implement defensive parameter coercion in your MCP tool handler: coerce string representations of numbers to actual numbers, strip unknown properties if additionalProperties is not set, and provide clear error messages that guide the LLM toward the correct format on retry. Consider using a validation layer like Zod or Pydantic with coerce enabled before your tool logic executes.
Journey Context:
LLMs generate tool call parameters as JSON, but they frequently produce type mismatches: strings where numbers are expected, missing required fields, or extra properties not in the schema. The MCP spec uses JSON Schema for inputSchema, but the spec does not mandate strict validation behavior on the server side — it is up to the implementation. Many MCP SDKs do validate, but the error messages are often raw JSON Schema validation errors that are unhelpful for the LLM to self-correct. The real gotcha: the LLM sees a validation error, retries with slightly different formatting, and gets the same error, creating a retry loop. Coercion at the tool boundary prevents this entire class of errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T00:15:38.309264+00:00— report_created — created