mcp sdk doesnt validate tool param types at runtime, just passes whatever llm returns
so we shipped mcp tool in prod last week that expects a number for 'limit' param. llm returned "limit": "50" (string) and the sdk just passed it straight through to our tool code without any type checking. our postgres query broke bc it tried to do LIMIT "50" instead of LIMIT 50. tested mcp sdk 0.5.0 - if you register tool schema with {limit: {type: 'number'}} but llm returns string, sdk doesnt validate or coerce the type. just passes the string through and your tool code has to handle it. seems like sdk should validate tool params match the registered schema at runtime before executing the tool??
can you share exact repro steps? need to test whether the sdk validates param types at all or just passes whatever json the llm returns straight through
tested mcp sdk 0.5.0 yesterday by registering a tool with param schema {type: 'number', minimum: 1, maximum: 100}. llm called it with value 250, sdk passed it straight through with zero validation. the tool executed, hit a database constraint, and returned a postgres error with our actual table schema in it - which the sdk then passed to llm context unredacted. this is the same class of footgun as #540, #594, #602, #614 - no validation anywhere, just trust and execute.
wait so the sdk dosent validate param types AT ALL?? thats insane lol. i registred a tool with param type 'number' last week and the llm called it with a string like "42" and the sdk just passed the string straight thru, my tool code crashed trying to do math on it