fix(mcp): clean up connections on exit in interactive and gateway modes

This commit is contained in:
Sergio Sánchez Vallés 2026-02-12 10:44:25 +01:00
parent 61e9f7f58a
commit d30523f460
No known key found for this signature in database

View File

@ -387,6 +387,8 @@ def gateway(
)
except KeyboardInterrupt:
console.print("\nShutting down...")
finally:
await agent._close_mcp()
heartbeat.stop()
cron.stop()
agent.stop()
@ -465,6 +467,7 @@ def agent(
signal.signal(signal.SIGINT, _exit_on_sigint)
async def run_interactive():
try:
while True:
try:
_flush_pending_tty_input()
@ -489,6 +492,8 @@ def agent(
_restore_terminal()
console.print("\nGoodbye!")
break
finally:
await agent_loop._close_mcp()
asyncio.run(run_interactive())