You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
McpError raised in tool handlers is swallowed as isError:true instead of propagating as JSON-RPC error #2770
When a tool handler raises McpError, the call_tool handler in src/mcp/server/lowlevel/server.py catches it via except Exception as e and wraps it as CallToolResult(isError=True). This loses the structured error code on the wire.
The existing UrlElicitationRequiredError (a subclass of McpError) already has a raise bypass for exactly this reason, but the parent McpError class does not.
Note: The v2 high-level API (src/mcp/server/mcpserver/server.py on main) already handles this correctly with except MCPError: raise.
This issue is specific to the v1.x decorator-based low-level server.
Expected behavior
McpError raised in a tool handler should propagate to the transport layer's _handle_request, which converts it to a JSON-RPC error response with the structured error code preserved — the same behavior as UrlElicitationRequiredError.
Reproduction
from mcp.shared.exceptions import McpError
@server.call_tool()
async def handle_call_tool(name, arguments):
raise McpError(code=-32000, message="server fault")
# Actual: client sees CallToolResult(isError=True, content="server fault")
# Expected: client sees JSON-RPC error with code=-32000
Proposed fix
In src/mcp/server/lowlevel/server.py, replace the tool call handler's exception chain:
This one is specific to the 1.x decorator-based low-level Server.call_tool() handler. On v2 (now released) that handler no longer exists, and an MCPError raised from a tool is re-raised and sent as a JSON-RPC error with its code intact, as you noted. The 1.x branch is only taking security and critical fixes at this point, and since tool errors still reach the client (as an isError result rather than a protocol error) this doesn't meet that bar, so I'm going to close it out. Feel free to reopen if this is blocking something on 1.x that can't move to v2.
Activity
fix: propagate MCPError from tool handlers as JSON-RPC error
fix: propagate McpError as JSON-RPC error in lowlevel server
maxisbey commentedon Aug 14, 2026
This one is specific to the 1.x decorator-based low-level
Server.call_tool()handler. On v2 (now released) that handler no longer exists, and anMCPErrorraised from a tool is re-raised and sent as a JSON-RPC error with its code intact, as you noted. The 1.x branch is only taking security and critical fixes at this point, and since tool errors still reach the client (as anisErrorresult rather than a protocol error) this doesn't meet that bar, so I'm going to close it out. Feel free to reopen if this is blocking something on 1.x that can't move to v2.AI Disclaimer