Statewright

Self-Hosted

Run the full Statewright stack locally with Docker Compose

Self-Hosted

Run PocketBase, the MCP gateway, and the workflow editor locally. No cloud dependency, no external API keys. BYO Ollama.

Prerequisites

Quick Start

git clone https://github.com/statewright/statewright.git
cd statewright/self-hosted
docker compose up --build

First build takes a few minutes (Rust compilation). Subsequent starts are fast.

ServicePortDescription
Gateway:3001MCP protocol server
UI:8080Workflow editor
PocketBase:8090State persistence (SQLite) + admin UI

Connect Your Agent

Pi

pi install /path/to/statewright/plugins/pi
cd /path/to/statewright/plugins/pi && npm install
export STATEWRIGHT_GATEWAY_URL=http://localhost:3001
pi

Claude Code

claude /plugin marketplace add statewright/statewright

Then in your project's .mcp.json:

{
  "mcpServers": {
    "statewright": {
      "command": "bash",
      "args": ["path/to/plugins/claude-code/mcp-proxy.sh"],
      "env": {
        "STATEWRIGHT_GATEWAY_URL": "http://localhost:3001"
      }
    }
  }
}

Codex

codex plugin marketplace add statewright/statewright
codex plugin add statewright --marketplace statewright

Set the gateway URL in ~/.codex/config.toml:

[mcp_servers.statewright]
env_vars = ["STATEWRIGHT_GATEWAY_URL"]

Load a Workflow

From any connected agent:

> load the bugfix workflow, then fix the failing tests

The gateway ships with the bugfix workflow template. Create custom workflows through the UI at http://localhost:8080 or via MCP tools.

Add Ollama

The self-hosted stack doesn't include Ollama — bring your own. If you're using Pi with local models:

ollama serve &
pi --model ollama/gemma4:12b

Data

All state is persisted in a Docker volume (pb_data). To reset:

docker compose down -v
docker compose up --build

Private Discord Operations Feed

Production deployments can run the optional statewright-discord-ops sidecar. It receives authenticated local notifications from PocketBase and posts them to a private Discord ops channel. The application emits new-account, workflow, API-key, first-plugin-install, and first-workflow-run events. A user with no activation signal after the configured window produces one durable stalled-activation alert, with an optional email copy for the operator.

Set these deployment-only values in a secret named statewright-ops-secrets; do not commit them:

DISCORD_BOT_TOKEN=...
DISCORD_BOT_SECRET=...
DISCORD_OPS_CHANNEL_ID=...
OPS_ALERT_EMAIL=ops@example.com
SMTP_HOST=...
SMTP_PORT=587
SMTP_USERNAME=...
SMTP_PASSWORD=...
SMTP_SENDER_ADDRESS=noreply@example.com

Enable the feed with DISCORD_OPS_NOTIFICATIONS=true. Set OPS_FUNNEL_WATCH_ENABLED=true to enable stalled-activation alerts; OPS_FUNNEL_ALERT_MINUTES defaults to 30. Leave the values unset outside production to keep development and staging quiet.

On this page