From 4a3edef287d551e19cd8ab19285314631035183c Mon Sep 17 00:00:00 2001 From: saidsurucu Date: Tue, 22 Jul 2025 11:51:31 +0300 Subject: [PATCH] Fix MCP redirect to support all HTTP methods - Use api_route with all methods instead of just GET - Claude AI makes POST/HEAD requests to /mcp endpoint - This should fix 405 Method Not Allowed error --- asgi_app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/asgi_app.py b/asgi_app.py index e704b2e..0d74b8d 100755 --- a/asgi_app.py +++ b/asgi_app.py @@ -209,8 +209,8 @@ async def health_check(): "auth_enabled": os.getenv("ENABLE_AUTH", "false").lower() == "true" } -# Manual redirect endpoint for /mcp -> /mcp/ (v0.1.6 approach) -@app.get("/mcp") +# Manual redirect endpoint for /mcp -> /mcp/ (support all HTTP methods) +@app.api_route("/mcp", methods=["GET", "POST", "HEAD", "OPTIONS"]) async def redirect_mcp_to_mcp_slash(): """Redirect /mcp to /mcp/ preserving HTTP method with 308""" from fastapi.responses import RedirectResponse