fix(mcp): keep local OpenAPI reads off the event loop

This commit is contained in:
Ruoyu Lu 2026-09-23 14:36:07 +10:00
parent 229f1fb6d9
commit 79060acfc9

View file

@ -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: