From bcc5f4294113ae28be49508481b6cc2b56818c8b Mon Sep 17 00:00:00 2001 From: Saket Aryan Date: Mon, 14 Jul 2025 21:25:45 +0530 Subject: [PATCH] Restore and update handle_post_message implementation (#3152) --- openmemory/api/app/mcp_server.py | 34 +++++++++++++++----------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/openmemory/api/app/mcp_server.py b/openmemory/api/app/mcp_server.py index f4759628..914eb15b 100644 --- a/openmemory/api/app/mcp_server.py +++ b/openmemory/api/app/mcp_server.py @@ -410,28 +410,26 @@ async def handle_get_message(request: Request): async def handle_post_message(request: Request): return await handle_post_message(request) -# async def handle_post_message(request: Request): -# """Handle POST messages for SSE""" -# try: -# body = await request.body() +async def handle_post_message(request: Request): + """Handle POST messages for SSE""" + try: + body = await request.body() -# # Create a simple receive function that returns the body -# async def receive(): -# return {"type": "http.request", "body": body, "more_body": False} + # Create a simple receive function that returns the body + async def receive(): + return {"type": "http.request", "body": body, "more_body": False} -# # Create a simple send function that does nothing -# async def send(message): -# return {} + # Create a simple send function that does nothing + async def send(message): + return {} -# # Call handle_post_message with the correct arguments -# await sse.handle_post_message(request.scope, receive, send) + # Call handle_post_message with the correct arguments + await sse.handle_post_message(request.scope, receive, send) -# # Return a success response -# return {"status": "ok"} -# finally: -# pass -# # Clean up context variable -# # client_name_var.reset(client_token) + # Return a success response + return {"status": "ok"} + finally: + pass def setup_mcp_server(app: FastAPI): """Setup MCP server with the FastAPI application"""