Skip to content

Treat JSON-null MCP result/error members as omitted - #337

Merged
tylerreckart merged 1 commit into
mainfrom
fix/mcp-parse-null-members
Sep 21, 2026
Merged

tylerreckart merged 1 commit into
mainfrom
fix/mcp-parse-null-members

Conversation

@cursor

@cursor cursor Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Problem

parse_response treated a present JSON-null result or error member as a real value. A serializer (or proxy) that emits {"jsonrpc":"2.0","id":1,"result":{...},"error":null} on success — or "result":null on error — threw response has both 'result' and 'error'.

Client::rpc counts that throw as a parse failure, skips the line, and kills the MCP subprocess after five such envelopes. /mcp tools then fail until the session is rebuilt. A2A already treats JSON-null as omitted (rpc_response_from_json); MCP did not.

Fix

Treat JSON-null result / error as omitted for the exclusivity check. Dual non-null members still reject. A successful method that returns JSON null still keeps result (distinct from a notification with no result member).

Tests

unit_mcp — success + error:null, error + result:null, successful result:null, error:null only, and the existing dual-object reject. Parse cases 4/4 locally; full unit_mcp 49/49.

Independently mergeable against main (0456350). Code hunks (src/mcp/types.cpp, tests/test_mcp.cpp) do not overlap #321–#336. CHANGELOG [Unreleased] will need a rebase after whichever sibling merges first.

Open in Web View Automation 

parse_response treated a present JSON-null member as a real result or
error, so serializers that emit "error": null on success (or
"result": null on error) threw. Client::rpc counted that as a parse
failure and killed the MCP subprocess after five such lines. Match
A2A: null means omitted; dual non-null members still reject.

Co-authored-by: Tyler Reckart <tylerreckart@users.noreply.github.com>
@cursor
cursor Bot marked this pull request as ready for review September 14, 2026 00:09
@tylerreckart
tylerreckart merged commit fa564a7 into main Sep 21, 2026
5 checks passed
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.

2 participants