Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
dist
coverage
.old
*.tgz
.git
plans
.env
.env.*
!.env.example
32 changes: 32 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Dokploy credentials
DOKPLOY_URL=https://panel.example.com
DOKPLOY_API_KEY=
DOKPLOY_TIMEOUT=30000
DOKPLOY_PROFILES_JSON=

# Server mode and capabilities
DOKPLOY_MCP_TRANSPORT=stdio
DOKPLOY_MCP_MODE=codemode
DOKPLOY_ENABLED_TAGS=
DOKPLOY_MCP_CAPABILITIES=
DOKPLOY_MCP_GATEWAY_RETRIES=2

# Hosted HTTP transport
DOKPLOY_MCP_HTTP_HOST=127.0.0.1
DOKPLOY_MCP_HTTP_PORT=3000
DOKPLOY_MCP_HTTP_PATH=/mcp
DOKPLOY_MCP_HEALTH_PATH=/health
DOKPLOY_MCP_ALLOWED_ORIGINS=
DOKPLOY_MCP_HTTP_ALLOW_CONFIG_FALLBACK=false

# Sandbox runtime and limits
DOKPLOY_MCP_SANDBOX_RUNTIME=subprocess
DOKPLOY_MCP_SANDBOX_TIMEOUT_MS=3000
DOKPLOY_MCP_SANDBOX_MAX_CALLS=40
DOKPLOY_MCP_SANDBOX_MAX_RESULT_BYTES=1048576
DOKPLOY_MCP_SANDBOX_MAX_RESPONSE_BYTES=1048576
DOKPLOY_MCP_SANDBOX_MAX_LOG_BYTES=65536
DOKPLOY_MCP_SANDBOX_MAX_HEAP_DELTA_BYTES=16777216
DOKPLOY_MCP_SANDBOX_MAX_CONCURRENT=4
DOKPLOY_MCP_SANDBOX_WORKER_MEMORY_MB=256
DOKPLOY_MCP_SANDBOX_WORKER_PATH=
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ jobs:

- run: npm ci

- name: Build test artifacts
run: npm run build

- name: Test with coverage
run: npm run test:coverage

Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/openapi-drift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: OpenAPI Drift

on:
schedule:
- cron: '0 6 * * 1'
workflow_dispatch:

permissions:
contents: read

jobs:
check-openapi-drift:
name: Check OpenAPI drift
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: actions/setup-node@v6
with:
node-version: '24'

- name: Check OpenAPI drift
run: |
set +e
node scripts/v2/check-openapi-drift.mjs
code=$?
if [ "$code" -eq 2 ]; then
echo "::warning::OpenAPI drift check could not complete (network/local error, exit 2) — not confirmed drift."
elif [ "$code" -ne 0 ]; then
echo "::error::OpenAPI drift detected against the vendored snapshot (exit $code)."
fi
exit $code
3 changes: 3 additions & 0 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ jobs:
- name: Lint
run: npm run lint

- name: Build test artifacts
run: npm run build

- name: Test with coverage
run: npm run test:coverage

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
- name: Lint
run: npm run lint

- name: Build test artifacts
run: npm run build

- name: Test
run: npm test

Expand Down
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

## What this is

MCP (Model Context Protocol) server for the Dokploy API. v2 is Code Mode only: two public tools, `search` and `execute`, backed by generated OpenAPI artifacts, a sandboxed runtime, and a generated Dokploy SDK. TypeScript, ES modules, Node >= 24.
MCP (Model Context Protocol) server for the Dokploy API. v2 is Code Mode only: three public tools: `search`, `execute`, and `list_profiles`, backed by generated OpenAPI artifacts, a sandboxed runtime, and a generated Dokploy SDK. TypeScript, ES modules, Node >= 24.

## Architecture

- Entry: `src/index.ts` (CLI vs MCP server)
- Server: `src/server.ts` (registers Code Mode tools with `McpServer`)
- Public tools: `src/codemode/tools/search.ts`, `src/codemode/tools/execute.ts`
- Public tools: `src/codemode/tools/search.ts`, `src/codemode/tools/execute.ts`, `src/codemode/tools/list-profiles.ts`
- Tool factory: `src/mcp/tool-factory.ts`
- Search context: `src/codemode/context/search-context.ts`
- Execute context: `src/codemode/context/execute-context.ts`
Expand All @@ -32,7 +32,7 @@ MCP (Model Context Protocol) server for the Dokploy API. v2 is Code Mode only: t

- Framework: Vitest
- Tests in `tests/*.test.ts`
- Coverage: v8 provider, excludes `src/index.ts` and `src/cli/**`
- Coverage: v8 provider, excludes entry shims `src/index.ts`, `src/cli/index.ts`, and generated code
- Run: `npm test` or `npm run test:coverage`

## Commands
Expand Down
61 changes: 7 additions & 54 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,9 @@
# CLAUDE.md -- project context for AI code review
# CLAUDE.md

## What this is
Read [AGENTS.md](./AGENTS.md) -- it is the single source of truth for project context,
architecture, code style, testing, and review guidelines. Everything there applies to Claude Code
sessions in this repo.

MCP (Model Context Protocol) server for the Dokploy API. 23 modules, 196 tools, full endpoint coverage. TypeScript, ES modules, Node >= 22.

## Architecture

- Entry: `src/index.ts` (routes CLI vs MCP server)
- Server: `src/server.ts` (registers all tools with McpServer)
- Tools: `src/tools/{module}.ts` -- each module exports tools via factory
- Factory: `src/tools/_factory.ts` (shared tool builder)
- Database helpers: `src/tools/_database.ts` (shared across postgres, mysql, mariadb, mongo, redis)
- Config: `src/config/resolver.ts` (env vars > config file > Dokploy CLI config)
- CLI: `src/cli/setup.ts` (interactive wizard using @clack/prompts)

## Code style

- Formatter/linter: Biome (not ESLint/Prettier)
- Single quotes, no semicolons, trailing commas, 2-space indent, 100 char line width
- `kebab-case` filenames (enforced by Biome)
- `useConst`, `useTemplate`, `useImportType`, `useExportType` -- all enforced
- No `forEach` -- use `for...of` or `.map()`
- No enums -- use const objects or union types
- Max cognitive complexity: 20

## Testing

- Framework: Vitest
- Tests in `tests/*.test.ts`
- Coverage: v8 provider, excludes `src/index.ts` and `src/cli/**`
- Run: `npm test` or `npm run test:coverage`

## Commands

```
npm run build # tsc
npm run typecheck # tsc --noEmit
npm run lint # biome check .
npm run lint:fix # biome check --write .
npm test # vitest run
npm run test:coverage # vitest run --coverage
```

## Dependencies

- Runtime: `@modelcontextprotocol/sdk`, `zod` (v4), `@clack/prompts`
- Dev: `@biomejs/biome`, `vitest`, `typescript`

## Review guidelines

- Watch for unused imports/variables (Biome catches these, but still)
- API client calls must go through `src/api/client.ts` -- no raw fetch
- Tool definitions follow the factory pattern -- don't create one-off tool registrations
- No `any` unless truly unavoidable (warn, don't block)
- Security: no hardcoded credentials, no secrets in code, no command injection
Quick orientation: this is the Dokploy MCP server, v2 "Code Mode" -- three public MCP tools
(`search`, `execute`, `list_profiles`) over 500+ generated Dokploy procedures, with a sandboxed
runtime for model-written code. TypeScript, ES modules, Node >= 24, Biome, Vitest.
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM node:24-slim AS build

WORKDIR /app

COPY package.json package-lock.json ./
RUN npm ci

COPY . .
RUN npm run build
RUN npm prune --omit=dev

FROM node:24-slim AS run

WORKDIR /app

ENV NODE_ENV=production
ENV DOKPLOY_MCP_TRANSPORT=http
ENV DOKPLOY_MCP_HTTP_HOST=0.0.0.0
ENV DOKPLOY_MCP_HTTP_PORT=3000
ENV DOKPLOY_MCP_HTTP_PATH=/mcp
ENV DOKPLOY_MCP_HEALTH_PATH=/health

COPY --from=build --chown=node:node /app/dist ./dist
COPY --from=build --chown=node:node /app/node_modules ./node_modules
COPY --from=build --chown=node:node /app/package.json ./package.json
COPY --from=build --chown=node:node /app/server.json ./server.json

USER node
EXPOSE 3000

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 CMD ["node", "-e", "fetch('http://127.0.0.1:3000/health').then((r)=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor configured healthcheck endpoint

When an operator overrides DOKPLOY_MCP_HTTP_PORT or DOKPLOY_MCP_HEALTH_PATH for the image, the server listens on the configured endpoint but this exec-form healthcheck still probes 127.0.0.1:3000/health, so otherwise healthy containers are marked unhealthy. Use a shell-form check or small script that reads the same env vars as the server.

Useful? React with 👍 / 👎.


CMD ["node", "dist/index.js", "serve-http"]
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Need proof instead of a sales monologue? Start with [docs/live-e2e-proof.md](./d
<!-- docs-facts:readme:start -->
## Current Fact Snapshot

- Generated API procedures in the pinned catalog: `524`
- Generated tags: `48`
- Generated API procedures in the pinned catalog: `544`
- Generated tags: `50`
- Default public MCP tools: `3` (`search`, `execute`, `list_profiles`)
- Default `tools/list` footprint from the current budget check: about `1,681` tokens (`6,723` bytes)
- Reduction versus the classic endpoint-per-tool baseline (`92,354` tokens): `98.2%`
Expand All @@ -42,6 +42,8 @@ Need proof instead of a sales monologue? Start with [docs/live-e2e-proof.md](./d

Get your API key from **Dokploy Settings > Profile > API/CLI**.

For env-based setup, start from [`.env.example`](./.env.example).

If your client uses a JSON-style MCP config, this is the whole block:

```json
Expand Down Expand Up @@ -148,6 +150,7 @@ working shape.
- [docs/guides/modes.md](./docs/guides/modes.md)
- [docs/guides/compose.md](./docs/guides/compose.md)
- [docs/guides/hosted-http.md](./docs/guides/hosted-http.md)
- [docs/guides/hosted-deploy.md](./docs/guides/hosted-deploy.md)
- [docs/guides/troubleshooting.md](./docs/guides/troubleshooting.md)
- [docs/live-e2e-proof.md](./docs/live-e2e-proof.md)

Expand Down
4 changes: 2 additions & 2 deletions docs/coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Run `npm run docs:sync:facts` after changing generated artifacts or budget-sensi
<!-- docs-facts:coverage-summary:start -->
## Summary

- Generated procedures in the pinned snapshot-backed catalog: `524`
- Generated tags: `48`
- Generated procedures in the pinned snapshot-backed catalog: `544`
- Generated tags: `50`
- Default public MCP tools: `3`
- Public tool surface: `search`, `execute`, `list_profiles`
- Default `tools/list` footprint from the current budget check: about `1,681` tokens (`6,723` bytes)
Expand Down
38 changes: 38 additions & 0 deletions docs/examples/compose.hosted.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
services:
dokploy-mcp:
build:
context: ../..
dockerfile: Dockerfile
restart: unless-stopped
environment:
DOKPLOY_MCP_TRANSPORT: http
DOKPLOY_MCP_HTTP_HOST: 0.0.0.0
DOKPLOY_MCP_HTTP_PORT: 3000
DOKPLOY_MCP_HTTP_PATH: /mcp
DOKPLOY_MCP_HEALTH_PATH: /health
# Leave empty unless a browser-based client needs CORS. Prefer explicit origins, not "*".
DOKPLOY_MCP_ALLOWED_ORIGINS: ""
DOKPLOY_MCP_SANDBOX_WORKER_MEMORY_MB: 256
DOKPLOY_MCP_SANDBOX_MAX_CONCURRENT: 4
# Do not set DOKPLOY_MCP_HTTP_ALLOW_CONFIG_FALLBACK for multi-client hosted servers.
# Per-request X-Dokploy-Url and X-Dokploy-Api-Key headers keep tenant credentials isolated.
ports:
- "3000:3000"
healthcheck:
test:
[
"CMD",
"node",
"-e",
"fetch('http://127.0.0.1:3000/health').then((r)=>{if(!r.ok)process.exit(1)}).catch(()=>process.exit(1))",
]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s

# Put TLS in front of this service. Example Caddyfile:
#
# mcp.example.com {
# reverse_proxy dokploy-mcp:3000
# }
70 changes: 70 additions & 0 deletions docs/guides/hosted-deploy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Hosted Deploy

Run hosted HTTP when a central MCP server should serve multiple clients. Keep TLS at a reverse
proxy. Do not bake Dokploy credentials into the container.

## Build

```bash
docker build -t dokploy-mcp-http .
docker run --rm -p 8787:3000 dokploy-mcp-http
```

The image binds `DOKPLOY_MCP_HTTP_HOST=0.0.0.0` because containers need a non-loopback listener.
Expose it only behind a proxy.

Health:

```bash
curl -fsS http://localhost:8787/health
```

MCP endpoint smoke:

```bash
curl -sS -i -X POST http://localhost:8787/mcp \
-H 'content-type: application/json' \
-H 'accept: application/json, text/event-stream' \
--data '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'
```

Without `X-Dokploy-Url` and `X-Dokploy-Api-Key`, protected MCP requests fail closed. That proves the
endpoint answers without sharing a default identity.

## Compose

```bash
docker compose -f docs/examples/compose.hosted.yml up -d --build
docker compose -f docs/examples/compose.hosted.yml ps
```

The example leaves `DOKPLOY_MCP_HTTP_ALLOW_CONFIG_FALLBACK` unset. Multi-client hosted servers should
use per-request credentials, not local config fallback.

## Client Contract

The MCP registry metadata in `server.json` advertises the hosted remote as:

- URL: `https://{remoteHost}{mcpPath}`
- default path: `/mcp`
- required headers: `X-Dokploy-Url`, `X-Dokploy-Api-Key`

Send the Dokploy panel URL and API key with each request. Do not put them in the image or compose
file.

## Security Posture

- terminate TLS at Caddy, Traefik, or another reverse proxy
- keep `DOKPLOY_MCP_HTTP_ALLOW_CONFIG_FALLBACK` off for shared servers
- set `DOKPLOY_MCP_ALLOWED_ORIGINS` only for browser clients, and prefer explicit origins
- tune `DOKPLOY_MCP_SANDBOX_WORKER_MEMORY_MB` and `DOKPLOY_MCP_SANDBOX_MAX_CONCURRENT` with host
CPU and memory in mind
- leave `DOKPLOY_MCP_SANDBOX_WORKER_REUSE` unset for hosted or multi-tenant deployments

## Smoke Checklist

1. `curl -fsS http://localhost:8787/health` returns JSON.
2. unauthenticated `/mcp` POST returns a JSON-RPC error, not a network failure.
3. an MCP client can initialize and call `tools/list` with `X-Dokploy-Url` and
`X-Dokploy-Api-Key`.
4. logs show `Dokploy MCP HTTP server listening at`.
2 changes: 2 additions & 0 deletions docs/guides/hosted-http.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ You want it when:
npx @vibetools/dokploy-mcp serve-http
```

For Docker and compose deployment, see [hosted-deploy.md](./hosted-deploy.md).

Defaults:

- MCP path: `/mcp`
Expand Down
Loading
Loading