MCPcopy Index your code
hub / github.com/codeaashu/claude-code / cleanup

Function cleanup

src/tools/AgentTool/runAgent.ts:197–210  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

195 // Only clean up newly created clients (inline definitions), not shared/referenced ones
196 // Shared clients (referenced by string name) are memoized and used by the parent context
197 const cleanup = async () => {
198 for (const client of newlyCreatedClients) {
199 if (client.type === 'connected') {
200 try {
201 await client.cleanup()
202 } catch (error) {
203 logForDebugging(
204 `[Agent: ${agentDefinition.agentType}] Error cleaning up MCP server '${client.name}': ${error}`,
205 { level: 'warn' },
206 )
207 }
208 }
209 }
210 }
211
212 // Return merged clients (parent + agent-specific) and agent tools
213 return {

Callers

nothing calls this directly

Calls 2

logForDebuggingFunction · 0.85
cleanupMethod · 0.45

Tested by

no test coverage detected