fix(mcp): widen isinstance check to BaseException for CancelledError

asyncio.gather(return_exceptions=True) captures CancelledError as a
BaseException value. The previous isinstance(result, Exception) check
missed CancelledError, silently dropping it without logging.

Since Python 3.9, CancelledError is a BaseException subclass (not
Exception). This one-line change ensures all failure types from MCP
server connections are properly logged.

Fixes NousResearch/hermes-agent#34443
This commit is contained in:
annguyenNous 2026-05-29 14:33:33 +07:00 committed by Teknium
parent 4fd8521e44
commit 9f5afc7636

View file

@ -3366,7 +3366,7 @@ def register_mcp_servers(servers: Dict[str, dict]) -> List[str]:
return_exceptions=True,
)
for name, result in zip(server_names, results):
if isinstance(result, Exception):
if isinstance(result, BaseException):
command = new_servers.get(name, {}).get("command")
logger.warning(
"Failed to connect to MCP server '%s'%s: %s",