Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

docker_compose_down

Stop and remove Docker containers and networks created by docker-compose up, with options to delete volumes and orphaned containers for clean environment management.

Instructions

Stop and remove containers, networks created by docker-compose up

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
volumesNoRemove named volumes
removeOrphansNoRemove containers for services not in compose file
fileNoPath to compose file
cwdNoWorking directory

Implementation Reference

  • The main handler function that constructs and executes the 'docker compose down' command with options for volumes, orphans, compose file, and working directory.
    export async function dockerComposeDown(args: z.infer<typeof dockerComposeDownSchema>): Promise<ToolResponse> { const volumesFlag = args.volumes ? '-v' : ''; const orphansFlag = args.removeOrphans ? '--remove-orphans' : ''; const fileFlag = args.file ? `-f ${args.file}` : ''; const composeCmd = await getComposeCmd(); return executeDockerCommand( `${composeCmd} ${fileFlag} down ${volumesFlag} ${orphansFlag}`.trim(), args.cwd ); }
  • Zod schema used for runtime input validation of the docker_compose_down tool parameters.
    export const dockerComposeDownSchema = z.object({ volumes: z.boolean().optional().default(false).describe('Remove named volumes'), removeOrphans: z.boolean().optional().default(false).describe('Remove containers for services not in compose file'), file: z.string().optional().describe('Path to compose file'), cwd: z.string().optional().describe('Working directory') });
  • MCP tool definition/registration in the dockerTools array, including JSON schema for tool listing.
    { name: 'docker_compose_down', description: 'Stop and remove containers, networks created by docker-compose up', inputSchema: { type: 'object', properties: { volumes: { type: 'boolean', default: false, description: 'Remove named volumes' }, removeOrphans: { type: 'boolean', default: false, description: 'Remove containers for services not in compose file' }, file: { type: 'string', description: 'Path to compose file' }, cwd: { type: 'string', description: 'Working directory' } } } },
  • src/index.ts:487-489 (registration)
    Runtime dispatch/registration in the main CallToolRequest handler that routes calls to the dockerComposeDown function after schema validation.
    if (name === 'docker_compose_down') { const validated = dockerComposeDownSchema.parse(args); return await dockerComposeDown(validated);
  • Core helper function used by all Docker tools, including dockerComposeDown, to execute shell commands and format responses.
    async function executeDockerCommand(command: string, cwd?: string): Promise<ToolResponse> { try { const { stdout, stderr } = await execAsync(command, { cwd: cwd || process.cwd(), shell: '/bin/bash', maxBuffer: 10 * 1024 * 1024, // 10MB buffer for logs timeout: 60000 // 60 second timeout for builds }); return { content: [ { type: "text" as const, text: JSON.stringify({ success: true, command: command, stdout: stdout.trim(), stderr: stderr.trim(), cwd: cwd || process.cwd() }, null, 2) } ] }; } catch (error: any) { return { content: [ { type: "text" as const, text: JSON.stringify({ success: false, command: command, stdout: error.stdout?.trim() || '', stderr: error.stderr?.trim() || error.message, exitCode: error.code || 1, cwd: cwd || process.cwd() }, null, 2) } ], isError: true }; } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ConnorBoetig-dev/mcp2'

If you have feedback or need assistance with the MCP directory API, please join our Discord server