Skip to content

Input validation error: Invalid arguments for tool

Spec
2026-07-28
Evidence
E2Reproducedarm64
TypeScript SDK (server)
@modelcontextprotocol/server@2.4.0
Python SDK
mcp@2.3.0
Verified

The SDKs check tool arguments against the tool’s inputSchema before your handler runs. A mismatch does not crash anything: the call returns a normal result with isError: true and the validation message as text, so the model can read it and retry. We called add with a as a string:

Server Text of the error result
TypeScript SDK v2 (Zod schema) Input validation error: Invalid arguments for tool add: a: Invalid input: expected number, received string
Python SDK 2.3.0 (type hints, Pydantic) Error executing tool add: 1 validation error for addArguments followed by a Input should be a valid number, unable to parse string as a number [type=float_parsing, input_value='x', input_type=str]

Because it is a result and not a protocol error, clients usually show it inside the conversation, and the model may retry on its own.

The message names the field and what was expected. Common causes:

  • Numbers or booleans sent as strings ("2" instead of 2). In our tests Python (Pydantic) accepted "2" for a float and returned 5.0, but rejected "x"; the TypeScript server (Zod) rejected "2" for z.number().
  • A missing required field, or an object where the schema expects a list.
  • Field names that differ from what the description suggests.

Make the schema easy to follow: clear field names, a description on every field, enums for fixed choices. The model only sees the schema and descriptions.

The schema is stricter than it needs to be

Section titled “The schema is stricter than it needs to be”

If models keep making the same harmless mistake, accept it. In Zod, z.coerce.number() accepts numeric strings. Optional fields with defaults avoid failures when the model leaves them out. Keep strict checks where wrong input could cause damage.

MCPDev is community documentation. It is not affiliated with the Model Context Protocol project or with the vendors of the clients it covers.