Skip to content

Commit 0d01bae

Browse files
zjxzjwjubaoliang-tencentcursoragent
authored
fix(mcp): run internal gateway MCP handlers off the event loop (#27)
POST /api/internal/mcp can invoke sync httpx/IMAP in handle_mcp_request; await asyncio.to_thread(...) so those calls do not block uvicorn. Co-authored-by: jubaoliang <jubaoliang@tencent.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 0a5f658 commit 0d01bae

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/octop/api/routers/internal_mcp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ async def internal_mcp_post(
7979
if method == "initialize":
8080
session_id = secrets.token_urlsafe(16)
8181

82-
resp = handle_mcp_request(kind=kind, creds=creds, body=body)
82+
resp = await asyncio.to_thread(handle_mcp_request, kind=kind, creds=creds, body=body)
8383
if not resp:
8484
return Response(status_code=202)
8585

0 commit comments

Comments
 (0)