Skip to content

Reject ambiguous and malformed MCP JSON responses - #152

Open
50022005 wants to merge 1 commit into
prooflinedev:mainfrom
50022005:fix/strict-mcp-json
Open

50022005 wants to merge 1 commit into
prooflinedev:mainfrom
50022005:fix/strict-mcp-json

Conversation

@50022005

@50022005 50022005 commented Dec 2, 2026

Copy link
Copy Markdown

Malformed MCP JSON can currently overwrite a tool refusal: a result containing both "isError": true and "isError": false is returned as success because Python keeps the last duplicate member. Duplicate JSON-RPC IDs/results are also silently accepted, and deeply nested JSON escapes as an untyped RecursionError.

Decode MCP responses with duplicate-member and non-standard-constant rejection, and translate decoder recursion failures into the existing ProoflineError. Both synchronous and asynchronous clients share this decoder. The change does not retry tool calls or include response values in errors.

Validation: all 266 tests pass, including 32 new loopback HTTP regression cases covering both handshake and tool responses, duplicate IDs/results/nested members, non-standard constants, conflicting refusal flags, and excessive nesting. Existing MCP tests verify normal results and refusals remain intact. Pinned Ruff checks and mypy (232 source files) also pass. Tests used --basetemp=../pytest-full-1 because this Windows machine's default pytest temp folder is inaccessible.

Prepared with Codex assistance for the Software Engineering Intern application; the applicant still needs to review and understand the code, run a real Proofline review, and record their narrated walkthrough before applying.

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