Update asgi_app.py
This commit is contained in:
+4
-6
@@ -98,9 +98,8 @@ mcp_server = create_app(auth=bearer_auth)
|
|||||||
# Add Starlette middleware to FastAPI (not MCP)
|
# Add Starlette middleware to FastAPI (not MCP)
|
||||||
# MCP already has Bearer auth, no need for additional middleware on MCP level
|
# MCP already has Bearer auth, no need for additional middleware on MCP level
|
||||||
|
|
||||||
# Create MCP Starlette sub-application
|
# Create MCP Starlette sub-application with the path it will be mounted at
|
||||||
# When mounting, the path parameter should NOT be set here
|
mcp_app = mcp_server.http_app(path="/mcp")
|
||||||
mcp_app = mcp_server.http_app()
|
|
||||||
|
|
||||||
# Configure JSON encoder for proper Turkish character support
|
# Configure JSON encoder for proper Turkish character support
|
||||||
import json
|
import json
|
||||||
@@ -154,9 +153,8 @@ async def custom_401_handler(request: Request, exc: HTTPException):
|
|||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
# Mount MCP app at /mcp to handle all MCP protocol requests
|
# Mount MCP app - the path is already configured in http_app(path="/mcp")
|
||||||
# Using path="/mcp/" with trailing slash to avoid redirects
|
app.mount("", mcp_app)
|
||||||
app.mount("/mcp/", mcp_app)
|
|
||||||
|
|
||||||
# Set the lifespan context after mounting
|
# Set the lifespan context after mounting
|
||||||
app.router.lifespan_context = mcp_app.lifespan
|
app.router.lifespan_context = mcp_app.lifespan
|
||||||
|
|||||||
Reference in New Issue
Block a user