MCPcopy
hub / github.com/codeaashu/claude-code / clearServerCache

Function clearServerCache

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

Source from the content-addressed store, hash-verified

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

getServerCacheKeyFunction · 0.85
featureFunction · 0.85
deleteMethod · 0.65
cleanupMethod · 0.45

Tested by

no test coverage detected