Coolify MCP Server

repository·main·Indexed 19 days ago

https://github.com/stumason/coolify-mcp

An MCP server for Coolify v4 self-hosted PaaS providing 44 optimized tools for infrastructure management, deployments, diagnostics, and documentation search. It enables natural language control over servers, projects, environments, applications, databases, and services via MCP-compatible clients like Claude or Cursor. Features include destructive operation protections with human-in-the-loop elicitation and secure secret masking at the API boundary.

Tokens
16.4K
Snippets
49
Records
75
Agent score
66%

What's inside @masonator/coolify-mcp

  1. Understand the Coolify resource hierarchy and workflow

    main

    Coolify resources follow a strict hierarchy: Server → Project → Environment → (Application | Database | Service).

    Smart Lookups

    Most tools accept either a UUID or a human-friendly identifier (name, domain, or IP), so you can often skip manual UUID lookups.

    1. Orient: Use get_infrastructure_overview for a summary of everything or find_issues to scan for unhealthy resources.
    2. Diagnose: Use diagnose_app or diagnose_server to get status, logs, and history before taking action.
    3. Act: Use control (start/stop/restart), deploy, or CRUD tools (application, database, service) to make changes.
    4. Verify: Check deployment status or application_logs to ensure the resource is healthy after an action.
  2. Understand destructive operation protections

    main

    To prevent accidental damage, the server implements several safety mechanisms:

    Elicitation (Human-in-the-loop)

    On clients that support elicitation (like Claude Code and VS Code Copilot), destructive operations will pause and ask for human confirmation. The prompt will explicitly state the "blast radius" (e.g., how many apps will be taken down).

    Operations requiring confirmation:

    • stop_all_apps, redeploy_project, restart_project_apps
    • system disable_api
    • Deleting applications, databases, services, projects, or environments
    • Deleting credentials (private_keys, cloud_tokens, github_apps)
    • bulk_env_update across more than three apps

    Note on Volumes: When deleting a resource, the delete_volumes flag defaults to true in the upstream API. You must explicitly manage this if you wish to keep persistent data.

    Disabling Confirmations

    If your client claims to support elicitation but does not implement it, you can bypass the prompts by setting the environment variable: COOLIFY_MCP_ELICITATION=off

    Troubleshooting Timeouts

    If a confirmation dialog times out, it is likely due to the MCP client's request timeout (default is often 60 seconds). You may need to increase your client's MCP tool timeout to allow time for human input.

  3. Security and Secret Masking

    main

    The server is secure by default and masks sensitive information at the API boundary. A client with "list" access will see *** instead of plaintext values for secrets unless you explicitly opt-in using the reveal: true parameter.

    Masked fields include:

    • env_vars: Variable values.
    • system list_resources (full mode): Webhook HMAC secrets, basic-auth and database passwords, internal/external_db_url connection strings, compose bodies, Traefik labels, and nested env vars.
    • deployment get: Raw upstream payloads (server settings, log-drain tokens, webhook secrets) are projected to prevent leakage.

    Important for Coolify v4.2+: Coolify v4.2+ may strip sensitive fields from API responses entirely unless the token has sensitive-read scope. If reveal: true returns an empty value, ensure your API token has the necessary sensitive-read permissions.

  4. Develop and run the Coolify MCP Server locally

    main

    To develop the project, clone the repository, install dependencies, build the project, and run the tests. You can run the server locally by providing the COOLIFY_BASE_URL and COOLIFY_ACCESS_TOKEN environment variables.

    git clone https://github.com/StuMason/coolify-mcp.git
    cd coolify-mcp && npm install
    npm run build && npm test
    
    COOLIFY_BASE_URL="https://your-coolify.com" COOLIFY_ACCESS_TOKEN="token" node dist/index.js
  5. Install the Coolify MCP Server

    main

    To use the Coolify MCP server, you must have a running Coolify v4 instance and an API token (found in Coolify → Settings → API).

    Claude Desktop (One-click)

    Download the coolify-mcp.mcpb file and drag it into Settings → Extensions. You will be prompted to provide your Coolify URL and API token.

    Claude Code

    Use the claude mcp add command with the required environment variables:

    claude mcp add coolify \
      -e COOLIFY_BASE_URL="https://your-coolify-instance.com" \
      -e COOLIFY_ACCESS_TOKEN="your-api-token" \
      -- npx @masonator/coolify-mcp@latest

    Any MCP Client (JSON Configuration)

    Add the following configuration to your MCP settings file. If your Coolify instance is behind Cloudflare Access or an auth proxy, you can add repeatable --header "Key: Value" arguments to the args array.

    {
      "mcpServers": {
        "coolify": {
          "command": "npx",
          "args": ["-y", "@masonator/coolify-mcp"],
          "env": {
            "COOLIFY_BASE_URL": "https://your-coolify-instance.com",
            "COOLIFY_ACCESS_TOKEN": "your-api-token"
          }
        }
      }
    }
  6. Capabilities of the Coolify MCP Server

    main

    The Coolify MCP Server provides a set of tools categorized by functional capabilities. Instead of managing individual tool names, the server is designed around these high-level operational domains:

    • Work out what is wrong: Diagnose applications or servers, read container logs, and scan the entire estate for issues.
    • Deploy and roll back: Trigger deployments via tag or UUID, monitor deployment progress, cancel deployments, and manage the lifecycle (start, stop, restart) of resources.
    • Create and destroy: Manage the lifecycle of Applications, databases, services, projects, and environments.
    • Handle the configuration: Manage environment variables, volumes, scheduled tasks, backups, and SSH keys. Note that secrets are masked by default.
    • Move across the whole estate: Perform bulk operations across multiple apps, redeploy projects, or stop all resources simultaneously (these actions require human confirmation).
  7. Manage Services and Docker Compose

    main

    Services are multi-container stacks in Coolify. They are defined by a ServiceType (e.g., n8n, supabase, uptime-kuma) or a custom docker_compose_raw YAML string.

    Critical: Traefik Basic Auth Configuration

    When updating services that use Traefik basic auth labels, follow these steps to avoid broken authentication:

    1. Manual Step: In the Coolify UI, navigate to Service Settings > Advanced > Container Label Character Escaping and disable "Escape characters in labels". This cannot be done via API.
    2. Hash Formatting: Traefik requires double dollar signs ($$) in htpasswd hashes to prevent Docker Compose from interpreting them as variables.
      • Correct: user:$$apr1$$hash$$here
      • Incorrect: user:$apr1$hash$here

    Note: The docker_compose_raw field is automatically base64-encoded by the client; you should provide the raw YAML.

  8. Understand Coolify MCP Tool Safety and Annotations

    main

    The Coolify MCP server uses tool annotations to communicate the nature of each tool to the client. This allows clients to decide if a tool call requires human confirmation.

    Tools are categorized into several safety levels:

    • Read-only: Tools that do not modify the environment (e.g., list_servers, get_application).
    • Destructive: Tools that perform actions like delete, stop, replace, or cancel (e.g., application, database, control, deploy).
    • Non-destructive Writes: Tools that are additive and do not replace or remove existing resources (e.g., hetzner for provisioning servers).
    • Idempotent: Tools that can be re-run with the same arguments without additional side effects (e.g., validate_server).

    Note: Because tools are consolidated for efficiency, some read-only actions (like env_vars list) are grouped under destructive tool names. This means they may trigger confirmation prompts on some clients even if the specific action is a read.

  9. Understand Coolify Resource List responses

    main

    The Coolify MCP server provides two levels of detail for resources (servers, applications, databases, etc.) to manage token usage efficiently:

    1. ResourceListItem: The default response used by listResources(). It provides a lightweight summary containing the uuid, name, type, and optional status.
    2. ResourceListItemFull: A detailed response returned only when the caller passes include_full: true. This includes all additional Coolify fields such as build configurations, healthchecks, limits, git settings, and docker-compose configurations.

    Use the lightweight list for broad discovery and the full object when you need to inspect specific configuration details for a single resource.

  10. Configure and run the Coolify MCP Server

    main

    The Coolify MCP Server is executed via a Node.js environment using stdio transport. It requires specific environment variables to connect to your Coolify instance. You can also provide custom HTTP headers via command-line arguments using the parseHeaders utility (though the specific flag format is determined by the internal parse-headers.js implementation).

    Required Environment Variables

    • COOLIFY_ACCESS_TOKEN: Your Coolify API access token. This is mandatory.
    • COOLIFY_BASE_URL: The base URL of your Coolify instance (defaults to http://localhost:3000).

    Configuration Object Structure

    The server uses a CoolifyConfig object internally, which maps to these settings:

    • baseUrl: The URL of the Coolify instance.
    • accessToken: The authentication token.
    • customHeaders: An optional object of additional HTTP headers.
    # Example setup using environment variables
    export COOLIFY_BASE_URL="https://coolify.yourdomain.com"
    export COOLIFY_ACCESS_TOKEN="your_secret_token"
    
    # Run the server (assuming it is installed/linked)
    npx @masonator/coolify-mcp
  11. Initialize the CoolifyClient

    main

    To interact with the Coolify API, instantiate the CoolifyClient class. You must provide a baseUrl and an accessToken. You can also provide customHeaders, but reserved headers like authorization and content-type will be ignored to prevent conflicts with the client's internal logic.

    import { CoolifyClient } from './coolify-client';
    
    const client = new CoolifyClient({
      baseUrl: 'https://your-coolify-instance.com',
      accessToken: 'your-api-token',
      customHeaders: {
        'X-Custom-Header': 'value'
      }
    });
  12. Troubleshoot application issues with diagnose_app

    main

    If an application is failing (e.g., throwing 500s), follow this pattern:

    1. Call diagnose_app <name|domain|uuid> to see status, recent logs, env vars, and deployment history.
    2. If a recent deployment failed, call deployment with the failed deployment ID and set lines to view logs.
    3. If the issue is configuration, use env_vars (with resource: "application" and action: "update") to fix it.
    4. Trigger a redeploy using deploy.
    5. Verify health by checking deployment status or calling diagnose_app again.
    1. diagnose_app(query="my-api")
    2. deployment(action="get", id="<failed_id>", lines=50)
    3. env_vars(resource="application", action="update", ...)
    4. deploy(target="<app_id>")