mirror of
https://github.com/latinogino/dolibarr-mcp.git
synced 2026-04-24 10:35:35 +02:00
Fix MCP HTTP route handling with ASGI adapter
This commit is contained in:
@@ -20,7 +20,7 @@ from .dolibarr_client import DolibarrClient, DolibarrAPIError
|
|||||||
# HTTP transport imports
|
# HTTP transport imports
|
||||||
from starlette.applications import Starlette
|
from starlette.applications import Starlette
|
||||||
from starlette.responses import Response
|
from starlette.responses import Response
|
||||||
from starlette.routing import Route
|
from starlette.routing import ASGIRoute, Route
|
||||||
import uvicorn
|
import uvicorn
|
||||||
|
|
||||||
|
|
||||||
@@ -1455,12 +1455,16 @@ def _build_http_app(session_manager: StreamableHTTPSessionManager) -> Starlette:
|
|||||||
async with session_manager.run():
|
async with session_manager.run():
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
async def asgi_handler(scope, receive, send):
|
||||||
|
"""Adapter to call the StreamableHTTPSessionManager with ASGI signature."""
|
||||||
|
await session_manager.handle_request(scope, receive, send)
|
||||||
|
|
||||||
return Starlette(
|
return Starlette(
|
||||||
routes=[
|
routes=[
|
||||||
Route("/", session_manager.handle_request, methods=["GET", "POST", "DELETE"]),
|
ASGIRoute("/", asgi_handler, methods=["GET", "POST", "DELETE"]),
|
||||||
Route("/{path:path}", session_manager.handle_request, methods=["GET", "POST", "DELETE"]),
|
ASGIRoute("/{path:path}", asgi_handler, methods=["GET", "POST", "DELETE"]),
|
||||||
Route("/", options_handler, methods=["OPTIONS"]),
|
ASGIRoute("/", options_handler, methods=["OPTIONS"]),
|
||||||
Route("/{path:path}", options_handler, methods=["OPTIONS"]),
|
ASGIRoute("/{path:path}", options_handler, methods=["OPTIONS"]),
|
||||||
],
|
],
|
||||||
lifespan=lifespan,
|
lifespan=lifespan,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user