Skip to content

Commit c55e126

Browse files
committed
fix: force disconnect on runtime error and reconnect
1 parent 347b2e6 commit c55e126

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

mcp_proxy_for_aws/proxy.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ async def _connect(self):
106106
raise McpError(error=jsonrpc_msg.error) from http_error
107107
else:
108108
raise http_error
109+
except RuntimeError:
110+
try:
111+
logger.warning('encountered runtime error, try force disconnect.')
112+
await self._disconnect(force=True)
113+
except Exception:
114+
logger.warning('encountered another error, raising the previous runtime error.')
115+
return await self._connect()
109116

110117
async def __aexit__(self, exc_type, exc_val, exc_tb):
111118
"""The MCP Proxy for AWS project is a proxy from stdio to http (sigv4).

0 commit comments

Comments
 (0)