Skip to content

fix(server): allow tools with outputSchema to surface errors via unstructured content#2447

Open
SAY-5 wants to merge 1 commit intomodelcontextprotocol:v1.xfrom
SAY-5:fix/lowlevel-tool-error-with-outputschema
Open

fix(server): allow tools with outputSchema to surface errors via unstructured content#2447
SAY-5 wants to merge 1 commit intomodelcontextprotocol:v1.xfrom
SAY-5:fix/lowlevel-tool-error-with-outputschema

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 15, 2026

Per #2429, a low-level tool with an outputSchema cannot return a tool-execution failure (e.g. "Resource not found") via unstructured TextContent because the call_tool decorator unconditionally validates the result against outputSchema and replaces the original error message with a hard "outputSchema defined but no structured output returned" error.

This PR mirrors the TypeScript SDK fix in modelcontextprotocol/typescript-sdk#655: when an outputSchema-bound tool returns no structured content, treat the unstructured payload as a tool-error result (isError=True) instead of replacing it. Tools that do return structured output keep their existing validation contract, and the explicit CallToolResult-returning path is unchanged.

Closes #2429

…ructured content

Per modelcontextprotocol#2429, a low-level tool with an `outputSchema` cannot return a
tool-execution failure (e.g. "Resource not found") via unstructured
`TextContent` because the call_tool decorator unconditionally validates
the result against `outputSchema` and replaces the original error
message with a hard "outputSchema defined but no structured output
returned" error.

Mirror the TypeScript SDK fix (modelcontextprotocol/typescript-sdk#655):
when an outputSchema-bound tool returns no structured content, treat
the unstructured payload as a tool-error result (`isError=True`)
instead of replacing it. Tools that *do* return structured output keep
their existing validation contract, and the explicit
`CallToolResult`-returning path is unchanged.

Github-Issue:modelcontextprotocol#2429
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant