Async load from file (future-proof for async I/O).
(cls, config_path: Path)
| 170 | |
| 171 | @classmethod |
| 172 | async def load_async(cls, config_path: Path) -> MCPConfig: |
| 173 | """Async load from file (future-proof for async I/O).""" |
| 174 | import asyncio |
| 175 | import json |
| 176 | |
| 177 | if not config_path.exists(): |
| 178 | return cls() |
| 179 | |
| 180 | # Use asyncio for file I/O |
| 181 | loop = asyncio.get_event_loop() |
| 182 | data = await loop.run_in_executor(None, config_path.read_text) |
| 183 | parsed = json.loads(data) |
| 184 | |
| 185 | return cls.model_validate(parsed) # type: ignore[no-any-return] |
| 186 | |
| 187 | @classmethod |
| 188 | def load_sync(cls, config_path: Path) -> MCPConfig: |
no outgoing calls