Skip to main content
Glama

docker_analyze_project

Analyze your project structure to generate Dockerfile recommendations for containerization, helping streamline DevOps workflows.

Instructions

Analyze project and suggest Dockerfile

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/index.js:199-376 (registration)
    MCP server.tool registration for the 'docker_analyze_project' tool. Includes tool description, input schema (path parameter), and the complete async handler function that detects project type by checking for specific files (pom.xml, package.json, etc.) and generates a recommended multi-stage Dockerfile and .dockerignore based on the detected type (java-maven, nodejs, python, etc.). Returns formatted text with the recommendations.
    server.tool(
      "docker_analyze_project",
      "Analyze project and suggest Dockerfile",
      { path: { type: "string", description: "Project path", default: "." } },
      async ({ path }) => {
        const projectPath = path || ".";
        let projectType = "unknown";
        let dockerfile = "";
        let dockerignore = "";
    
        // Detect project type
        const checks = [
          { file: "pom.xml", type: "java-maven" },
          { file: "build.gradle", type: "java-gradle" },
          { file: "package.json", type: "nodejs" },
          { file: "requirements.txt", type: "python" },
          { file: "go.mod", type: "golang" },
          { file: "Cargo.toml", type: "rust" },
        ];
    
        for (const check of checks) {
          try {
            await access(`${projectPath}/${check.file}`, constants.F_OK);
            projectType = check.type;
            break;
          } catch {}
        }
    
        // Generate Dockerfile based on project type
        const dockerfiles = {
          "java-maven": `# Build stage
    FROM maven:3.9-eclipse-temurin-17 AS build
    WORKDIR /app
    COPY pom.xml .
    RUN mvn dependency:go-offline
    COPY src ./src
    RUN mvn package -DskipTests
    
    # Runtime stage
    FROM eclipse-temurin:17-jre-alpine
    WORKDIR /app
    COPY --from=build /app/target/*.jar app.jar
    EXPOSE 8080
    ENTRYPOINT ["java", "-jar", "app.jar"]`,
    
          "java-gradle": `# Build stage
    FROM gradle:8-jdk17 AS build
    WORKDIR /app
    COPY build.gradle settings.gradle ./
    COPY gradle ./gradle
    RUN gradle dependencies --no-daemon
    COPY src ./src
    RUN gradle build -x test --no-daemon
    
    # Runtime stage
    FROM eclipse-temurin:17-jre-alpine
    WORKDIR /app
    COPY --from=build /app/build/libs/*.jar app.jar
    EXPOSE 8080
    ENTRYPOINT ["java", "-jar", "app.jar"]`,
    
          "nodejs": `FROM node:20-alpine
    WORKDIR /app
    COPY package*.json ./
    RUN npm ci --only=production
    COPY . .
    EXPOSE 3000
    CMD ["node", "index.js"]`,
    
          "python": `FROM python:3.11-slim
    WORKDIR /app
    COPY requirements.txt .
    RUN pip install --no-cache-dir -r requirements.txt
    COPY . .
    EXPOSE 8000
    CMD ["python", "app.py"]`,
    
          "golang": `# Build stage
    FROM golang:1.21-alpine AS build
    WORKDIR /app
    COPY go.mod go.sum ./
    RUN go mod download
    COPY . .
    RUN CGO_ENABLED=0 go build -o main .
    
    # Runtime stage
    FROM alpine:latest
    WORKDIR /app
    COPY --from=build /app/main .
    EXPOSE 8080
    CMD ["./main"]`,
    
          "rust": `# Build stage
    FROM rust:1.75 AS build
    WORKDIR /app
    COPY Cargo.toml Cargo.lock ./
    COPY src ./src
    RUN cargo build --release
    
    # Runtime stage
    FROM debian:bookworm-slim
    COPY --from=build /app/target/release/app /usr/local/bin/
    EXPOSE 8080
    CMD ["app"]`,
    
          "unknown": `# Could not detect project type
    # Please specify your base image and build steps
    FROM ubuntu:22.04
    WORKDIR /app
    COPY . .
    # Add your build and run commands here`
        };
    
        const dockerignores = {
          "java-maven": `target/
    *.class
    *.jar
    *.log
    .git/
    .idea/
    *.iml`,
          "java-gradle": `build/
    .gradle/
    *.class
    *.jar
    *.log
    .git/
    .idea/
    *.iml`,
          "nodejs": `node_modules/
    npm-debug.log
    .git/
    .env
    coverage/
    dist/`,
          "python": `__pycache__/
    *.pyc
    .git/
    .env
    venv/
    .venv/`,
          "golang": `.git/
    *.exe
    *.test
    *.out`,
          "rust": `target/
    .git/
    Cargo.lock`,
          "unknown": `.git/
    *.log
    .env`
        };
    
        dockerfile = dockerfiles[projectType];
        dockerignore = dockerignores[projectType];
    
        return {
          content: [{
            type: "text",
            text: `PROJECT TYPE DETECTED: ${projectType}
    
    RECOMMENDED DOCKERFILE:
    =======================
    ${dockerfile}
    
    RECOMMENDED .dockerignore:
    ==========================
    ${dockerignore}
    
    NEXT STEPS:
    1. Save Dockerfile:      Copy the above to ./Dockerfile
    2. Save .dockerignore:   Copy the above to ./.dockerignore
    3. Build image:          docker build -t myapp:latest .
    4. Run container:        docker run -p 8080:8080 myapp:latest`
          }]
        };
      }
    );
  • Input schema definition for the tool: optional 'path' string parameter defaulting to current directory.
    { path: { type: "string", description: "Project path", default: "." } },
  • The core handler function that implements the tool logic: detects project type, generates appropriate Dockerfile and .dockerignore, and returns them in a markdown-formatted response.
      async ({ path }) => {
        const projectPath = path || ".";
        let projectType = "unknown";
        let dockerfile = "";
        let dockerignore = "";
    
        // Detect project type
        const checks = [
          { file: "pom.xml", type: "java-maven" },
          { file: "build.gradle", type: "java-gradle" },
          { file: "package.json", type: "nodejs" },
          { file: "requirements.txt", type: "python" },
          { file: "go.mod", type: "golang" },
          { file: "Cargo.toml", type: "rust" },
        ];
    
        for (const check of checks) {
          try {
            await access(`${projectPath}/${check.file}`, constants.F_OK);
            projectType = check.type;
            break;
          } catch {}
        }
    
        // Generate Dockerfile based on project type
        const dockerfiles = {
          "java-maven": `# Build stage
    FROM maven:3.9-eclipse-temurin-17 AS build
    WORKDIR /app
    COPY pom.xml .
    RUN mvn dependency:go-offline
    COPY src ./src
    RUN mvn package -DskipTests
    
    # Runtime stage
    FROM eclipse-temurin:17-jre-alpine
    WORKDIR /app
    COPY --from=build /app/target/*.jar app.jar
    EXPOSE 8080
    ENTRYPOINT ["java", "-jar", "app.jar"]`,
    
          "java-gradle": `# Build stage
    FROM gradle:8-jdk17 AS build
    WORKDIR /app
    COPY build.gradle settings.gradle ./
    COPY gradle ./gradle
    RUN gradle dependencies --no-daemon
    COPY src ./src
    RUN gradle build -x test --no-daemon
    
    # Runtime stage
    FROM eclipse-temurin:17-jre-alpine
    WORKDIR /app
    COPY --from=build /app/build/libs/*.jar app.jar
    EXPOSE 8080
    ENTRYPOINT ["java", "-jar", "app.jar"]`,
    
          "nodejs": `FROM node:20-alpine
    WORKDIR /app
    COPY package*.json ./
    RUN npm ci --only=production
    COPY . .
    EXPOSE 3000
    CMD ["node", "index.js"]`,
    
          "python": `FROM python:3.11-slim
    WORKDIR /app
    COPY requirements.txt .
    RUN pip install --no-cache-dir -r requirements.txt
    COPY . .
    EXPOSE 8000
    CMD ["python", "app.py"]`,
    
          "golang": `# Build stage
    FROM golang:1.21-alpine AS build
    WORKDIR /app
    COPY go.mod go.sum ./
    RUN go mod download
    COPY . .
    RUN CGO_ENABLED=0 go build -o main .
    
    # Runtime stage
    FROM alpine:latest
    WORKDIR /app
    COPY --from=build /app/main .
    EXPOSE 8080
    CMD ["./main"]`,
    
          "rust": `# Build stage
    FROM rust:1.75 AS build
    WORKDIR /app
    COPY Cargo.toml Cargo.lock ./
    COPY src ./src
    RUN cargo build --release
    
    # Runtime stage
    FROM debian:bookworm-slim
    COPY --from=build /app/target/release/app /usr/local/bin/
    EXPOSE 8080
    CMD ["app"]`,
    
          "unknown": `# Could not detect project type
    # Please specify your base image and build steps
    FROM ubuntu:22.04
    WORKDIR /app
    COPY . .
    # Add your build and run commands here`
        };
    
        const dockerignores = {
          "java-maven": `target/
    *.class
    *.jar
    *.log
    .git/
    .idea/
    *.iml`,
          "java-gradle": `build/
    .gradle/
    *.class
    *.jar
    *.log
    .git/
    .idea/
    *.iml`,
          "nodejs": `node_modules/
    npm-debug.log
    .git/
    .env
    coverage/
    dist/`,
          "python": `__pycache__/
    *.pyc
    .git/
    .env
    venv/
    .venv/`,
          "golang": `.git/
    *.exe
    *.test
    *.out`,
          "rust": `target/
    .git/
    Cargo.lock`,
          "unknown": `.git/
    *.log
    .env`
        };
    
        dockerfile = dockerfiles[projectType];
        dockerignore = dockerignores[projectType];
    
        return {
          content: [{
            type: "text",
            text: `PROJECT TYPE DETECTED: ${projectType}
    
    RECOMMENDED DOCKERFILE:
    =======================
    ${dockerfile}
    
    RECOMMENDED .dockerignore:
    ==========================
    ${dockerignore}
    
    NEXT STEPS:
    1. Save Dockerfile:      Copy the above to ./Dockerfile
    2. Save .dockerignore:   Copy the above to ./.dockerignore
    3. Build image:          docker build -t myapp:latest .
    4. Run container:        docker run -p 8080:8080 myapp:latest`
          }]
        };
      }
  • Alternative/exported version of the handler function (for testing), with similar project detection but simpler single-stage Dockerfiles.
    export async function dockerAnalyzeProject({ path }) {
      const projectPath = path || ".";
      let projectType = "unknown";
    
      const checks = [
        { file: "pom.xml", type: "java-maven" },
        { file: "build.gradle", type: "java-gradle" },
        { file: "package.json", type: "nodejs" },
        { file: "requirements.txt", type: "python" },
        { file: "go.mod", type: "golang" },
        { file: "Cargo.toml", type: "rust" },
      ];
    
      for (const check of checks) {
        try {
          await access(`${projectPath}/${check.file}`, constants.F_OK);
          projectType = check.type;
          break;
        } catch {}
      }
    
      const dockerfiles = {
        "java-maven": `FROM maven:3.9-eclipse-temurin-17 AS build
    WORKDIR /app
    COPY pom.xml .
    RUN mvn dependency:go-offline
    COPY src ./src
    RUN mvn package -DskipTests
    
    FROM eclipse-temurin:17-jre-alpine
    WORKDIR /app
    COPY --from=build /app/target/*.jar app.jar
    EXPOSE 8080
    ENTRYPOINT ["java", "-jar", "app.jar"]`,
        "nodejs": `FROM node:20-alpine
    WORKDIR /app
    COPY package*.json ./
    RUN npm ci --only=production
    COPY . .
    EXPOSE 3000
    CMD ["node", "index.js"]`,
        "python": `FROM python:3.11-slim
    WORKDIR /app
    COPY requirements.txt .
    RUN pip install --no-cache-dir -r requirements.txt
    COPY . .
    EXPOSE 8000
    CMD ["python", "app.py"]`,
        "unknown": `# Could not detect project type
    FROM ubuntu:22.04
    WORKDIR /app
    COPY . .`
      };
    
      const dockerfile = dockerfiles[projectType] || dockerfiles["unknown"];
    
      return {
        content: [{
          type: "text",
          text: `PROJECT TYPE DETECTED: ${projectType}\n\nRECOMMENDED DOCKERFILE:\n=======================\n${dockerfile}`
        }]
      };
    }
  • src/tools.js:576-597 (registration)
    Exports a 'tools' object containing dockerAnalyzeProject for potential use in testing or other non-MCP contexts.
    export const tools = {
      // Git
      gitStatusExplained,
      gitBranchExplained,
      gitCommitGuided,
      // Docker
      dockerCheckSetup,
      dockerAnalyzeProject,
      dockerBuild,
      // GitHub
      githubSecretsList,
      githubSecretsSet,
      // Azure
      azureCheckCli,
      azureAcrSetup,
      azureContainerAppsDeploy,
      // SonarCloud
      sonarcloudSetupGuide,
      sonarcloudCreateConfig,
      // Onboarding
      devOnboardingCheck,
    };
Behavior2/5

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

No annotations are provided, so the description carries full burden but offers minimal behavioral insight. It mentions analysis and suggestion, implying a read-only or advisory operation, but doesn't disclose if it requires specific inputs, permissions, or has side effects like file modifications. Without annotations, this leaves key behavioral traits unclear.

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

Conciseness5/5

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

The description is extremely concise with a single, clear sentence: 'Analyze project and suggest Dockerfile.' It's front-loaded and wastes no words, making it efficient and easy to parse. Every word earns its place without redundancy.

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 tool's complexity (implied analysis task) and lack of annotations or output schema, the description is incomplete. It doesn't explain what the analysis covers, how suggestions are provided, or what the output entails. For a tool with no structured support, more context is needed to guide effective use.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage, so no parameter information is needed. The description doesn't add param details, which is appropriate, earning a baseline score of 4 as it compensates adequately for the lack of parameters by not introducing unnecessary complexity.

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

Purpose3/5

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

The description states the tool's purpose as analyzing a project and suggesting a Dockerfile, which is clear but vague. It specifies the verb 'analyze' and resource 'project' with outcome 'suggest Dockerfile', but lacks detail on what analysis entails or what makes it distinct from sibling tools like docker_build. It's not tautological but remains general.

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?

The description provides no guidance on when to use this tool versus alternatives. With siblings like docker_build and various setup/guide tools, there's no indication of context, prerequisites, or exclusions. Usage is implied only by the tool's name and description, lacking explicit when/when-not instructions.

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/rideRTD/RTD-DevOps'

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