feat: Implement lazy MCP client shutdown

This commit is contained in:
Aleksander Grygier 2026-01-02 19:37:41 +01:00
parent 9571e07687
commit 069be7b517
1 changed files with 7 additions and 0 deletions

View File

@ -202,6 +202,13 @@ class AgenticStore {
return { handled: true, error: normalizedError };
} finally {
this._isRunning = false;
// Lazy Disconnect: Close MCP connections after agentic flow completes
// This prevents continuous keepalive/heartbeat polling when tools are not in use
await mcpStore.shutdown().catch((err) => {
console.warn('[AgenticStore] Failed to shutdown MCP after flow:', err);
});
console.log('[AgenticStore] MCP connections closed (lazy disconnect)');
}
}