pyclaudir icon indicating copy to clipboard operation
pyclaudir copied to clipboard

Docker build broken: unpinned mcp>=1.2.0 resolves to mcp 2.x (ModuleNotFoundError: mcp.server.fastmcp)

Open imurodl opened this issue 3 months ago • 0 comments

Fresh docker compose up -d --build produces a container that crash-loops on startup.

File "/app/hamroh/mcp_server.py", line 27, in <module>
    from mcp.server.fastmcp import FastMCP
File "/app/.venv/lib/python3.11/site-packages/mcp/server/fastmcp.py", line 16, in <module>
    raise ModuleNotFoundError(_MESSAGE, name=__name__)
ModuleNotFoundError: No module named 'mcp.server.fastmcp'. This is mcp 2.x, where FastMCP was
renamed to MCPServer (from mcp.server.mcpserver import MCPServer)

The container restarts forever; docker compose ps shows restarting.

Root cause

pyproject.toml declares an unbounded lower bound:

dependencies = [
    "mcp>=1.2.0",

uv.lock pins the working version:

name = "mcp"
version = "1.27.0"

but the Dockerfile installs with

RUN uv venv /app/.venv && \
    uv pip install --python /app/.venv/bin/python . --no-cache-dir

uv pip install . resolves from pyproject.toml and ignores uv.lock, so any build after mcp 2.x was published picks up 2.x, where FastMCP was renamed to MCPServer. Builds from before the 2.x release are unaffected, which is why this appears as a sudden breakage with no code change.

Fix

Either pin the major in pyproject.toml:

"mcp>=1.2.0,<2",

or make the image honour the lockfile (uv sync --frozen), which also pins every other unbounded dependency and makes builds reproducible.

I patched locally with the <2 pin and both of my deployments build and run fine:

INFO hamroh.mcp_server  MCP server listening on http://127.0.0.1:36731/mcp
INFO hamroh             hamroh is live

Environment

  • Ubuntu 22.04, aarch64 (OCI Ampere A1)
  • Docker 29.5.2, Compose v5.1.4
  • hamroh at current main, built from a clean clone

imurodl avatar Aug 29 '26 22:08 imurodl