Skip to content

mcp: expose the JSON-RPC request id to receiving middleware - #1464

Merged
guglielmo-san merged 3 commits into
modelcontextprotocol:mainfrom
xianshujun:feat-1264-request-id
Oct 28, 2026
Merged

guglielmo-san merged 3 commits into
modelcontextprotocol:mainfrom
xianshujun:feat-1264-request-id

Conversation

@xianshujun

Copy link
Copy Markdown
Contributor

Adds Request.GetID and an ID field on ClientRequest/ServerRequest, populated from the incoming JSON-RPC request in handleReceive. Receiving middleware can now read the id of a call, and gets the zero ID for a notification or an SDK-originated request. The id is preserved when multi-round-trip retries rebuild the request.

Tests cover server and client receiving middleware, the zero ID on notifications, and the MRTR rebuild path.

  • go test ./... passes
  • go vet ./... passes

Compatibility note: adding the exported ID field can break an unkeyed composite literal of ClientRequest/ServerRequest; go vet found none in this repository.

Fixes #1264.

Add GetID to the Request interface and an ID field to ClientRequest and ServerRequest, populated from the incoming JSON-RPC request. Receiving middleware can now read the id of a call and gets the zero id for a notification.

Preserve the id when multi-round-trip retries rebuild the request.

Updates modelcontextprotocol#1264.
@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Oct 28, 2026
@github-actions github-actions Bot closed this Oct 28, 2026
@github-actions github-actions Bot reopened this Oct 28, 2026
@github-actions github-actions Bot removed the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Oct 28, 2026
@guglielmo-san
guglielmo-san merged commit 985722d into modelcontextprotocol:main Oct 28, 2026
9 checks passed
@guglielmo-san

Copy link
Copy Markdown
Contributor

@xianshujun thank you for the contribution!

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.

proposal: mcp: expose the JSON-RPC request id to receiving middleware and handlers

2 participants