Repository navigation
Keep the code and message of MCP JSON-RPC errors - #161
Open
AdityaPradhan01 wants to merge 1 commit into
Open
AdityaPradhan01 wants to merge 1 commit into
AdityaPradhan01 wants to merge 1 commit into
Conversation
A JSON-RPC error response from the MCP endpoint (for example -32602 Invalid params) was reported only as the fixed 'Invalid or refused MCP response.', so callers could not tell a bad argument from a broken server. A well-formed error now raises ProoflineError with the code in title and the server message in detail, with the API token redacted. Malformed errors, and responses carrying both error and result, keep the fixed refusal. Tool calls still never retry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SnJtMTbFz8FeAHg5pLrzkN
This was referenced Dec 3, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
/mcpanswers a tool call with a JSON-RPC error object,_decoderaises the fixedInvalid or refused MCP response.and drops the error'scodeandmessage. A caller can't tell-32602 Invalid params(fix your arguments) from a broken server.This change keeps a well-formed error:
ProoflineErrorwith typeurn:proofline:sdk:mcp(unchanged),title="JSON-RPC error <code>"anddetail=<message>. The API token is redacted from the message with the sameredactedhelper that problem documents use. These cases still raise the fixed refusal:errorandresultTool calls still never retry.
BearerAuthgains a read-onlytokenproperty, so the MCP layer can redact without a new constructor argument onMcpToolsand its subclasses.Tests:
test_mcp_jsonrpc_error_keeps_code_and_redacted_message(sync and async) fails onmainand passes here. The full suite, ruff, mypy, the generate check and the contract check pass. README updated.