MCP · MCP0012

Return structuredContent from MCP tools with an outputSchema

Report MCP tools that declare an `outputSchema` and return a result without `structuredContent`, directly or from a helper up to two calls deep. For nitro-mcp-toolkit, only explicit `toolResult()` envelopes are checked.
MCP0012vite-doctor/mcptoolserrorSuggestion

Run this rule

pnpm vite-doctor . --rules mcp/tools/output-schema-needs-structured-content

Why it matters

A tool with an outputSchema promises structured results. h3-mcp (okmcp) answers a result without structuredContent with JSON-RPC error -32602, and the MCP SDK, which @nuxtjs/mcp-toolkit 0.x builds on, fails the call with an output validation error. nitro-mcp-toolkit, which @nuxtjs/mcp-toolkit 1.x builds on, fills structuredContent from a returned data object, but sends an explicit toolResult() envelope as written and fails validation if structured content is required and missing.

Return the data the outputSchema describes in structuredContent, and keep content as its text form.

Example

Return the structured result

Before

defineTool({
  name: 'get_order',
  outputSchema: { type: 'object', properties: { id: { type: 'string' } } },
  handler: async () => ({ content: [{ type: 'text', text: 'ord_1' }] }),
})

After

defineTool({
  name: 'get_order',
  outputSchema: { type: 'object', properties: { id: { type: 'string' } } },
  handler: async () => ({
    content: [{ type: 'text', text: 'ord_1' }],
    structuredContent: { id: 'ord_1' },
  }),
})
Copyright © 2026