✨ WP12: mcp SDK 2.0 support — dual-path compat, pin widened to <3 - #10
Merged
Conversation
mcp SDK 2.0 runs sync tool handlers in anyio worker threads (1.x ran them inline on the event loop), so the serving SQLite connection is touched from a different thread per tool call and the stock check_same_thread guard crashes every request — reproduced across the whole MCP suite under mcp==2.0.0. Sequential cross-thread use is safe: CPython's sqlite3 ships threadsafety=3 (serialized) and MCP stdio traffic is serial. Nothing enables concurrent cross-thread access.
Wuesteon
added a commit
that referenced
this pull request
Jul 29, 2026
Resolves the import-block conflict in mcp_server.py: keep the compat factory (make_stdio_server) AND the metadata imports (ToolAnnotations, Field). Renumbers this packet WP12 → WP13 — the mcp 2.0 migration claimed WP12 concurrently and merged first (PR #10). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VgxNBms5npMWXD2krUofs3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lifts the v0.2.2 emergency
mcp<2cap by supporting BOTH SDK majors (packet WP12):lean_memory._mcp_compat,lean_memory_console._mcp_compat— duplicated on purpose; console↔core version skew makes cross-package private imports fragile): handle the 2.0FastMCP→MCPServerrename, ctorversion=(replacing the 1.x_mcp_server.versionpoke), and transport params moving from the constructor tostreamable_http_app(...)for the console's HTTP mount.check_same_thread=False— safe for serial MCP traffic (CPython sqlite3 threadsafety=3, serialized); nothing enables concurrent cross-thread access.tests/mcp_client_compat.pywraps 2.0's in-memoryClient(server)vs 1.x'screate_connected_server_and_client_session; console's server-sidecall_toolunwrap handles 2.0'sCallToolResult.structured_content.mcp>=1.2,<3(core extra + console); the pyproject guard test now asserts the<3cap.Test plan
Verified against BOTH majors locally:
[llm]extra), console 153 passed.🤖 Generated with Claude Code
https://claude.ai/code/session_01YRU73aDWiYUqgaL5UETUMp