Skip to content

Commit b6595f7

Browse files
committed
fix: no need throw err when can't connect mcp
1 parent afb97f0 commit b6595f7

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

openhands/mcp/mcp.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,8 @@ async def connect_sse(self, server_url: str, timeout: float = 30.0) -> None:
104104
await connection_task
105105
except asyncio.CancelledError:
106106
pass
107-
raise TimeoutError(f'Connection to {server_url} timed out after {timeout} seconds')
108107
except Exception as e:
109-
if not isinstance(e, TimeoutError):
110-
logger.error(f'Error connecting to {server_url}: {str(e)}')
111-
raise
108+
logger.error(f'Error connecting to {server_url}: {str(e)}')
112109

113110
async def _connect_sse_internal(self, server_url: str) -> None:
114111
"""Internal method to establish SSE connection."""
@@ -154,11 +151,8 @@ async def connect_stdio(self, command: str, args: List[str], envs: List[tuple[st
154151
await connection_task
155152
except asyncio.CancelledError:
156153
pass
157-
raise TimeoutError(f'Connection to {command} timed out after {timeout} seconds')
158154
except Exception as e:
159-
if not isinstance(e, TimeoutError):
160-
logger.error(f'Error connecting to {command}: {str(e)}')
161-
raise
155+
logger.error(f'Error connecting to {command}: {str(e)}')
162156

163157
async def _connect_stdio_internal(self, command: str, args: List[str], envs: List[tuple[str, str]]) -> None:
164158
"""Internal method to establish stdio connection."""

0 commit comments

Comments
 (0)