fix: refactor handle_sse to standard ASGI to avoid Starlette TypeError
All checks were successful
Build and Push Monarch MCP Docker Image / build (push) Successful in 8s

This commit is contained in:
Ben
2025-12-24 04:43:06 +00:00
parent 776b4b8cc8
commit 177832053f

View File

@@ -183,8 +183,8 @@ def create_app():
# Stream endpoint at /mcp, messages at /mcp/messages # Stream endpoint at /mcp, messages at /mcp/messages
sse = SseServerTransport("/mcp/messages") sse = SseServerTransport("/mcp/messages")
async def handle_sse(request): async def handle_sse(scope, receive, send):
async with sse.connect_sse(request.scope, request.receive, request._send) as ( async with sse.connect_sse(scope, receive, send) as (
read_stream, read_stream,
write_stream, write_stream,
): ):
@@ -196,7 +196,7 @@ def create_app():
routes = [ routes = [
Route("/health", health_check, methods=["GET"]), Route("/health", health_check, methods=["GET"]),
Route("/mcp", endpoint=handle_sse, methods=["GET"]), Route("/mcp", endpoint=handle_sse),
Route("/mcp/messages", endpoint=sse.handle_post_message, methods=["POST"]), Route("/mcp/messages", endpoint=sse.handle_post_message, methods=["POST"]),
] ]