Skip to content

Tutorial

Coolify MCP on a VPS: deploy with Claude Code, Cursor and Codex

Connecting an AI coding agent to Coolify on your VPS through MCP (Model Context Protocol) lets you create projects, manage environment variables, trigger deployments, inspect build logs and diagnose outages directly from Claude Code, Cursor or Codex without bouncing between your terminal and the web UI. In this tutorial you set up the open-source @fndchagas/coolify-mcp server (v2.3.1), compare it with Coolify's built-in /mcp endpoint and enable practical guardrails for production servers.

On this page
  1. Coolify's built-in `/mcp` endpoint vs `@fndchagas/coolify-mcp`
  2. Prerequisites
  3. Step 1: enable the API and create a Coolify token
  4. Step 2: connect Claude Code, Codex, Cursor or Claude Desktop
  5. Step 3: verify the connection in read-only mode
  6. Step 4: zero-to-production deployment workflow
  7. Step 5: diagnose failed deploys and runtime logs
  8. Production security guardrails
  9. Common setup issues and fixes
  10. Next steps

Every tool name, environment variable and command below was verified against the upstream source of frndchagas/coolify-mcp (v2.3.1, with schemas generated from the official Coolify v4.7.5 OpenAPI spec).

Coolify's built-in /mcp endpoint vs @fndchagas/coolify-mcp

There are two ways to let an AI agent operate Coolify on your VPS over MCP. Use this table to pick the right fit:

Criteria Coolify built-in /mcp endpoint @fndchagas/coolify-mcp (local stdio / HTTP MCP server)
Where it runs Inside your Coolify instance (Streamable HTTP) Locally via npx (stdio) or a dedicated HTTP process (127.0.0.1)
Initial activation Disabled by default on self-hosted (Settings > Advanced) Works over the Coolify API + token without exposing a new server endpoint
Client-side read-only lock Depends solely on the Coolify token scope Token scope plus local COOLIFY_ALLOW_WRITE=false switch
Aggregated diagnostics Individual API calls Composite tools (diagnoseApp, diagnoseServer, getInfrastructureOverview)
Documentation lookup Requires external search Bundled offline docs index (searchDocs), no network needed
Secrets and deletes Controlled by client and token Secrets masked by default plus human confirmation (elicitation) on deletes

Architecture of coolify-mcp connecting Claude Code, Cursor or Codex over MCP to the Coolify API on a VPS with secret masking and write protection

Running @fndchagas/coolify-mcp over stdio is the cleanest default for a self-hosted VPS: the MCP process starts on demand when your IDE or CLI needs it, talks only to your existing HTTPS Coolify API and never requires opening another firewall port on the server.

Prerequisites

  • A Linux VPS running Coolify behind an HTTPS domain (for example https://coolify.example.com). If you have not hardened the panel yet, start with How to install Coolify on an Ubuntu VPS safely.
  • Node.js 18 or newer on your local machine (where Claude Code, Cursor or Codex runs).
  • A Coolify API token scoped to the minimum permissions needed for your workflow.

Step 1: enable the API and create a Coolify token

In your self-hosted Coolify dashboard:

  1. Open Settings → API (or Keys & Tokens → API Tokens, depending on your panel version) and verify that the API is enabled.
  2. Create a dedicated token for your AI client (such as claude-code-prod or cursor-staging) so you can revoke it independently later.
  3. Grant least-privilege scopes:
    • Monitoring and log triage only: assign read only.
    • Routine deployments: assign read and deploy, leaving resource creation/deletion disabled while you validate the workflow.
    • Full zero-to-production provisioning: add write, and keep human confirmation enabled in your MCP client.
  4. Copy the token right away and store it in your password manager.

Step 2: connect Claude Code, Codex, Cursor or Claude Desktop

In the snippets below, replace https://coolify.example.com/api/v1 with your real Coolify API base URL (notice the /api/v1 suffix) and <your-token> with the token from Step 1.

Claude Code CLI

Register the MCP server directly from your shell:

bash
claude mcp add coolify \
  --env COOLIFY_BASE_URL="https://coolify.example.com/api/v1" \
  --env COOLIFY_TOKEN="<your-token>" \
  --env COOLIFY_ALLOW_WRITE="false" \
  -- npx -y @fndchagas/coolify-mcp

Start with COOLIFY_ALLOW_WRITE="false" to verify read access safely. Switch it to "true" once you are ready to run deployments and mutations.

OpenAI Codex CLI

From the Codex CLI:

bash
codex mcp add coolify \
  --env COOLIFY_BASE_URL="https://coolify.example.com/api/v1" \
  --env COOLIFY_TOKEN="<your-token>" \
  --env COOLIFY_ALLOW_WRITE="false" \
  -- npx -y @fndchagas/coolify-mcp

Or add it directly to ~/.codex/config.toml:

~/.codex/config.toml
[mcp_servers.coolify]
command = "npx"
args = ["-y", "@fndchagas/coolify-mcp"]
env = { COOLIFY_BASE_URL = "https://coolify.example.com/api/v1", COOLIFY_TOKEN = "<your-token>", COOLIFY_ALLOW_WRITE = "false" }

Cursor or manual JSON config (~/.mcp.json)

For clients that read standard MCP JSON config (such as Cursor, Windsurf or file-based Claude Code setups):

~/.mcp.json
{
  "mcpServers": {
    "coolify": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@fndchagas/coolify-mcp"],
      "env": {
        "COOLIFY_BASE_URL": "https://coolify.example.com/api/v1",
        "COOLIFY_TOKEN": "<your-token>",
        "COOLIFY_ALLOW_WRITE": "false"
      }
    }
  }
}

One-click install on Claude Desktop (.mcpb)

If you use Claude Desktop and want zero JSON editing, download coolify-mcp.mcpb from the latest GitHub release and drag it into Settings → Extensions. Claude Desktop prompts for your Coolify URL and token automatically.

Step 3: verify the connection in read-only mode

Open your agent and run three read-only checks first. With COOLIFY_ALLOW_WRITE=false, every write, deploy or delete call is rejected by the MCP server itself:

  1. API health check: "Call getHealth and confirm my Coolify API is reachable."
  2. One-call estate overview: "Run getInfrastructureOverview and summarize my servers, projects, applications, databases, services and running deployments."
  3. Offline docs search: "Use searchDocs to check how Coolify healthchecks are configured."

Once the overview returns your VPS, projects and apps accurately, authentication is working. Change COOLIFY_ALLOW_WRITE to "true" when you want to allow writes and deploys.

Step 4: zero-to-production deployment workflow

With writes enabled, coolify-mcp handles the full deployment lifecycle — for both Git-backed applications and Docker Compose services:

Tool sequence
1. listProjects / createProject         → pick or create a project
2. listEnvironments / createEnvironment → select the environment (e.g. production)
3. listServers                          → resolve your VPS UUID
4. createApplication or createService   → create a Git/Dockerfile app or Compose service
5. applicationEnvs (action: "upsert")   → set env vars without exposing secrets
6. deploy (wait: true)                  → trigger the build and wait for terminal status

Two Coolify v4 rules to keep in mind when prompting your agent:

  • Docker Compose deployments are services, not applications: since Coolify v4.1, Compose stacks are created through createService with docker_compose_raw, whereas createApplication covers public Git repos, private-github-app, private-deploy-key, dockerfile and dockerimage sources.
  • Synchronous deploys with failure logs: calling deploy with wait: true polls until the deployment finishes and automatically returns the failing log tail so your agent can diagnose and fix build errors in one loop.

A practical prompt in Claude Code or Cursor looks like this:

Example prompt
List my Coolify projects and servers. Create a public Git application for
https://github.com/my-org/my-api in the production environment on my VPS,
upsert NODE_ENV=production via applicationEnvs, and run deploy with wait=true.

Step 5: diagnose failed deploys and runtime logs

Day to day, the biggest time saver in coolify-mcp is fast incident triage. Instead of clicking through multiple screens to correlate container status, deployment history and logs, use two composite diagnostic tools:

  • diagnoseApp: accepts an application UUID, name or domain and aggregates current status, recent deployments, failure log tails, recent runtime logs and suggested next actions in a single call.
  • diagnoseServer: accepts a server UUID, name or IP and reports all running resources broken down by status alongside configured domains.

When a release breaks right after a push, simply ask: "Run diagnoseApp for api.example.com, identify why the last deployment failed and tell me whether the issue is in the Dockerfile or environment variables."

Production security guardrails

Giving an AI agent infrastructure access calls for concrete safety controls beyond prompt discipline. @fndchagas/coolify-mcp ships with four built-in protections:

Variable / Feature Default What it protects in practice
COOLIFY_ALLOW_WRITE true Set to false to block all creates, updates, deletes and deploys (read-only observability)
Secret masking Enabled applicationEnvs, getApplication, getDatabase, getService and getPrivateKey mask secrets unless showSecrets: true
Human confirmation (elicitation) on On compatible clients (Claude Code, VS Code Copilot), asks you to confirm before deleting a project, app, database, service, server or SSH key
Hardened HTTP transport 127.0.0.1 With MCP_TRANSPORT=http, binds loopback by default; exposing beyond loopback requires MCP_HTTP_TOKEN (Bearer auth)

If you also rely on a VPS firewall, remember that Docker-published ports bypass plain ufw rules — keep the panel and internal ports locked down as covered in Docker port still open with ufw.

Common setup issues and fixes

  • 401 or 403 on every tool call: verify the token is still active under Settings → API in Coolify and has the required permissions (read, write or deploy).
  • 404 or HTML returned instead of JSON: COOLIFY_BASE_URL is almost always missing /api/v1 at the end. Use https://coolify.example.com/api/v1, not just https://coolify.example.com.
  • Coolify version mismatch warning: on startup the server compares your Coolify version against the pinned OpenAPI spec (v4.7.5). By default this logs a harmless warning and only aborts if COOLIFY_STRICT_VERSION=true is set.
  • Delete tool fails in a specific MCP client: a few clients advertise elicitation support without implementing the confirmation prompt. If you hit that, set COOLIFY_MCP_ELICITATION=off for that client and restrict destructive scopes on the Coolify token instead.

Next steps