modelcontextprotocol / modelcontextprotocol/python-sdk
[v1.x] Server-side outputSchema validation blocks tool error reporting (isError: true)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.3k
- Forks
- 4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 31
Description
Initial Checks
- I confirm that I'm using the latest version of MCP Python SDK
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
Description
When a tool handler returns unstructured content for an error case, the low-level server's call_tool decorator validates the output against outputSchema before checking if the response is an error.
This prevents tools with outputSchema from reporting errors via isError: true, as the validation fails with "outputSchema defined but no structured output returned", replacing the original error message.
This was already fixed in the TypeScript SDK via modelcontextprotocol/typescript-sdk#654 / PR #655 (2025-06-24), but the equivalent fix has not been applied to the Python SDK v1.x branch.
The issue is in src/mcp/server/lowlevel/server.py, the call_tool decorator handler:
- Line ~560: outputSchema validation runs unconditionally — should skip when the result is an error
- Line ~575: isError=False is hardcoded — there is no path for the handler to signal an error through unstructured content while outputSchema is defined
Example Code
from mcp.server.lowlevel import Server
from mcp import types
server = Server("test")
@server.call_tool()
async def call_tool(name: str, arguments: dict):
# Tool has outputSchema but needs to return an error
# This gets blocked by outputSchema validation
return [types.TextContent(type="text", text="Resource not found")]
Python & MCP Python SDK
- Python: 3.11 / 3.12
- MCP SDK: v1.26.0+ (v1.x branch)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the call_tool decorator handler in src/mcp/server/lowlevel/server.py around lines 560 and 575, then compare the corresponding TypeScript SDK fix in modelcontextprotocol/typescript-sdk#654 / PR #655. Confirm the error path avoids outputSchema validation and preserves an isError response for unstructured tool errors, with a regression check for the reported example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 70/100