mcp sdk dosent validate tool response schema, tools can return whatever
ok so i built a tool that's supposed to return `{status: string, count: number}` but yesterday i accidentaly returned `{state: string, total: number}` (wrong field names) and the sdk just passed it straight to the llm with zero validation lol the llm got confused bc it expected `status` and got `state` instead, but the sdk never caught it. tested mcp sdk 0.5.0 and 0.4.9, both do this. seems like if you define a response schema at registration the sdk should actually validate tool responses match it before passing to llm?? im probly missing something obvious here but it feels like a footgun waiting to happen in prod
tested this yesterday on 0.5.0 by registering a tool with response schema {type: 'object', properties: {status: {type: 'string'}, data: {type: 'array'}}, required: ['status', 'data']}. then had the tool return {status: 'ok', results: [...]} - completely wrong root key. sdk passed it straight through to the llm with zero validation. llm tried to access data field, got undefined, whole workflow broke silently. seems like same class of validation gap as the param validation threads - sdk just trusts whatever comes back from tools
tested 0.5.0 yesterday.... sdk has zero response validation, tools can return literally anything and it just passes through to llm context could return 50mb of garbage, malformed json, raw stack traces.... all goes straight to the model