Skip to main content
Glama
ConnorBoetig-dev

Unrestricted Development MCP Server

docker_compose_logs

View container output from docker-compose stacks to monitor application behavior and debug issues. Filter by specific services, set line limits, or view logs from specific time periods.

Instructions

View output from containers in a docker-compose stack

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
servicesNoOnly show logs for specific services
tailNoNumber of lines to show from end of logs
sinceNoShow logs since timestamp
timestampsNoShow timestamps
fileNoPath to compose file
cwdNoWorking directory

Implementation Reference

  • The main handler function that constructs and executes the docker compose logs command using dynamic flags and the executeDockerCommand helper.
    export async function dockerComposeLogs(args: z.infer<typeof dockerComposeLogsSchema>): Promise<ToolResponse> { const tailFlag = args.tail ? `--tail ${args.tail}` : ''; const sinceFlag = args.since ? `--since ${args.since}` : ''; const timestampsFlag = args.timestamps ? '-t' : ''; const services = args.services ? args.services.join(' ') : ''; const fileFlag = args.file ? `-f ${args.file}` : ''; const composeCmd = await getComposeCmd(); return executeDockerCommand( `${composeCmd} ${fileFlag} logs ${tailFlag} ${sinceFlag} ${timestampsFlag} ${services}`.trim(), args.cwd ); }
  • Zod schema for input validation of the docker_compose_logs tool parameters.
    export const dockerComposeLogsSchema = z.object({ services: z.array(z.string()).optional().describe('Only show logs for specific services'), tail: z.number().optional().describe('Number of lines to show from end of logs'), since: z.string().optional().describe('Show logs since timestamp'), timestamps: z.boolean().optional().default(false).describe('Show timestamps'), file: z.string().optional().describe('Path to compose file'), cwd: z.string().optional().describe('Working directory') });
  • src/index.ts:495-498 (registration)
    Dispatch logic in the main MCP server handler that validates arguments with the schema and calls the dockerComposeLogs handler function.
    if (name === 'docker_compose_logs') { const validated = dockerComposeLogsSchema.parse(args); return await dockerComposeLogs(validated); }
  • Tool metadata definition including name, description, and JSON input schema, included in the dockerTools array for listing available tools.
    { name: 'docker_compose_logs', description: 'View output from containers in a docker-compose stack', inputSchema: { type: 'object', properties: { services: { type: 'array', items: { type: 'string' }, description: 'Only show logs for specific services' }, tail: { type: 'number', description: 'Number of lines to show from end of logs' }, since: { type: 'string', description: 'Show logs since timestamp' }, timestamps: { type: 'boolean', default: false, description: 'Show timestamps' }, file: { type: 'string', description: 'Path to compose file' }, cwd: { type: 'string', description: 'Working directory' } } } },
  • Core helper function that executes any docker command via child_process.exec and formats the response in MCP ToolResponse format.
    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