Skip to main content
Glama

generate_docker_compose

Generates a Docker Compose file template for specified services, with optional database support for PostgreSQL and Redis, to simplify environment setup.

Instructions

Generate a Docker Compose file template

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
servicesYesList of service names to include
include_databaseNoInclude database services (PostgreSQL, Redis)

Implementation Reference

  • Main handler function 'generateDockerCompose' that generates a Docker Compose file, writes it to disk, and returns the result.
    async generateDockerCompose(services: string[], includeDatabase = false): Promise<ToolResult> {
      const composeContent = this.generateDockerComposeContent(services, includeDatabase);
      const composePath = path.join(this.getCurrentWorkspace(), 'docker-compose.yml');
      
      try {
        await fs.writeFile(composePath, composeContent);
        return {
          content: [{
            type: 'text',
            text: `Docker Compose file generated successfully at: ${composePath}\n\nContent:\n${composeContent}`,
          }],
        };
      } catch (error: any) {
        throw new Error(`Failed to write Docker Compose file: ${error.message}`);
      }
    }
  • Private helper 'generateDockerComposeContent' that constructs the actual YAML content for the docker-compose.yml file, including services and optional database (PostgreSQL, Redis) configuration.
      private generateDockerComposeContent(services: string[], includeDatabase: boolean): string {
        let content = `version: '3.8'
    
    services:
    `;
    
        // Add main application services
        services.forEach(service => {
          content += `  ${service}:
        build: .
        ports:
          - "3000:3000"
        environment:
          - NODE_ENV=production
        volumes:
          - .:/app
          - /app/node_modules
        depends_on:
          - db
        networks:
          - app-network
        restart: unless-stopped
    
    `;
        });
    
        // Add database if requested
        if (includeDatabase) {
          content += `  db:
        image: postgres:15
        environment:
          POSTGRES_DB: appdb
          POSTGRES_USER: appuser
          POSTGRES_PASSWORD: apppass
        volumes:
          - postgres_data:/var/lib/postgresql/data
        ports:
          - "5432:5432"
        networks:
          - app-network
        restart: unless-stopped
    
      redis:
        image: redis:7-alpine
        ports:
          - "6379:6379"
        networks:
          - app-network
        restart: unless-stopped
    
    `;
        }
    
        content += `networks:
      app-network:
        driver: bridge
    
    `;
    
        if (includeDatabase) {
          content += `volumes:
      postgres_data:
    `;
        }
    
        return content;
      }
  • Schema definition: registers tool name 'generate_docker_compose', description, and inputSchema with 'services' (array of strings) and optional 'include_database' (boolean).
    {
      name: 'generate_docker_compose',
      description: 'Generate a Docker Compose file template',
      inputSchema: {
        type: 'object',
        properties: {
          services: { 
            type: 'array', 
            items: { type: 'string' },
            description: 'List of service names to include' 
          },
          include_database: { type: 'boolean', description: 'Include database services (PostgreSQL, Redis)' },
        },
        required: ['services'],
      },
    },
  • src/index.ts:223-224 (registration)
    Registration in the main router: case 'generate_docker_compose' dispatches to dockerService.generateDockerCompose with args.services and args.include_database.
    case 'generate_docker_compose':
      return await this.dockerService.generateDockerCompose(args.services, args.include_database);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, and the description fails to disclose behavioral traits such as output format (file vs. string), side effects, prerequisites, or the nature of the generated template. This leaves significant ambiguity for an AI agent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, concise sentence that front-loads the main action. However, it could be slightly expanded to include key details without becoming verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the absence of an output schema and annotations, the description should explain what the tool returns and how parameters affect the output. It fails to do so, leaving the agent without essential context for a simple but multi-parameter tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema provides clear descriptions for both parameters (services and include_database), achieving 100% schema coverage. The description adds no additional information beyond the schema, so baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action 'Generate' and the resource 'Docker Compose file template', distinguishing it from sibling tools like 'docker_compose' and 'generate_dockerfile'. However, the term 'template' may introduce slight ambiguity regarding whether it produces a complete file or a template.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives such as 'docker_compose' or 'generate_dockerfile'. The description lacks context for when generation is appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/agentics-ai/code-mcp'

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