[BUG] Claude Code 2.1.80 MCP host fails to invoke fastmcp 3.1.1 tools — "No module named 'fastmcp.server.tasks.routing'"

Resolved 💬 4 comments Opened Mar 20, 2026 by adam-appd Closed Apr 21, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When a stdio MCP server built with fastmcp 3.1.1 is registered with Claude Code, the server initializes successfully but every tool invocation fails with:

Error calling tool: No module named 'fastmcp.server.tasks.routing'

The server starts, responds to the initialize JSON-RPC handshake, and lists tools correctly. Only tool calls fail. Downgrading to fastmcp 3.1.0 resolves the issue completely.

What Should Happen?

Tool calls on a fastmcp 3.1.1 stdio server should succeed, as they do with fastmcp 3.1.0.

Error Messages/Logs

Error calling tool 'hello': No module named 'fastmcp.server.tasks.routing'

fastmcp 3.1.1 added lazy imports of fastmcp.server.tasks.routing.check_background_task inside tool/resource handlers (in tool.py, resource.py, prompt.py). These trigger on tool invocation, not server startup. The module exists in the fastmcp package and imports fine in a normal Python process — the failure occurs specifically in Claude Code's MCP host subprocess environment.

Steps to Reproduce

  1. Create a minimal fastmcp MCP server with fastmcp 3.1.1:

server.py

from fastmcp import FastMCP
mcp = FastMCP("test")

@mcp.tool()
def hello() -> str:
return "hello"

if __name__ == "__main__":
mcp.run()

  1. Register it with Claude Code: claude mcp add test -- uv run server.py
  2. In Claude Code, invoke the hello tool
  3. Observe: Error calling tool: No module named 'fastmcp.server.tasks.routing'

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.78

Claude Code Version

2.1.80

Platform

AWS Bedrock

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

Verified:

  • fastmcp 3.1.0 → works
  • fastmcp 3.1.1 → fails
  • Python 3.12 and 3.14 both reproduce the issue
  • The import from fastmcp.server.tasks.routing import check_background_task succeeds in a standalone Python process with fastmcp 3.1.1 installed

---
Environment

  • Claude Code version: 2.1.80
  • OS: macOS 15.3 (Darwin 25.3.0, arm64)
  • fastmcp version: 3.1.1 (fails), 3.1.0 (works)
  • Python: 3.14.0 (also reproduced on 3.12)
  • Install method: uv run --directory <repo>

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗