From 79060acfc91c49e15e3c81dd49043133323c64aa Mon Sep 17 00:00:00 2001 From: Ruoyu Lu <93816781+ruoyu-lu@users.noreply.github.com> Date: Wed, 23 Sep 2026 14:36:07 +1000 Subject: [PATCH] fix(mcp): keep local OpenAPI reads off the event loop --- .../_experimental/mcp_server/openapi_to_mcp_generator.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/_experimental/mcp_server/openapi_to_mcp_generator.py b/litellm/proxy/_experimental/mcp_server/openapi_to_mcp_generator.py index 16f58ef5b76..4d8693317e3 100644 --- a/litellm/proxy/_experimental/mcp_server/openapi_to_mcp_generator.py +++ b/litellm/proxy/_experimental/mcp_server/openapi_to_mcp_generator.py @@ -170,8 +170,10 @@ async def load_openapi_spec_async(filepath: str) -> dict[str, Any]: r.raise_for_status() return r.json() - # fallback: local file - # Local filesystem path + return await asyncio.to_thread(_read_local_openapi_spec, filepath) + + +def _read_local_openapi_spec(filepath: str) -> dict[str, Any]: if not os.path.exists(filepath): raise FileNotFoundError(f"OpenAPI spec not found at {filepath}") with open(filepath, "r", encoding="utf-8") as f: