Skip to content

[BUG] Incompatible with mcp 2.0 — Server.__init__() positional arg crash #321

Description

@mihirathale98

Hi there! First off, thank you for building and maintaining fastapi-mcp — it's been a great tool for us.

Description

With the recent release of mcp==2.0.0, fastapi-mcp crashes on startup due to Server.__init__() now requiring keyword-only arguments after name.

Root Cause

In fastapi_mcp/server.py (line 181 in 0.4.0, line 144 in earlier versions), description is passed as a positional argument:

mcp_server: LowlevelMCPServer = LowlevelMCPServer(self.name, self.description)

In mcp<2.0, Server.__init__ accepted positional args (name, version=None, ...), so self.description silently landed on the version parameter — incorrect but non-breaking.

In mcp==2.0.0, the signature changed to Server(name, *, ...) — everything after name is keyword-only — so the positional description arg now raises:

TypeError: Server.__init__() takes 2 positional arguments but 3 were given

Steps to Reproduce

pip install fastapi-mcp==0.4.0 mcp==2.0.0
from fastapi import FastAPI
from fastapi_mcp import FastApiMCP

app = FastAPI()
mcp = FastApiMCP(app, name="test", description="A test server")
# TypeError: Server.__init__() takes 2 positional arguments but 3 were given

Suggested Fix

Pass description as a keyword argument:

mcp_server: LowlevelMCPServer = LowlevelMCPServer(self.name, description=self.description)

Notes

I noticed issue #272 and several open PRs (#254, #282, #292, #294, #317) already address the underlying positional arg bug. With mcp 2.0 now released, this has escalated from a cosmetic issue (description landing on the wrong field) to a hard crash that prevents any fastapi-mcp server from starting.

Would it be possible to merge one of the existing PRs and cut a release? We're currently pinning mcp<2.0 as a workaround, and would love to be able to drop that pin.

Thank you for your time!

Environment

  • fastapi-mcp: 0.4.0 (also affects 0.3.7)
  • mcp: 2.0.0
  • Python: 3.12

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions