Skip to content

fix: negotiate MCP protocol version instead of hardcoding#324

Merged
bensig merged 3 commits intoMemPalace:mainfrom
virgil-at-biocompute:fix/mcp-protocol-version-negotiation
Apr 9, 2026
Merged

fix: negotiate MCP protocol version instead of hardcoding#324
bensig merged 3 commits intoMemPalace:mainfrom
virgil-at-biocompute:fix/mcp-protocol-version-negotiation

Conversation

@virgil-at-biocompute
Copy link
Copy Markdown
Contributor

Summary

  • The initialize handler hardcodes protocolVersion: "2024-11-05", which causes newer MCP clients (Claude Code, Cursor, etc.) to reject the connection when they negotiate 2025-11-25 or later
  • Echo the client's requested version when it is in the supported set, otherwise fall back to the latest known version
  • Adds a SUPPORTED_PROTOCOL_VERSIONS list for easy maintenance as new versions are released

What broke

Claude Code's MCP client sends protocolVersion: "2025-11-25" in the initialize request. The server responded with "2024-11-05", causing the client to reject the handshake. All 18 mempalace tools failed to load as a result.

Changes

mempalace/mcp_server.py

  • Add SUPPORTED_PROTOCOL_VERSIONS list (2025-11-25 through 2024-11-05)
  • Negotiate: echo the client's version if supported, otherwise use the latest

tests/test_mcp_server.py

  • test_initialize_negotiates_client_version — client sends 2025-11-25, server echoes it
  • test_initialize_negotiates_older_supported_version — client sends 2025-03-26, server echoes it
  • test_initialize_unknown_version_falls_back_to_latest — unknown version gets latest supported
  • test_initialize_missing_version_uses_oldest — no version in params gets 2024-11-05 (backwards compat)

Test plan

  • All existing TestHandleRequest tests pass
  • 4 new protocol negotiation tests pass
  • ruff check and ruff format --check clean

virgil-at-biocompute and others added 2 commits April 8, 2026 22:57
The initialize handler hardcoded protocolVersion "2024-11-05", which
causes newer MCP clients (e.g. Claude Code) to reject the connection
when they negotiate "2025-11-25" or later.

Echo the client's requested version if it is in the supported set,
otherwise fall back to the latest supported version. This keeps
backwards compatibility with older clients while allowing newer ones
to connect.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@bensig bensig self-requested a review April 9, 2026 15:12
@bensig bensig merged commit 252e440 into MemPalace:main Apr 9, 2026
5 of 6 checks passed
@milla-jovovich milla-jovovich mentioned this pull request Apr 9, 2026
6 tasks
gnusam pushed a commit to gnusam/mempalace-pgsql that referenced this pull request Apr 9, 2026
The initialize handler replied with a fixed protocolVersion "2024-11-05",
which causes newer MCP clients (Claude Code negotiating 2025-11-25)
to refuse the connection. Echo the client's requested version when it
is in the supported set, otherwise fall back to the newest we know.

Ported from upstream 950d52b (PR MemPalace#324), by @virgil-at-biocompute.
Amusing note: the upstream commit is co-authored by Claude Opus 4.6.

Co-Authored-By: virgil-at-biocompute <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
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