fix: map FastApiMCP description to instructions, not version - #347
Open
Amiirhosseini wants to merge 1 commit into
Open
fix: map FastApiMCP description to instructions, not version#347Amiirhosseini wants to merge 1 commit into
Amiirhosseini wants to merge 1 commit into
Conversation
mcp>=1.12 treats the second Server positional as version, so description text was showing up as Version in MCP Inspector. Pass FastAPI app version and instructions/description via keywords. Fixes tadata-org#293, tadata-org#322. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
🟢 Approval recommended
The change directly addresses the reported MCP signature mismatch and includes a targeted regression test covering the corrected mapping behavior.
Pull request overview
This PR fixes compatibility with mcp>=1.12 by avoiding passing FastApiMCP.description as a positional argument to mcp.server.lowlevel.server.Server, where it would bind to version, and instead mapping the human-readable description to instructions (and description when supported) while setting the MCP server version from the FastAPI app version.
Changes:
- Update
FastApiMCP.setup_server()to constructServer(...)using keyword arguments (version,instructions, and optionallydescription) based on the installed MCP SDK signature. - Add a regression test ensuring
descriptiondoes not bind toServer.versionand thatServer.instructionsreceives the description.
File summaries
| File | Description |
|---|---|
| fastapi_mcp/server.py | Switches MCP Server construction to keyword args and maps FastAPI version + human description correctly across MCP SDK versions. |
| tests/test_configuration.py | Adds a regression test validating the corrected Server.version and Server.instructions mappings. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
descriptionas the second positional arg tomcp.server.Server(on mcp>=1.12 that field isversion, which is why MCP Inspector showed the description under Version).version=self.fastapi.versionand maps the human description toinstructions(anddescriptionwhen the installed SDK exposes that keyword).Fixes #293
Fixes #322
Test plan
pytest tests/test_configuration.py::test_description_is_not_passed_as_mcp_versionpasses on mcp 1.30server.version == FastAPI.versionandserver.instructions == description