Skip to content

GET /mcp endpoint hangs with streamable HTTP app, causing timeouts in Claude integration #532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Marcostbo opened this issue May 21, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@Marcostbo
Copy link

Description

Hi team,

I've set up a basic FastMCP instance with streamable_http_app() and mounted it inside a FastAPI app as shown below:

from fastapi import FastAPI
from mcp.server.fastmcp import FastMCP

echo_mcp = FastMCP(name="EchoServer", stateless_http=True)

@echo_mcp.tool(description="A simple echo tool")
def echo(message: str) -> str:
    return f"Echo: {message}"

echo_app = echo_mcp.streamable_http_app()

app = FastAPI(
    title="Echo MCP Service",
    description="A service that provides an echo",
    version="1.0.0",
    lifespan=echo_app.router.lifespan_context,
)

app.mount("/echo-server", echo_app, name="echo")

When I run this locally using:

uvicorn app.server:app --reload --port 8888

and make a GET request to http://localhost:8888/echo-server/mcp, the request hangs indefinitely and outputs nothing.

This becomes problematic when integrating this Remote MCP with Claude, which after Oauth steps, begin the integration with a GET request to /mcp. That request seems to time out on their end due to this behavior.

The issue is reproducible locally

Image

Image

Post request to fetch list of tools works as expected
Image

Is this expected behavior for streamable_http_app()? If not, what would be the appropriate way to handle simple GET requests to /mcp so they don't hang? Also if not, why would Claude make a GET request to kick off the integration with Remote MCP?

Thanks!

Example Code

from fastapi import FastAPI
from mcp.server.fastmcp import FastMCP

echo_mcp = FastMCP(name="EchoServer", stateless_http=True)

@echo_mcp.tool(description="A simple echo tool")
def echo(message: str) -> str:
    return f"Echo: {message}"

echo_app = echo_mcp.streamable_http_app()

app = FastAPI(
    title="Echo MCP Service",
    description="A service that provides an echo",
    version="1.0.0",
    lifespan=echo_app.router.lifespan_context,
)

app.mount("/echo-server", echo_app, name="echo")

Version Information

FastMCP version:                                                            2.3.4
MCP version:                                                                1.9.0
Python version:                                                            3.11.8
Platform:          Linux-5.15.167.4-microsoft-standard-WSL2-x86_64-with-glibc2.36
FastMCP root path:                        /usr/local/lib/python3.11/site-packages

fastapi = {extras = ["standard"], version = "^0.115.12"}

Additional Context

No response

@Marcostbo Marcostbo added the bug Something isn't working label May 21, 2025
@Marcostbo
Copy link
Author

INFO:     Uvicorn running on http://127.0.0.1:8888 (Press CTRL+C to quit)
INFO:     Started reloader process [111844] using WatchFiles
INFO:     Started server process [111865]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     127.0.0.1:50444 - "GET /mcp-server/mcp/ HTTP/1.1" 200 OK
INFO:     127.0.0.1:56346 - "POST /mcp-server/mcp/ HTTP/1.1" 200 OK

Something is wrong maybe when building the response for the GET request?

Added a middleware to check the response body

response_body = b""
async for chunk in response.body_iterator:
    response_body += chunk

Every chunk is a string like : ping - 2025-05-22T14:16:16.855206+00:00 and it takes 15s for each chunk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant