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

Function clearServerCache

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

Source from the content-addressed store, hash-verified

1658 * @param serverRef Server configuration
1659 */
1660export async function clearServerCache(
1661 name: string,
1662 serverRef: ScopedMcpServerConfig,
1663): Promise<void> {
1664 const key = getServerCacheKey(name, serverRef)
1665
1666 try {
1667 const wrappedClient = await connectToServer(name, serverRef)
1668
1669 if (wrappedClient.type === 'connected') {
1670 await wrappedClient.cleanup()
1671 }
1672 } catch {
1673 // Ignore errors - server might have failed to connect
1674 }
1675
1676 // Clear from cache (both connection and fetch caches so reconnect
1677 // fetches fresh tools/resources/commands instead of stale ones)
1678 connectToServer.cache.delete(key)
1679 fetchToolsForClient.cache.delete(name)
1680 fetchResourcesForClient.cache.delete(name)
1681 fetchCommandsForClient.cache.delete(name)
1682 if (feature('MCP_SKILLS')) {
1683 fetchMcpSkillsForClient!.cache.delete(name)
1684 }
1685}
1686
1687/**
1688 * 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.65
cleanupMethod · 0.45

Tested by

no test coverage detected