feat(mcp): adopt FastMCP 4 beta - #1198
Merged
Merged
Conversation
Signed-off-by: phernandez <paul@basicmachines.co>
28 tasks
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.
Why
FastMCP 4 moves its runtime and Python model surface onto MCP SDK v2. Basic Memory still depended on FastMCP 3, imported
ToolErrorfrom the legacy MCP SDK compatibility path, and read SDK model fields through camelCase Python attributes.This PR delivers the Core Phase 1 compatibility work from #1181 and fixes the production exception-class mismatch from #1197. It deliberately leaves hosted Cloud MCP App callbacks and optional FastMCP 4 capabilities for the follow-up phase described in #1181.
What changed
fastmcpand itsfastmcp-slimruntime exactly to the latest verified beta,4.0.0b1.mcp>=2,<3and refresh the UV lockfile.ToolErrorfromfastmcp.exceptionsthroughout Core and its tests.HTTPStatusErroras the cause of translated tool failures.Implementation details
Current-request identity is authoritative.
is_openai_mcp_client()readscontext.request_context.session.client_params.client_infofirst; stored initialize state is used only when a request does not expose negotiated identity. This prevents a non-OpenAI request from inheriting stale OpenAI identity while retaining the legacy-session fallback.UV's constraint pins
fastmcp-slim==4.0.0b1alongside the publicfastmcp==4.0.0b1dependency so the runtime cannot drift independently. The resulting lock resolves MCP SDK and MCP types to2.0.0.Testing
just fast-checkuv lock --checkjust test-smoke— 1 passedjust doctor— passed end to endFASTMCP_MCP_CAMELCASE_COMPAT=false— 83 passed, 1 skippedFASTMCP_MCP_CAMELCASE_COMPAT=false— 1,115 passed, 1 skippedBASIC_MEMORY_TEST_POSTGRES=1and the camelCase bridge disabled — 84 passed, 1 skippedThe live OpenAI semantic-quality benchmark could not complete because the provider returned
429 insufficient_quota. Deterministic local and Postgres coverage passed.Risks and follow-ups
Refs #1181
Closes #1197