Skip to content

Reject boolean IDs in MCP JSON-RPC responses - #86

Open
rajveer100704 wants to merge 1 commit into
prooflinedev:mainfrom
rajveer100704:fix/mcp-jsonrpc-boolean-id
Open

rajveer100704 wants to merge 1 commit into
prooflinedev:mainfrom
rajveer100704:fix/mcp-jsonrpc-boolean-id

Conversation

@rajveer100704

Copy link
Copy Markdown

Problem

Python treats bool as a subclass of int, so True == 1. The MCP initialize request uses a numeric JSON-RPC response ID, and _decode compared the returned ID to the expected identity without rejecting booleans first. As a result, a response containing "id": true could be incorrectly accepted as the response to request ID 1.

Change

  • Reject Boolean response IDs explicitly before comparing the response ID with the expected identity.
  • Add a regression test covering both synchronous and asynchronous clients. The fake MCP server returns an otherwise valid initialize response with "id": true; the client must raise ProoflineError and stop after the initialize request.

Verification

  • Test-first check: before the fix, both sync and async regression cases failed because ProoflineError was not raised.
  • After the fix: the targeted regression test passed in both modes (2 passed).
  • Full test suite on the rebased upstream v9.1.0 base: 221 passed, 8 subtests passed.
  • Also ran and passed the generated API check, contracts check, Ruff lint/format checks, and mypy locally.

The change is limited to proofline/_mcp.py and tests/test_http.py.

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