mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-09 08:21:50 +00:00
fix(mcp): ensure server.shutdown() on probe iteration failure
Wrap the _tools iteration in _probe_single_server() in try/finally so that server.shutdown() is called even if iterating tool metadata raises. Without this, the MCP server connection leaks until the event loop is torn down by _stop_mcp_loop().
This commit is contained in:
parent
454d6cbe52
commit
751b91446e
1 changed files with 9 additions and 7 deletions
|
|
@ -225,13 +225,15 @@ def _probe_single_server(
|
|||
server = await asyncio.wait_for(
|
||||
_connect_server(name, config), timeout=connect_timeout
|
||||
)
|
||||
for t in server._tools:
|
||||
desc = getattr(t, "description", "") or ""
|
||||
# Truncate long descriptions for display
|
||||
if len(desc) > 80:
|
||||
desc = desc[:77] + "..."
|
||||
tools_found.append((t.name, desc))
|
||||
await server.shutdown()
|
||||
try:
|
||||
for t in server._tools:
|
||||
desc = getattr(t, "description", "") or ""
|
||||
# Truncate long descriptions for display
|
||||
if len(desc) > 80:
|
||||
desc = desc[:77] + "..."
|
||||
tools_found.append((t.name, desc))
|
||||
finally:
|
||||
await server.shutdown()
|
||||
|
||||
try:
|
||||
_run_on_mcp_loop(_probe(), timeout=connect_timeout + 10)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue