Skip to content

fix: distinguish server requests from MCP responses with matching IDs - #5393

Merged
milind-soni merged 1 commit into
milind-soni:mainfrom
Afloat16:fix/mcp-response-id-direction
Nov 12, 2026
Merged

milind-soni merged 1 commit into
milind-soni:mainfrom
Afloat16:fix/mcp-response-id-direction

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

Problem

MCP peers allocate request IDs independently. A server can send a ping or another reverse request using the same ID as an in-flight client request. The HTTP transport currently matches only the ID, so it accepts that server request as the client's response and resolves the tool call with undefined before its actual result arrives.

Changes

Require a JSON-RPC response shape (no method and an own result or error field) before matching a pending client ID. Apply the check consistently to JSON response batches, streamable HTTP SSE responses, and the legacy SSE listener. Null results remain valid. Extend the fake server with an optional reverse-request ID for deterministic coverage.

Recorded verification

The following results were recorded for this branch on base 9d6678adcaf62645513a3e3419999134742bb458.

  • Two new real-socket regressions fail before the fix, covering streamable HTTP and legacy SSE reverse-request collisions.
  • 16/16 isolated HTTP and framing tests pass after the fix, including a JSON batch that contains a colliding server request followed by a null result.
  • git diff --check passed.
  • Full application dependency installation was blocked during that validation by the repository's minimumReleaseAge policy for recent @trycua/cua-driver platform packages; full application checks and workflow verification were not run.

This fixes JSON-RPC direction correlation in the HTTP transport. It is separate from the connector cache reply matching in #5092 and the SSE end-of-stream framing change in #5251.

Current upstream check

The complete source and regression-test patch applies cleanly to main 613ed01fdc2b04860ef63e3dbdcb46d7e6b1666d as checked on 2026-11-11. Current main still matches JSON and streamable HTTP responses by ID alone and matches legacy SSE pending IDs without response-shape validation. The complete patch applies cleanly over final-event framing added by #5251.

Head branch: Afloat16:fix/mcp-response-id-direction (44ca476b871926f3cbbe71c1ece2f5da1bd1cfbf).

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@vercel

vercel Bot commented Nov 11, 2026

Copy link
Copy Markdown

@Afloat16 is attempting to deploy a commit to the SupaMaus Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Nov 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 59e5819f-09d7-40ea-a2f1-276427e05c4a
Commits

Reviewing files that changed from the base of the PR and between 613ed01 and 44ca476.

Files selected for processing: 3

  • server/mcp-http.test.ts
  • server/mcp-http.ts
  • server/testing/fake-http-mcp-server.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@milind-soni
milind-soni merged commit dd6b4c4 into milind-soni:main Nov 12, 2026
26 of 27 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