Skip to content

fix: reject duplicate initialize requests#973

Closed
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/reject-repeat-initialize
Closed

fix: reject duplicate initialize requests#973
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/reject-repeat-initialize

Conversation

@he-yufeng
Copy link
Copy Markdown
Contributor

Fixes #961.

Summary

  • Reject a second initialize request after a session has already stored its initial parameters.
  • Keep the original InitializeParams intact when a duplicate request tries to change client info, capabilities, or protocol version.
  • Add a regression test that exercises a raw JSON-RPC connection and verifies the duplicate request returns an error.

Tests

  • go test ./mcp -run TestServerRejectsDuplicateInitialize -count=1
  • go test ./mcp -run "TestServerRejectsDuplicateInitialize|TestClientRootCapabilities" -count=1
  • go test ./mcp -count=1
  • go test ./...
  • git diff --check

@guglielmo-san
Copy link
Copy Markdown
Contributor

Is this a duplicate of PR #962 ?

@he-yufeng
Copy link
Copy Markdown
Contributor Author

Yes, this is a duplicate of #962. I opened #973 from the same issue after #962 had already converged, so I'm closing this one and keeping the approved #962 as the active PR. Thanks for catching it.

@he-yufeng he-yufeng closed this May 23, 2026
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.

Duplicate initialize with changed parameters can overwrite stored session initialization parameters

2 participants