MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / deleteConnection

Method deleteConnection

src/services/mcp/McpHub.ts:1521–1564  ·  view source on GitHub ↗
(name: string, source?: "global" | "project")

Source from the content-addressed store, hash-verified

1519 }
1520
1521 async deleteConnection(name: string, source?: "global" | "project"): Promise<void> {
1522 // Cancel any active OAuth token watchers for this connection
1523 const watcherKey = `${name}:${source}`
1524 const watcher = this._oauthWatchers.get(watcherKey)
1525 if (watcher) {
1526 watcher.unsubscribe()
1527 clearTimeout(watcher.abortHandle)
1528 this._oauthWatchers.delete(watcherKey)
1529 }
1530
1531 // Clean up file watchers for this server
1532 this.removeFileWatchersForServer(name)
1533
1534 // If source is provided, only delete connections from that source
1535 const connections = source
1536 ? this.connections.filter((conn) => conn.server.name === name && conn.server.source === source)
1537 : this.connections.filter((conn) => conn.server.name === name)
1538
1539 for (const connection of connections) {
1540 try {
1541 if (connection.type === "connected") {
1542 await connection.transport.close()
1543 await connection.client.close()
1544 await connection.authProvider?.close()
1545 }
1546 } catch (error) {
1547 console.error(`Failed to close transport or auth provider for ${name}:`, error)
1548 }
1549 }
1550
1551 // Remove the connections from the array
1552 this.connections = this.connections.filter((conn) => {
1553 if (conn.server.name !== name) return true
1554 if (source && conn.server.source !== source) return true
1555 return false
1556 })
1557
1558 // Remove from sanitized name registry if no more connections with this name exist
1559 const remainingConnections = this.connections.filter((conn) => conn.server.name === name)
1560 if (remainingConnections.length === 0) {
1561 const sanitizedName = sanitizeMcpName(name)
1562 this.sanitizedNameRegistry.delete(sanitizedName)
1563 }
1564 }
1565
1566 async updateServerConnections(
1567 newServers: Record<string, any>,

Callers 13

connectToServerMethod · 0.95
_initiateOAuthFlowMethod · 0.95
onTokensChangedMethod · 0.95
_runOAuthFlowMethod · 0.95
_completeOAuthFlowMethod · 0.95
restartConnectionMethod · 0.95
refreshAllConnectionsMethod · 0.95
toggleServerDisabledMethod · 0.95
disposeMethod · 0.95

Calls 6

sanitizeMcpNameFunction · 0.90
getMethod · 0.65
deleteMethod · 0.65
closeMethod · 0.65
errorMethod · 0.65

Tested by

no test coverage detected