kill unused mcp servers
This commit is contained in:
parent
432221b87d
commit
d11ed7da53
2 changed files with 12 additions and 0 deletions
|
|
@ -369,6 +369,11 @@ async function configYamlToContinueConfig(
|
|||
|
||||
// Apply MCP if specified
|
||||
const mcpManager = MCPManagerSingleton.getInstance();
|
||||
if (config.mcpServers) {
|
||||
await mcpManager.removeUnusedConnections(
|
||||
config.mcpServers.map((s) => s.name),
|
||||
);
|
||||
}
|
||||
await Promise.allSettled(
|
||||
config.mcpServers?.map(async (server) => {
|
||||
const abortController = new AbortController();
|
||||
|
|
|
|||
|
|
@ -46,6 +46,13 @@ export class MCPManagerSingleton {
|
|||
|
||||
this.connections.delete(id);
|
||||
}
|
||||
|
||||
async removeUnusedConnections(keepIds: string[]) {
|
||||
const toRemove = this.connections
|
||||
.keys()
|
||||
.filter((k) => !keepIds.includes(k));
|
||||
await Promise.all(toRemove.map(this.removeConnection));
|
||||
}
|
||||
}
|
||||
|
||||
class MCPConnection {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue