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:
+2
-2
@@ -209,8 +209,8 @@ async def health_check():
|
|||||||
"auth_enabled": os.getenv("ENABLE_AUTH", "false").lower() == "true"
|
"auth_enabled": os.getenv("ENABLE_AUTH", "false").lower() == "true"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Manual redirect endpoint for /mcp -> /mcp/ (v0.1.6 approach)
|
# Manual redirect endpoint for /mcp -> /mcp/ (support all HTTP methods)
|
||||||
@app.get("/mcp")
|
@app.api_route("/mcp", methods=["GET", "POST", "HEAD", "OPTIONS"])
|
||||||
async def redirect_mcp_to_mcp_slash():
|
async def redirect_mcp_to_mcp_slash():
|
||||||
"""Redirect /mcp to /mcp/ preserving HTTP method with 308"""
|
"""Redirect /mcp to /mcp/ preserving HTTP method with 308"""
|
||||||
from fastapi.responses import RedirectResponse
|
from fastapi.responses import RedirectResponse
|
||||||
|
|||||||
Reference in New Issue
Block a user