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

Function clearServerCache

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

Source from the content-addressed store, hash-verified

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