docker_compose
Manage Docker Compose services to start, stop, monitor, and control multi-container applications through the Docker MCP Server.
Instructions
Manage Docker Compose services
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Docker Compose action to perform | |
| service | No | Specific service name (optional) | |
| detach | No | Run in detached mode | |
| build | No | Build images before starting (for up action) |
Implementation Reference
- src/index.ts:1816-1876 (registration)Registration of the 'docker_compose' MCP tool, including schema and inline handler function.server.registerTool( "docker_compose", { title: "Docker Compose Management", description: "Manage Docker Compose services", inputSchema: { action: z.enum(["up", "down", "logs", "ps", "restart", "build"]).describe("Docker Compose action to perform"), service: z.string().optional().describe("Specific service name (optional)"), detach: z.boolean().optional().default(true).describe("Run in detached mode"), build: z.boolean().optional().describe("Build images before starting (for up action)") } }, async ({ action, service, detach, build }) => { try { let command: string; const serviceArg = service ? ` ${service}` : ""; switch (action) { case "up": command = `docker-compose up${detach ? " -d" : ""}${build ? " --build" : ""}${serviceArg}`; break; case "down": command = `docker-compose down${serviceArg}`; break; case "logs": command = `docker-compose logs${serviceArg}`; break; case "ps": command = "docker-compose ps"; break; case "restart": command = `docker-compose restart${serviceArg}`; break; case "build": command = `docker-compose build${serviceArg}`; break; } const result = await executeDockerCommand(command); return { content: [ { type: "text", text: `Docker Compose ${action} completed:\n\n${result.stdout}${result.stderr ? `\nWarnings:\n${result.stderr}` : ""}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error with Docker Compose: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
- src/index.ts:1828-1875 (handler)The handler function that constructs and executes docker-compose commands based on the input action (up, down, logs, ps, restart, build). Uses the shared executeDockerCommand helper.async ({ action, service, detach, build }) => { try { let command: string; const serviceArg = service ? ` ${service}` : ""; switch (action) { case "up": command = `docker-compose up${detach ? " -d" : ""}${build ? " --build" : ""}${serviceArg}`; break; case "down": command = `docker-compose down${serviceArg}`; break; case "logs": command = `docker-compose logs${serviceArg}`; break; case "ps": command = "docker-compose ps"; break; case "restart": command = `docker-compose restart${serviceArg}`; break; case "build": command = `docker-compose build${serviceArg}`; break; } const result = await executeDockerCommand(command); return { content: [ { type: "text", text: `Docker Compose ${action} completed:\n\n${result.stdout}${result.stderr ? `\nWarnings:\n${result.stderr}` : ""}` } ] }; } catch (error) { return { content: [ { type: "text", text: `Error with Docker Compose: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
- src/index.ts:1818-1826 (schema)The input schema defining parameters for the docker_compose tool: action (required enum), optional service, detach, and build flags.{ title: "Docker Compose Management", description: "Manage Docker Compose services", inputSchema: { action: z.enum(["up", "down", "logs", "ps", "restart", "build"]).describe("Docker Compose action to perform"), service: z.string().optional().describe("Specific service name (optional)"), detach: z.boolean().optional().default(true).describe("Run in detached mode"), build: z.boolean().optional().describe("Build images before starting (for up action)") }