Self-hosting
Run the platform with Docker Compose: services, environment, proxies and client IPs, migrations and health checks.
You can run the whole platform on your own Docker host. This page is the short version; the full
operator guide is docs/deploy.md in the repository.
What runs
| Service | Port | Role |
|---|---|---|
web | 3000 | Dashboard, docs, hosted connect pages, and a proxy for /api/* to api |
api | 4000 | REST API for the SDK and your agents |
mcp | 4100 | Streamable HTTP MCP endpoints |
worker | Token refresh, trigger polling, webhook deliveries, usage rollups | |
migrate | Applies database migrations, then exits | |
| Postgres 16 and Redis 7 | Internal network only |
Put a TLS-terminating reverse proxy in front, with one domain each for web (for example
app.example.com), api and mcp. OAuth callbacks and incoming webhooks go to the web domain.
Build and start
The repository has one multi-target Dockerfile and a docker-compose.prod.yml:
cp .env.example .env.production # then set every value from the checklist below
chmod 600 .env.production
docker compose --env-file .env.production -f docker-compose.prod.yml build
docker compose --env-file .env.production -f docker-compose.prod.yml up -d --waitAlways pass --env-file .env.production, also for logs and run. The containers run as an
unprivileged user, the public ports are bound to 127.0.0.1 for your proxy, and no secret is
baked into an image.
Environment essentials
Generate each secret with
node -e "console.log(require('node:crypto').randomBytes(32).toString('base64'))", and the
Postgres password with openssl rand -hex 32 (hex only). Production refuses the development
values from .env.example, AUTH_REQUIRE_EMAIL_VERIFICATION=false, STRIPE_API_BASE and every
test-only override. A service with an invalid environment exits at startup and names the variable,
never its value.
| Variable | Where | Notes |
|---|---|---|
POSTGRES_PASSWORD | compose | Bundled Postgres password, hex only |
ENCRYPTION_KEY, ENCRYPTION_KEY_VERSION | api, worker, mcp | Same value everywhere. Losing it makes stored credentials unreadable. |
BETTER_AUTH_SECRET | api | Signs dashboard sessions |
PROXY_SHARED_SECRET | api, web | Same value on both, see below |
TRUSTED_PROXY_HOPS | api, mcp, web | 1 behind one proxy; web refuses to start in production with 0 |
REDIS_KEY_PREFIX | api, worker, mcp | Same value everywhere |
WEB_URL, MCP_PUBLIC_URL | api, mcp | Public URLs of web and mcp |
API_URL | web | Set by Compose to the internal api address |
NEXT_PUBLIC_APP_URL, NEXT_PUBLIC_API_URL | web (build args) | Public URLs of web and api, baked into the browser bundle |
SMTP_* | api | Email verification is required in production |
BILLING_ENABLED | api, mcp | false by default: no plans and no plan limits |
RATE_LIMIT_ENABLED, RATE_LIMIT_MULTIPLIER | api, mcp | On by default; the multiplier scales every rate limit |
AUDIT_LOG_RETENTION_DAYS | worker | Default 365 |
AI_ONBOARDING_ENABLED | api, worker | false by default: no AI workspace setup with Claude and no check-ins, see below |
AUTOMATIONS_ENABLED | api, worker, web | true by default: automations on, see below |
MCP_WORKSPACE_ENABLED | api, mcp | true by default: the AI workspace in Claude, see below |
Compose builds DATABASE_URL and REDIS_URL for the bundled Postgres and Redis itself. To use a
managed database or Redis instead, remove that service and set the URL in a Compose override.
Leave billing off unless you sell the platform yourself. With BILLING_ENABLED=true, the API also
needs STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET, STRIPE_PRICE_PRO and STRIPE_PRICE_TEAM,
and refuses to start without them. Set BILLING_ENABLED the same on api and mcp. In Stripe:
- Create two recurring prices (Pro and Team) for
STRIPE_PRICE_PROandSTRIPE_PRICE_TEAM. - Let the customer portal switch between the two prices and cancel.
- Add a webhook endpoint
https://<web domain>/api/v1/billing/stripe/webhookforcheckout.session.completedandcustomer.subscription.created,.updatedand.deleted, and set its signing secret asSTRIPE_WEBHOOK_SECRET.
See Usage and billing.
AI workspace onboarding
Setting up the AI workspace with Claude and its check-ins
are off by default. Off, the api needs no Anthropic key, every setup and check-in route answers
404, nothing is sent to Anthropic and the intake form works as before.
| Variable | Where | Notes |
|---|---|---|
AI_ONBOARDING_ENABLED | api, worker | Same value on both. true requires ANTHROPIC_API_KEY on the api |
ANTHROPIC_API_KEY | api only | Starts with sk-ant-. Never logged and never passed to another service |
AI_ONBOARDING_MODEL | api | A Claude Sonnet model by default; it must accept adaptive thinking |
AI_ORG_MONTHLY_TOKEN_BUDGET | api | Allowance units per organization per calendar month (UTC). Default 3,000,000 |
To turn it on, create a key in the Anthropic Console (ideally in a workspace for this deployment
only) and set a monthly spend limit there: that is the hard cap, the per-organization allowance
is the platform's own. Set the key and AI_ONBOARDING_ENABLED=true, then recreate api and worker
(a plain restart keeps the old environment). The api refuses to start with the flag on and no
key, and names the variable. To turn it off, set AI_ONBOARDING_ENABLED=false and recreate both;
stored drafts and check-ins expire on their own.
With it on, Anthropic processes public website text, the setup chat and check-in answers (see
What is sent to Anthropic). Name Anthropic as a
subprocessor in your privacy terms, and check its current terms for API data retention before you
turn it on for customers. The website reader honours robots.txt for the token CulturewireBot and
sends the user agent CulturewireBot/1.0 (+<your web URL>). Streamed setup responses need no proxy
change: they send X-Accel-Buffering: no and a ping every 15 seconds, so keep proxy read
timeouts at 120 seconds or more.
AI workspace in Claude
Members' personal agent links also carry the organization's AI workspace: read tools, prompts, resources and suggested updates for review. It needs no Anthropic key and sends nothing to Anthropic from the platform; Claude reads the workspace through your MCP server like any other tool result.
| Variable | Where | Notes |
|---|---|---|
MCP_WORKSPACE_ENABLED | api, mcp | Default true. Same value on both. false is the kill switch: mcp never serves the workspace and the dashboard hides In Claude and the workspace row |
WEB_URL | api, mcp | Optional on mcp: with it, a suggestion from Claude includes a link to the review inbox |
With the switch on, each organization still decides under AI workspace > Settings > Claude access (off, read only, or read and suggest updates; the default). Recreate api and mcp after changing the variable. Rendered workspaces are cached in the mcp process for up to 10 minutes and dropped as soon as the workspace changes, so no extra Redis or Postgres setup is needed.
Automations
Automations are on by default. Their steps run in the worker on a queue of their own, so a burst of runs never holds up token refreshes or trigger polling.
| Variable | Where | Notes |
|---|---|---|
AUTOMATIONS_ENABLED | api, worker, web | Default true. Set the same on all three. false is the kill switch, see below |
AUTOMATION_WORKER_CONCURRENCY | worker | Default 5 (1 to 50): steps run at once per worker process. Each step is one tool call |
AUTOMATION_STEP_RETRY_SCHEDULE | worker | Default 30,120,600: seconds between the attempts of a failed step (4 in total) |
AUTOMATIONS_ENABLED=false stops every automated action without a new deploy: every automation,
run and template route answers 404, the dashboard hides the Automations pages and menu entries,
and the worker stops running steps. Deliveries of automation triggers then fail with
automation_unavailable, and events that arrive while it is off are not run later. Automations,
versions and run history stay in the database; runs that were in flight continue when it is
turned on again, unless they are older than an hour (then they end with run_timeout). Recreate
api, worker and web after a change (a plain restart keeps the old environment).
A step mostly waits on the app's API, so memory, not CPU, limits AUTOMATION_WORKER_CONCURRENCY:
keep 5 on a small server and raise DB_POOL_MAX with it if steps wait for a database
connection. Set RATE_LIMIT_* and BILLING_ENABLED on the worker the same as on the api: they
drive the per-project run smoothing and the execution quota of automation steps. The retry
schedule takes 1 to 10 comma-separated integers from 1 to 86400; a bad value stops the worker at
startup. Only steps that can't send or create something twice are retried (see
Retries). Run history follows the trigger delivery retention
(TRIGGER_DELIVERY_RETENTION_DAYS), with no variable of its own.
Gmail and Google Calendar automations need a Google OAuth client: the managed Google app
(OAUTH_GOOGLE_CLIENT_ID and OAUTH_GOOGLE_CLIENT_SECRET, see below), or a project's own auth
config. WhatsApp needs no server setting: each project connects its own WhatsApp Business account
with a Meta system user token and phone number ID.
Managed OAuth apps
A managed OAuth app lets every organization connect a provider's apps
with one click. Since 0.19.0 any eligible OAuth app can have one, not only GitHub, Gmail, Google
Calendar, Slack, Notion and Linear: set two variables per provider and register the shared
redirect URI https://<web domain>/api/v1/connect/oauth/callback with the provider.
| Variable | Where | Notes |
|---|---|---|
OAUTH_<PREFIX>_CLIENT_ID, OAUTH_<PREFIX>_CLIENT_SECRET | api, worker, mcp | Both or neither. PREFIX is GOOGLE, MICROSOFT, ATLASSIAN or the toolkit slug in upper case |
With Compose, the variables go in their own file, .env.oauth next to docker-compose.prod.yml
(start from .env.oauth.example, mode 600, only OAUTH_* lines); only api, worker and mcp load
it. On OneDev, keep the lines in /etc/toolwire/env.production; toolwire-compose copies them
into /etc/toolwire/env.oauth for those three services. Then recreate them, without a rebuild:
toolwire-compose up -d --wait api worker mcpUpgrading from 0.18.0 with Compose: docker-compose.prod.yml no longer passes OAUTH_*
from .env.production. Move the pairs before you upgrade, or one-click connect stops and existing
managed connections fail at their next token refresh:
grep -E '^OAUTH_[A-Z0-9_]+_CLIENT_(ID|SECRET)=' .env.production > .env.oauth && chmod 600 .env.oauthOn OneDev nothing changes: the lines stay in /etc/toolwire/env.production.
A half-set pair stops the service at startup and names the variable, never the value. Owners and admins see which providers are configured under Organization settings > Managed OAuth apps. Provider-by-provider registration steps, the families and the apps that are never managed are in Managed OAuth apps.
Proxies and client IPs
Rate limits and the audit log use the client IP, so each service has to know which
X-Forwarded-For entries to trust:
TRUSTED_PROXY_HOPSis the number of proxies in front of the service that append toX-Forwarded-For:1behind one TLS proxy,0when clients connect directly. With0, the header is ignored and the socket address is used.- Dashboard traffic reaches api through web. Web forwards the browser's IP in an internal header
signed with
PROXY_SHARED_SECRET, and api trusts it only with the right secret. - Web must run behind a proxy. Next.js route handlers cannot see the socket address, so with
0web would know no browser IP and every sign-in would share one rate limit. In production web therefore exits at startup unlessTRUSTED_PROXY_HOPSis at least1. The Compose file binds web to127.0.0.1so only your proxy can reach it; setTRUSTED_PROXY_HOPS=1for web there. - Do not let the proxy strip
X-Forwarded-For, and turn off response buffering for mcp (streaming responses).
Migrations
The migrate service runs before api, worker and mcp start on every up. It is safe to run
twice: a database lock serializes parallel runs, and with nothing pending it exits at once. If it
fails, it rolls back and the apps do not start; read docker compose ... logs migrate, fix the
cause and run up again (or docker compose ... run --rm migrate). Back up Postgres before
upgrading.
Health checks
| Service | Liveness | Readiness |
|---|---|---|
| api | GET /health | GET /health/ready (DB and Redis) |
| mcp | GET /health | GET /health/ready (DB and Redis) |
| worker | GET :4401/health (internal) | same |
| web | GET /healthz | same |
Point your load balancer at the readiness paths. They answer 503 while a dependency is down.
Upgrades and scaling
- Upgrade with
git pull, then the samebuildandup -d --waitcommands. Migrations run first. Roll back by redeploying the previousIMAGE_TAGonly if no migration ran; otherwise restore the backup. - api and mcp are stateless: run more replicas behind the proxy. Rate limits, locks and idempotency state live in Redis and Postgres.
- One worker is enough; several are safe.
- Back up Postgres on a schedule and keep
ENCRYPTION_KEYwith your restore procedure, stored apart from the backups. Redis holds only queues, counters and caches.

