Skip to content

mcp: avoid panic for new-protocol null IDs#1046

Open
cyphercodes wants to merge 1 commit into
modelcontextprotocol:mainfrom
cyphercodes:fix-1043-null-id-meta-panic
Open

mcp: avoid panic for new-protocol null IDs#1046
cyphercodes wants to merge 1 commit into
modelcontextprotocol:mainfrom
cyphercodes:fix-1043-null-id-meta-panic

Conversation

@cyphercodes

Copy link
Copy Markdown

This fixes a panic in the server-side per-request protocol metadata path when an inbound message has id: null and new-protocol _meta.

The request decodes as notification-shaped, so validateRequestMeta returns new-protocol metadata without initialize params. Guard the protocol-version check before reading initialize params, allowing the existing request validation path to reject the malformed call instead of dereferencing nil.

Tests:

  • go test ./mcp -run 'Test(ServerHandleNewProtocolNullID|ValidateRequestMeta)$' -count=1
  • go test ./mcp -count=1
  • git diff --check HEAD~1..HEAD

Fixes #1043

Guard the per-request protocol version check so notification-shaped messages with new-protocol metadata do not dereference nil initialize params. This lets malformed id:null calls continue to the existing request validation path instead of crashing.

Fixes modelcontextprotocol#1043
@kuangmi-bit

This comment was marked as spam.

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.

Server panics on id: null request with per-request protocol _meta

2 participants