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

Method findConnection

src/services/mcp/McpHub.ts:1378–1395  ·  view source on GitHub ↗

* Helper method to find a connection by server name and source * @param serverName The name of the server to find * @param source Optional source to filter by (global or project) * @returns The matching connection or undefined if not found

(serverName: string, source?: "global" | "project")

Source from the content-addressed store, hash-verified

1376 * @returns The matching connection or undefined if not found
1377 */
1378 private findConnection(serverName: string, source?: "global" | "project"): McpConnection | undefined {
1379 // If source is specified, only find servers with that source
1380 if (source !== undefined) {
1381 return this.connections.find((conn) => conn.server.name === serverName && conn.server.source === source)
1382 }
1383
1384 // If no source is specified, first look for project servers, then global servers
1385 // This ensures that when servers have the same name, project servers are prioritized
1386 const projectConn = this.connections.find(
1387 (conn) => conn.server.name === serverName && conn.server.source === "project",
1388 )
1389 if (projectConn) return projectConn
1390
1391 // If no project server is found, look for global servers
1392 return this.connections.find(
1393 (conn) => conn.server.name === serverName && (conn.server.source === "global" || !conn.server.source),
1394 )
1395 }
1396
1397 /**
1398 * Find a connection by sanitized server name.

Callers 15

connectToServerMethod · 0.95
onTokensChangedMethod · 0.95
_runOAuthFlowMethod · 0.95
_completeOAuthFlowMethod · 0.95
fetchToolsListMethod · 0.95
fetchResourcesListMethod · 0.95
restartConnectionMethod · 0.95
toggleServerDisabledMethod · 0.95
updateServerTimeoutMethod · 0.95
deleteServerMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected