Output validation error: Invalid structured content for tool
- Spec
2026-07-28- Evidence
- E2Reproducedarm64
- TypeScript SDK (server)
@modelcontextprotocol/server@2.4.0- Verified
What it means
Section titled “What it means”When a tool declares an outputSchema, the server SDK checks structuredContent against it before the result leaves the server. Our tool declared { sum: number } and returned { total: 'five' }. The TypeScript SDK v2 turned the result into an error result:
Output validation error: Invalid structured content for tool bad_output: sum: Invalid input: expected number, received undefinedwith isError: true. This is a bug in the server, not in the client or the model: the tool ran, but its answer was thrown away.
The handler returns a different shape
Section titled “The handler returns a different shape”Compare the field names and types in the message with what the handler builds. Typical slips: a renamed field (total vs sum), a number serialized as a string, or a nested object where the schema says flat. Fix whichever side is wrong, and add a test that calls the tool, for example with the Inspector CLI.
The handler returns no structuredContent
Section titled “The handler returns no structuredContent”If a tool declares outputSchema, every successful result must include structuredContent. A tool that returned only content: [{ type: 'text', … }] got this instead:
Output validation error: Tool text_only has an output schema but no structured content was providedEither return both (text for clients that only show text, structured data for programs), or remove outputSchema if the tool does not produce structured data.
Related
Section titled “Related”- Input validation error
- Your first server in TypeScript: a tool with both
contentandstructuredContent.
MCPDev is community documentation. It is not affiliated with the Model Context Protocol project or with the vendors of the clients it covers.