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
This commit is contained in:
saidsurucu
2025-07-22 11:51:31 +03:00
parent e2ca844ab9
commit 4a3edef287
+2 -2
View File
@@ -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