Skip to content

fix: map FastApiMCP description to instructions, not version - #347

Open
Amiirhosseini wants to merge 1 commit into
tadata-org:mainfrom
Amiirhosseini:fix/mcp-description-not-version-293
Open

fix: map FastApiMCP description to instructions, not version#347
Amiirhosseini wants to merge 1 commit into
tadata-org:mainfrom
Amiirhosseini:fix/mcp-description-not-version-293

Conversation

@Amiirhosseini

Copy link
Copy Markdown

Summary

  • Stops passing description as the second positional arg to mcp.server.Server (on mcp>=1.12 that field is version, which is why MCP Inspector showed the description under Version).
  • Passes version=self.fastapi.version and maps the human description to instructions (and description when the installed SDK exposes that keyword).
  • Adds a regression test.

Fixes #293
Fixes #322

Test plan

  • pytest tests/test_configuration.py::test_description_is_not_passed_as_mcp_version passes on mcp 1.30
  • Confirmed server.version == FastAPI.version and server.instructions == description

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>
Copilot AI lite review requested due to automatic review settings September 8, 2026 02:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 construct Server(...) using keyword arguments (version, instructions, and optionally description) based on the installed MCP SDK signature.
  • Add a regression test ensuring description does not bind to Server.version and that Server.instructions receives 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.

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.

[BUG] Server.__init__ incompatible with mcp>=1.12 [BUG] Description incorrectly passed as version to MCP Server

2 participants