Skip to content

Keep the code and message of MCP JSON-RPC errors - #164

Open
Mr-Noor-aldeen wants to merge 18 commits into
prooflinedev:mainfrom
Mr-Noor-aldeen:mcp-jsonrpc-errors
Open

Mr-Noor-aldeen wants to merge 18 commits into
prooflinedev:mainfrom
Mr-Noor-aldeen:mcp-jsonrpc-errors

Conversation

@Mr-Noor-aldeen

Copy link
Copy Markdown

Fixes #161.

_decode raised a fixed "Invalid or refused MCP response." for every JSON-RPC error, so the server's code and message never reached the caller.

A well-formed JSON-RPC error now raises a ProoflineError with the type unchanged (urn:proofline:sdk:mcp), the title set to JSON-RPC error <code>, and the server message as the detail, with the API token redacted through the same redacted helper problem documents use. Anything malformed still raises the fixed refusal: the error must be an object with an integer code (a boolean is rejected) and a string message, and the response cannot carry both error and result. Tool calls still never retry. BearerAuth gains a read-only token property so the MCP layer can redact the credential from error text.

Tests: test_mcp_jsonrpc_error_keeps_code_and_redacted_message and test_mcp_jsonrpc_error_malformed_still_refused (both run sync and async) fail on main and pass with the change. Full suite (238 tests), ruff, mypy, the generate check and the contract check all pass. README updated.

This branch has not been deployed

No deployments
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