Self-hosting the engine
Run the Plotwork engine inside your own network as one container: the MCP tools for your agents and the REST drawing routes for your services, with no account and no request leaving your network. It is for platform and security teams at companies that cannot send diagram text to a hosted service.
- Docker
- Claude Code
- Cursor
- VS Code
TL;DR
| Question | Answer |
|---|---|
| What is it? | One container image with the diagram engine, MCP over Streamable HTTP at /mcp, the REST drawing routes under /v1, and /healthz. |
| Does anything leave my network? | No. The server makes no outbound request, sends no telemetry, and stores nothing. Logs go to standard output and never hold diagram text. |
| What is not in it? | Accounts, the portal, hosted diagram links, organisations, brand themes, and icon packs. Those are features of the hosted service. |
| How do I run it? | Pull plotwork/selfhost, check its signature, put it in your registry, set PLOTWORK_TOKEN, and start it with Docker, Compose, Kubernetes, or the Helm chart at oci://ghcr.io/plotwork-official/charts/plotwork-selfhost. |
| How does an agent connect? | Point the client at http://<host>:3106/mcp with the header Authorization: Bearer <token>. |
| Is it the same engine? | Yes. The tools, their schemas, and the pictures are the same as the hosted service and the npm package. |
| Is it free? | For individuals, non-commercial use, a 30 day evaluation, and organisations under 250 people and USD 10 million a year. A larger organisation needs a commercial licence, the self-hosting add-on to Enterprise. See Licence. |
What is included
| Part | Self-hosted | Hosted service |
|---|---|---|
| Every MCP tool of the local server (draw, edit, convert, import, map icons, sync Markdown, patterns, read, compare, validate, render, outline, search icons) | Yes | Yes |
| REST: validate, render, draw, edit, convert Mermaid, sync Markdown, find, get, and draw a pattern | Yes, same paths and bodies | Yes |
read_diagram and compare_diagrams with a link to a hosted picture | No: send the SVG text or the source | Yes |
A viewUrl on a drawing | No: it points at Plotwork's viewer | Yes |
| Publishing, listing, and deleting hosted diagrams | No | Yes |
| Accounts, API keys, the portal, organisations | No | Yes |
| Brand themes and icon packs | No | Yes, on plans that include them |
| Usage counting of any kind | No | Anonymous daily totals |
The REST routes take the same request bodies and answer the same shapes as the hosted API, so a client written for one works with the other after a change of base address and credential. The self-hosted server adds two answers the hosted API does not have: 503 engine.busy when every worker is busy and the queue is full, and 504 engine.timeout when a job runs past its deadline.
1. Get the image
The image is public, in two registries, with the same digest in both. Pick a version from the releases (opens in a new tab); latest follows stable releases and beta the previews, but a fixed version belongs in production.
docker pull plotwork/selfhost:<version>docker pull ghcr.io/plotwork-official/plotwork-selfhost:<version>Check what you pulled before you trust it. Every image is signed with Sigstore by the public repository's publish workflow, and carries build provenance and an SBOM:
cosign verify plotwork/selfhost:<version> \ --certificate-identity-regexp '^https://github.com/plotwork-official/plotwork-selfhost/' \ --certificate-oidc-issuer https://token.actions.githubusercontent.com
gh attestation verify oci://plotwork/selfhost:<version> --repo plotwork-official/plotwork-selfhostThen push it into your own registry, so your hosts pull it from inside your network. The examples on this page call your copy plotwork-selfhost.
| Property | Value |
|---|---|
| Images | plotwork/selfhost on Docker Hub, ghcr.io/plotwork-official/plotwork-selfhost on GitHub |
| Platforms | linux/amd64 and linux/arm64 |
| Base | Distroless Node 24, pinned by digest |
| Size | About 55 MB |
| User | 65532, not root |
| Filesystem | Runs with a read-only root filesystem; writes nothing |
| Port | 3106 |
| Health check | Built in: GET /healthz over loopback |
| Licences | The Plotwork Self-Hosted Licence, with every bundled component's licence, under /licenses in the image |
2. Run it
Make a token and keep it in your secret store:
openssl rand -hex 32Run the container with the token in its environment:
docker run -d --name plotwork \ --read-only --cap-drop ALL --security-opt no-new-privileges \ -p 127.0.0.1:3106:3106 \ -e PLOTWORK_TOKEN \ plotwork-selfhostCheck it:
curl http://127.0.0.1:3106/healthzWith Compose
This file runs the server on an internal network, which has no route out. Docker publishes no port from an internal network, so the services that call Plotwork, such as an agent gateway or a reverse proxy, join the plotwork network and reach it at http://plotwork:3106. Put PLOTWORK_TOKEN in a .env file beside it, never in the file itself.
services: plotwork: image: plotwork-selfhost restart: unless-stopped environment: PLOTWORK_TOKEN: ${PLOTWORK_TOKEN:?Set PLOTWORK_TOKEN in .env} PLOTWORK_WORKERS: '2' networks: - plotwork read_only: true cap_drop: - ALL security_opt: - no-new-privileges:true mem_limit: 1g pids_limit: 64
networks: plotwork: internal: trueWith Kubernetes
The public repository has a manifest to start from, kubernetes.yaml (opens in a new tab): a namespace, two replicas as a non-root, read-only Deployment with health probes, a Service, and a NetworkPolicy with no egress. Create the token as a Secret, never in the file:
kubectl apply -f kubernetes.yamlkubectl -n plotwork create secret generic plotwork --from-literal=token="$(openssl rand -hex 32)"Agents in the cluster reach it at http://plotwork.plotwork.svc:3106/mcp. If you write your own manifest, set enableServiceLinks: false on the pod: a Service named plotwork otherwise makes Kubernetes set PLOTWORK_PORT to tcp://<address>:3106 in every pod, over the server's own setting, and the server stops at start with a message that says so.
With Helm
A Helm chart is released with every image, at the same version, and signed the same way. It installs two non-root, read-only replicas with no Kubernetes API token, a Service, a NetworkPolicy that allows no egress at all, and a PodDisruptionBudget. It needs Kubernetes 1.25 or newer.
Create the token as a Secret first, then install a fixed version and run its test:
kubectl create namespace plotworkkubectl -n plotwork create secret generic plotwork --from-literal=token="$(openssl rand -hex 32)"
helm install plotwork oci://ghcr.io/plotwork-official/charts/plotwork-selfhost \ --version <version> --namespace plotwork \ --set auth.existingSecret=plotwork
helm test plotwork -n plotworkAgents in the cluster reach it at http://plotwork.plotwork.svc:3106/mcp. The chart refuses to render without a token, unless you set auth.allowOpen=true where the network is the control. Check the chart's signature before you install it:
cosign verify ghcr.io/plotwork-official/charts/plotwork-selfhost:<version> \ --certificate-identity-regexp '^https://github.com/plotwork-official/plotwork-selfhost/' \ --certificate-oidc-issuer https://token.actions.githubusercontent.comThe values most installs change:
| Value | Default | Use |
|---|---|---|
auth.existingSecret | none | The Secret that holds the token. Required, unless auth.allowOpen is true. |
image.repository | plotwork/selfhost | Your registry's copy of the image. |
image.digest | none | The digest you verified, so every pod runs exactly that image. |
replicaCount | 2 | Pods to run when autoscaling is off. |
autoscaling.enabled | false | Adds a HorizontalPodAutoscaler on CPU, from 2 to 6 pods. |
config.workers | 2 | Worker threads per pod. Keep it at or under the pod's CPU. |
config.tools | full | core for a model with a small context. |
license.existingSecret | none | The Secret that holds your licence key. |
resources | 250m CPU and 256Mi requested, 1Gi memory limit | Requests and limits. |
ingress.enabled | false | Adds an Ingress. Terminate TLS there or in your mesh. |
networkPolicy.ingress.namespaces | none | Namespaces, by name, whose pods may call, such as your ingress controller's or your agent gateway's. Pods in the release's namespace may always call. |
For a network with no internet access, pull the chart and the image, push both into your own registries, and set image.repository and tests.image to your copies:
helm pull oci://ghcr.io/plotwork-official/charts/plotwork-selfhost --version <version>helm push plotwork-selfhost-<version>.tgz oci://registry.example.internal/chartsThe chart's README lists every value, and its values.schema.json refuses a value it does not know, so a typo stops the install instead of being ignored. The NetworkPolicy takes effect only where the network plugin enforces policies, as Calico, Cilium, and most managed clusters do.
Both the Compose file and the manifest are run as they are, on fresh machines, for every release, and the published chart is installed on a fresh cluster and its test run; see the verify workflow (opens in a new tab).
Settings
Every setting is an environment variable. A value the server cannot use stops it at start with a message that names the variable.
| Variable | Default | Meaning |
|---|---|---|
PLOTWORK_TOKEN | none | The bearer token for /mcp and /v1, at least 32 characters. |
PLOTWORK_HOST | 0.0.0.0 in the image | The address to listen on. |
PLOTWORK_PORT | 3106 | The port to listen on. |
PLOTWORK_ALLOW_OPEN | unset | 1 serves without a token on an address other than loopback. Use it only where the network itself is the control. |
PLOTWORK_ALLOWED_ORIGINS | none | Browser origins allowed to call, separated by commas. |
PLOTWORK_WORKERS | 2 | Worker threads that run the engine. One layout uses one thread for up to a second. |
PLOTWORK_QUEUE | 32 | Jobs that may wait for a worker before more are refused. |
PLOTWORK_TIMEOUT_MS | 30000 | The deadline of one job, waiting included. |
PLOTWORK_WORKER_MEMORY_MB | 512 | The heap limit of each worker. |
PLOTWORK_MAX_BODY_BYTES | 4194304 | The largest request body. |
PLOTWORK_MCP_RESULT_LIMIT | 44000 | Characters of an MCP drawing answer before its pictures are left out, so an AI client can read it. |
PLOTWORK_TOOLS | full | core lists only the eight workflow tools on /mcp, with short descriptions, for an open model with a small context. See Use Plotwork with open and self-hosted models. Any other value stops the start. |
PLOTWORK_LICENSE | none | Your licence. /healthz shows whether one is set and a short fingerprint of it, never the value. |
Without PLOTWORK_TOKEN, the server listens on loopback only. The image listens on every address, so it does not start without a token unless PLOTWORK_ALLOW_OPEN=1 is set.
3. Connect an agent
Every client below sends the token as a bearer header. Replace plotwork.internal with the address of your server.
Claude Code
claude mcp add --transport http plotwork http://plotwork.internal:3106/mcp \ --header "Authorization: Bearer $PLOTWORK_TOKEN"Cursor
Add this to ~/.cursor/mcp.json:
{ "mcpServers": { "plotwork": { "url": "http://plotwork.internal:3106/mcp", "headers": { "Authorization": "Bearer ${env:PLOTWORK_TOKEN}" } } }}VS Code
Add this to .vscode/mcp.json. VS Code asks for the token once and keeps it out of the file:
{ "inputs": [ { "type": "promptString", "id": "plotwork-token", "description": "Plotwork token", "password": true } ], "servers": { "plotwork": { "type": "http", "url": "http://plotwork.internal:3106/mcp", "headers": { "Authorization": "Bearer ${input:plotwork-token}" } } }}A service over REST
curl -X POST http://plotwork.internal:3106/v1/diagrams/render \ -H "Authorization: Bearer $PLOTWORK_TOKEN" \ -H "content-type: application/json" \ -d '{"source": "flow \"Checkout\"\nnode web service \"Web\"\nnode db database \"Orders\"\nweb -> db"}'4. Licence
The image is free to pull. It is free to run for the uses below, under the Plotwork Self-Hosted Licence, in /licenses/LICENSE in the image:
| Who | Free? |
|---|---|
| An individual, for themselves | Yes |
| A charity, non-profit, school or research institution, for non-commercial work | Yes |
| Any organisation, evaluating it for up to 30 days, not in production | Yes |
| An organisation with fewer than 250 employees and contractors and less than USD 10 million in annual revenue, counting its affiliates, for its own work | Yes |
| Any other organisation | Needs a commercial licence |
The commercial licence is the self-hosting add-on to an Enterprise (opens in a new tab) contract, which also brings support from a named person and an uptime SLA. An organisation that grows past the free size has 90 days to license it or stop. Offering the engine to others as a hosted service needs a written agreement.
The server never stops working for want of a licence, so a network with no internet access is never broken by one. Set the key you are given as PLOTWORK_LICENSE: /healthz then shows its fingerprint, and without one the server says once at start which licence applies. The npm package and the command line are MIT, and this licence does not change them.
5. Security notes
| Topic | What the server does | What you do |
|---|---|---|
| Transport | Plain HTTP. | Put TLS in front: a reverse proxy, a service mesh, or an ingress. |
| Authentication | One static bearer token, compared in constant time. A missing or wrong token is a 401. | Keep the token in a secret store, give each environment its own, and rotate it by restarting with a new one. |
| Outbound network | Makes no request. fetch and the socket clients are switched off in the process, and a link sent to a tool is refused. | Block egress anyway, with an internal network, a network policy, or a firewall rule, so the container has no route out. |
| Browsers | Refuses a request whose Origin is not in PLOTWORK_ALLOWED_ORIGINS, which also stops a web page from reaching a server on loopback. | List only the origins of your own tools. |
| Limits | A body cap, a bounded queue, a deadline on every job, and a heap cap on each worker. A job past its deadline is stopped and its worker replaced. | Set container memory and CPU limits; about 250 MB at rest with two workers. |
| Logs | One JSON line per request and per tool call: path, status, tool, outcome, duration, and argument size. Never diagram text, a header value, or an error message. | Collect standard output with your log pipeline. |
| Storage | None. Every request is worked on in memory and forgotten. | Run with a read-only root filesystem. |
| Telemetry | None. PLOTWORK_USAGE, which turns on counting in the npm package, does nothing here. | Nothing. |
See also
| Doc | Why |
|---|---|
| MCP server | The tools, and how the local and hosted servers differ |
| Connecting an agent | Client settings for the hosted server and the npm package |
| API reference | Request and response shapes of the REST routes |
| Privacy policy | What the hosted service collects, none of which applies to a self-hosted server |
| Why Plotwork draws plain SVG | Why the pictures add no runtime dependency to the pages that show them |