import { z } from 'zod'; import { config } from '../../config.js'; import { runCommand } from '../../lib/runCommand.js'; import { errorResult, jsonResult, toErrorMessage } from '../shared.js'; /** * Docker Compose is invoked via the local `docker compose` or `docker-compose` * CLI. The server does not parse compose files itself; it delegates to the * official tool and streams the output back, just like workflow tools. */ export function registerDockerComposeTools(server) { server.registerTool('docker_compose_up', { title: 'Docker Compose Up', description: 'Bring up a docker-compose.yml stack in the workspace root. Detached by default so the server does not block.', inputSchema: { file: z .string() .optional() .default('docker-compose.yml') .describe('Compose file path, relative to the workspace root.'), services: z .array(z.string()) .optional() .describe('Specific services to start. Omit to start all.'), build: z .boolean() .optional() .default(false) .describe('Build images before starting.'), }, }, async ({ file, services, build }) => { try { const args = ['compose', '-f', file, 'up', '-d']; if (build) args.push('--build'); if (services && services.length > 0) args.push(...services); const result = await runCommand('docker', args, { cwd: config.workspaceRoot, timeoutMs: config.scaffoldCommandTimeoutMs, }); return jsonResult({ file, ...result }); } catch (error) { return errorResult(toErrorMessage(error)); } }); server.registerTool('docker_compose_down', { title: 'Docker Compose Down', description: 'Shut down a docker-compose.yml stack in the workspace root.', inputSchema: { file: z .string() .optional() .default('docker-compose.yml') .describe('Compose file path, relative to the workspace root.'), volumes: z .boolean() .optional() .default(false) .describe('Also remove named volumes declared in the volumes section.'), }, }, async ({ file, volumes }) => { try { const args = ['compose', '-f', file, 'down']; if (volumes) args.push('-v'); const result = await runCommand('docker', args, { cwd: config.workspaceRoot, timeoutMs: config.defaultCommandTimeoutMs, }); return jsonResult({ file, ...result }); } catch (error) { return errorResult(toErrorMessage(error)); } }); } //# sourceMappingURL=compose.js.map