Repository navigation
Release v4 hardening and hosted deploy #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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))"] | ||
|
|
||
| CMD ["node", "dist/index.js", "serve-http"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| # } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an operator overrides
DOKPLOY_MCP_HTTP_PORTorDOKPLOY_MCP_HEALTH_PATHfor the image, the server listens on the configured endpoint but this exec-form healthcheck still probes127.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 👍 / 👎.