Skip to content

Startup crash in FastMCP HTTP app due to fakeredis aioredis import mismatch (FakeServer/FakeConnection) #3862

@iowathe3rd

Description

@iowathe3rd

What happened?

Summary

FastMCP HTTP server fails during ASGI lifespan startup (before any tool execution) due to import errors in Docket Redis memory backend:

  • ImportError: cannot import name 'FakeConnection' from 'fakeredis.aioredis'
  • ImportError: cannot import name 'FakeServer' from 'fakeredis.aioredis'

This is a hard startup failure: server process exits, MCP tools are never available.


Minimal reproducible example

from fastmcp import FastMCP

mcp = FastMCP("ReproServer", stateless_http=True)
app = mcp.http_app()

Run:

python -m uvicorn app:app --host 0.0.0.0 --port 8000

Actual behavior

Startup fails in lifespan.

Observed traceback path:

  • fastmcp.server.server._docket_lifespan
  • docket._redis._memory_connection_pool
  • from fakeredis.aioredis import FakeConnection, FakeServer

Observed errors:

ImportError: cannot import name 'FakeConnection' from 'fakeredis.aioredis'
ImportError: cannot import name 'FakeServer' from 'fakeredis.aioredis'

Expected behavior

Server should start successfully:

INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8000

Environment

  • Date: 2026-04-12
  • Python: 3.11
  • FastMCP: 2.14.3
  • Uvicorn: 0.35.*
  • Dependency manager: Poetry
  • App mode: mcp.http_app()

Note: warning about stateless_http deprecation is present, but it is not the crash cause.


Workaround (used and validated)

1) Pin fakeredis

In pyproject.toml:

fakeredis = "2.32.1"

2) Re-lock and install

poetry lock
poetry install

3) Validate required symbols

poetry run python -c "from fakeredis.aioredis import FakeConnection, FakeServer; print('fakeredis OK')"

Expected:

fakeredis OK

4) Re-run server

poetry run python -m uvicorn app.server:app --host 0.0.0.0 --port 8000

Result after workaround: startup succeeds.


Why this matters

  • Failure happens before any app/tool logic.
  • Error surfaces from transitive dependency internals, hard to diagnose quickly.
  • Behavior may vary by environment/dependency drift.

Additional context

In our incident, environment drift (manual package changes) made dependency state inconsistent with expected compatibility window, which triggered this startup failure.


Suggested improvement

A clearer compatibility guard would help users, e.g.:

  • tighter constraints in dependency chain for fakeredis compatibility,
  • and/or a startup-time remediation hint when incompatible symbols are missing.

Example Code

Version Information

FastMCP version:                                                         2.14.3
MCP version:                                                             1.27.0
Python version:                                                          3.11.0
Platform:          Linux-6.6.87.2-microsoft-standard-WSL2-x86_64-with-glibc2.39
FastMCP root path:      /home/u19203/dev/mcp/.venv/lib/python3.11/site-packages

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working. Reports of errors, unexpected behavior, or broken functionality.httpRelated to HTTP transport, networking, or web server functionality.serverRelated to FastMCP server implementation or server-side functionality.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions