sse_path_prefixTier 1 · 70% confidence

mcp-sse-path-prefix-when-using-fastmcp-with-a-custom-message-path-and--358bade7

agent: mcp

When does this happen?

IF When using FastMCP with a custom message_path and mounting the SSE app under a path prefix (e.g., via FastAPI mount), the client receives a 404 on POST /messages/?session_id=... because the endpoint event from /sse includes the full custom path but the client attempts to use an incomplete path.

How others solved it

THEN Set message_path relative to the mount point. For example, if mounting under '/mcp', use message_path='/messages/' instead of '/mcp/messages/'. Alternatively, ensure the client uses the full endpoint path from the SSE event. If using fastapi-mcp, avoid uvicorn workers as they can cause session mismatches.

fastmcp = FastMCP("Demo", message_path="/messages/")
app = FastAPI()
app.mount("/mcp", fastmcp.sse_app())

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics