docker_cleanup
Removes unused Docker containers and resources tracked by the Code MCP Server to free up system space and maintain a clean development environment.
Instructions
Clean up tracked Docker containers and resources
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/services/DockerService.ts:1093-1113 (handler)The handler function that executes docker_cleanup logic. Iterates over tracked containers (runningContainers map), stops and removes each one, and returns results.
async cleanupTrackedContainers(): Promise<ToolResult> { const results: string[] = []; for (const [name, info] of this.runningContainers) { try { await this.manageContainers({ action: 'stop', container: name }); await this.manageContainers({ action: 'remove', container: name, force: true }); this.runningContainers.delete(name); results.push(`✅ Cleaned up container: ${name}`); } catch (error: any) { results.push(`❌ Failed to cleanup container ${name}: ${error.message}`); } } return { content: [{ type: 'text', text: results.join('\n') || 'No tracked containers to clean up', }], }; } - src/toolDefinitions.ts:620-627 (schema)Schema definition for docker_cleanup tool - no input parameters, just description and empty inputSchema.
{ name: 'docker_cleanup', description: 'Clean up tracked Docker containers and resources', inputSchema: { type: 'object', properties: {}, }, }, - src/index.ts:225-226 (registration)Registration/case statement that routes 'docker_cleanup' to DockerService.cleanupTrackedContainers().
case 'docker_cleanup': return await this.dockerService.cleanupTrackedContainers(); - The runningContainers Map that stores tracked containers used by the cleanup handler.
private runningContainers: Map<string, any> = new Map();