Skip to content

Requests to fastapi-mcp hangs if Sentry is enabled #4764

@emirsavran

Description

@emirsavran

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.36.0

Steps to Reproduce

  1. Clone the example repo
  2. Run uv sync
  3. Add DSN to with_sentry.py
  4. Run uv run with_sentry.py
  5. On another terminal, run MCP inspector with npx @modelcontextprotocol/inspector
  6. Select "Streamable HTTP" as transport type
  7. Enter "http://localhost:8000/mcp" as URL
  8. See unsuccessful request.

Expected Result

MCP inspector should connect and show the tools like this:
Image

You can also find the working version in main.py. Just follow the repro steps, but instead of number (4), run uv run main.py.

Actual Result

Requests are somehow hanging. Here are the logs:

DEBUG:    2025-09-05 01:00:14   [mcp.server.lowlevel.server] Initializing server 'FastAPI'
DEBUG:    2025-09-05 01:00:14   [mcp.server.lowlevel.server] Registering handler for ListToolsRequest
DEBUG:    2025-09-05 01:00:14   [mcp.server.lowlevel.server] Registering handler for CallToolRequest
INFO:     2025-09-05 01:00:14   [fastapi_mcp.server] No auth config provided, skipping auth setup
INFO:     2025-09-05 01:00:14   [fastapi_mcp.server] No auth config provided, skipping auth setup
INFO:     2025-09-05 01:00:14   [fastapi_mcp.server] MCP HTTP server listening at /mcp
INFO:     2025-09-05 01:00:14   [fastapi_mcp.server] MCP HTTP server listening at /mcp
DEBUG:    2025-09-05 01:00:14   [asyncio] Using selector: KqueueSelector
INFO:     Started server process [71787]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
DEBUG:    2025-09-05 01:00:19   [fastapi_mcp.transport.http] Starting StreamableHTTP session manager
DEBUG:    2025-09-05 01:00:19   [fastapi_mcp.transport.http] Starting StreamableHTTP session manager
INFO:     2025-09-05 01:00:19   [mcp.server.streamable_http_manager] StreamableHTTP session manager started
INFO:     2025-09-05 01:00:19   [fastapi_mcp.transport.http] StreamableHTTP session manager is running
INFO:     2025-09-05 01:00:19   [fastapi_mcp.transport.http] StreamableHTTP session manager is running
DEBUG:    2025-09-05 01:00:19   [fastapi_mcp.transport.http] Handling FastAPI request: POST /mcp
DEBUG:    2025-09-05 01:00:19   [fastapi_mcp.transport.http] Handling FastAPI request: POST /mcp
DEBUG:    2025-09-05 01:00:19   [mcp.server.streamable_http_manager] Creating new transport
INFO:     2025-09-05 01:00:19   [mcp.server.streamable_http_manager] Created new transport with session ID: cc8a639a06b94dc89bc82aac77620897
DEBUG:    2025-09-05 01:00:19   [urllib3.connectionpool] Starting new HTTPS connection (1): o4506478296367104.ingest.us.sentry.io:443
DEBUG:    2025-09-05 01:00:20   [urllib3.connectionpool] https://o4506478296367104.ingest.us.sentry.io:443 "POST /api/4509963382161408/envelope/ HTTP/1.1" 200 0

Metadata

Metadata

Labels

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions