Skip to content

Commit b3f045c

Browse files
committed
fix: use sse_app() instead of http_app() for SSE endpoints
- FastMCP http_app() only provides /mcp endpoint (not SSE) - FastMCP sse_app() provides /sse/ endpoint (what we need) - Using deprecated sse_app() but suppressing warning since it's required for SSE - SSE endpoint now accessible: http://localhost:8000/sse/ returns 200 OK - CORS headers still working: access-control-allow-origin: * - Browser SSE client can now connect successfully
1 parent 55187cf commit b3f045c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

weather_mcp/cli.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,14 @@ async def run_server():
9090

9191
setup_weather_tools(mcp_server, weather_client)
9292

93-
# Mount the MCP server to the FastAPI app
94-
mcp_app = mcp_server.http_app()
93+
# Mount the MCP SSE app to the FastAPI app (deprecated but needed for SSE)
94+
import warnings
95+
96+
with warnings.catch_warnings():
97+
warnings.simplefilter("ignore", DeprecationWarning)
98+
mcp_app = mcp_server.sse_app()
9599
app.mount("/", mcp_app)
96-
logger.info("Mounted FastMCP server to FastAPI app")
100+
logger.info("Mounted FastMCP SSE server to FastAPI app")
97101

98102
return app
99103

0 commit comments

Comments
 (0)