MCPcopy Create free account
hub / github.com/freecodexyz/free-code / clearServerCache

Function clearServerCache

src/services/mcp/client.ts:1650–1675  ·  view source on GitHub ↗
(
  name: string,
  serverRef: ScopedMcpServerConfig,
)

Source from the content-addressed store, hash-verified

1648 * @param serverRef Server configuration
1649 */
1650export async function clearServerCache(
1651 name: string,
1652 serverRef: ScopedMcpServerConfig,
1653): Promise<void> {
1654 const key = getServerCacheKey(name, serverRef)
1655
1656 try {
1657 const wrappedClient = await connectToServer(name, serverRef)
1658
1659 if (wrappedClient.type === 'connected') {
1660 await wrappedClient.cleanup()
1661 }
1662 } catch {
1663 // Ignore errors - server might have failed to connect
1664 }
1665
1666 // Clear from cache (both connection and fetch caches so reconnect
1667 // fetches fresh tools/resources/commands instead of stale ones)
1668 connectToServer.cache.delete(key)
1669 fetchToolsForClient.cache.delete(name)
1670 fetchResourcesForClient.cache.delete(name)
1671 fetchCommandsForClient.cache.delete(name)
1672 if (feature('MCP_SKILLS')) {
1673 fetchMcpSkillsForClient!.cache.delete(name)
1674 }
1675}
1676
1677/**
1678 * Ensures a valid connected client for an MCP server.

Callers 10

runFunction · 0.85
MCPRemoteServerMenuFunction · 0.85
handleClearAuthFunction · 0.85
IDECommandFlowFunction · 0.85
runHeadlessStreamingFunction · 0.85
reconcileMcpServersFunction · 0.85
reconnectMcpServerImplFunction · 0.85
callMCPToolFunction · 0.85
useManageMCPConnectionsFunction · 0.85

Calls 3

getServerCacheKeyFunction · 0.85
deleteMethod · 0.80
cleanupMethod · 0.45

Tested by

no test coverage detected