Kairoku

Self-hosting the platform

Run the Kairoku API, MCP gateway and database yourself.

Self-hosting is for development and early evaluation. Expect configuration to change before general availability.

The platform is one API server (Node.js, PostgreSQL), an MCP gateway, and the runtime you install on machines.

Requirements

  • Node.js 24.16
  • PostgreSQL 17
  • A Clerk instance for sign-in (organizations enabled)
  • A Clerk account with billing turned on and a Stripe account connected in Clerk, to sell plans (optional)
  • Amazon SES, to send email (optional)

Run it

# Migrate the database first; the command needs only its target URL.
DATABASE_URL=postgres://… npm run db:migrate

# API on 127.0.0.1:3200
npm run dev:clerk

# MCP gateway on 127.0.0.1:3300
npm run dev:gateway

Set KAIROKU_PUBLIC_URL to the address clients reach the API on. Behind a proxy, use its public https origin.

Forge connections

To let people connect GitHub or GitLab, set KAIROKU_SECRET_KEY plus KAIROKU_GITHUB_CLIENT_ID and KAIROKU_GITHUB_CLIENT_SECRET, and/or the GitLab equivalents (optionally KAIROKU_GITLAB_URL for a self-managed GitLab). Each OAuth app's callback is:

<KAIROKU_PUBLIC_URL>/v1/oauth/<github|gitlab>/callback

Desktop sign-in

The desktop app signs in with a public Clerk OAuth client using PKCE. Set the platform's KAIROKU_DESKTOP_CLIENT_ID to that client's ID.

Plans and billing

Plans are sold through Clerk Billing. The server knows Free, Solo, Pro and Pro Plus and what each includes; Clerk holds the prices and subscriptions, and charges cards through the Stripe account you connect in Clerk. You set up no Stripe keys, webhooks or products yourself.

  • In Clerk's dashboard, turn on billing for organizations and connect your Stripe account. Create the plans solo, pro and pro_plus under Organization plans, give each the features sandboxes, tailscale and fleet, and give Free none. Pro and Pro Plus are seat-based: five included seats, then a price per extra seat, up to 20. Solo has one seat. Clerk's development instance needs no Stripe account.
  • KAIROKU_BILLING_URL set to https://<your API host>/billing turns billing on. The API then serves a small page at that address, on that host only, which makes the organization in the link the active one and shows Clerk's billing screen. It needs CLERK_PUBLISHABLE_KEY for the same Clerk instance as CLERK_ISSUER, and the API's own origin must not be in CLERK_AUTHORIZED_PARTIES. With either missing, the page is off. The app's Upgrade and Manage billing buttons open it, with ?org=<organization id> added.
  • Clerk adds no tax, collects no tax id, takes no 3-D Secure cards and charges in US dollars only. It charges 0.7% of each transaction on top of Stripe's fees. Refunds are made in the Stripe dashboard.
  • Without KAIROKU_BILLING_URL the app shows no billing buttons, and every organization has Free limits unless you set its plan with scripts/set-entitlement-override.ts.
  • KAIROKU_BILLING_ENFORCE is off, shadow or on. off leaves limits as they were. shadow logs each refusal it would make and allows it. on refuses, and locks the controls that would go past a limit.
  • CLERK_SECRET_KEY is required for billing and for event email. It lets the API read members, roles and email addresses from Clerk and set each organization's member cap to its seats.
  • CLERK_WEBHOOK_SIGNING_SECRET is the signing secret of a Clerk webhook endpoint at <KAIROKU_PUBLIC_URL>/v1/webhooks/clerk. Subscribe it to organization.deleted, organizationMembership.created, organizationMembership.deleted and user.deleted, plus subscription.* and subscriptionItem.*, which tell the server a plan changed. Until it is set, that endpoint answers 503.

Email

The API sends product email through Amazon SES, in the region in AWS_REGION (us-east-1 if unset), using the AWS credentials it runs with.

  • KAIROKU_MAIL_FROM is the sender, for example Kairoku <notify@mail.example.com>. It needs KAIROKU_SECRET_KEY and KAIROKU_PUBLIC_URL, which sign and build the unsubscribe links, and CLERK_SECRET_KEY, which gives the API each workspace's members and their addresses. Without them, the API sends no mail.
  • KAIROKU_MAIL_REPLY_TO is an optional reply-to address.
  • Verify the sender's domain in SES, let the API call ses:SendEmail for it, turn on SES suppression for bounces and complaints, and move your SES account out of the sandbox before you mail real people.

Tailscale SSH and cloud sandboxes

Both are off until you switch them on.

Tailscale SSH and cloud sandboxes also need the organization's plan to include the feature, whatever KAIROKU_BILLING_ENFORCE is set to.

  • KAIROKU_TAILNET_ENABLED=true lets organizations connect a tailnet and lets sandboxes join it. It needs KAIROKU_SECRET_KEY to store the tailnet secret.
  • KAIROKU_FLEET_ENABLED=true lets organizations set up cloud sandboxes. The server won't start with it on unless KAIROKU_FLEET_CLI_URL, KAIROKU_FLEET_CLI_SHA256, KAIROKU_FLEET_PRINCIPAL_ARN, KAIROKU_PUBLIC_URL and KAIROKU_SECRET_KEY are set.
  • KAIROKU_FLEET_CLI_URL is the https address of a released kairoku binary for Linux arm64, the file itself and not an archive, with an exact version in it, never latest. Each cloud box downloads it. KAIROKU_FLEET_CLI_SHA256 is that file's SHA-256.
  • KAIROKU_FLEET_PRINCIPAL_ARN is the ARN of the AWS role the API runs as. Customer stacks trust that role, and the role needs permission to assume KairokuFleetControl-* roles in customer accounts.

Container image

The API ships as a Linux ARM64 image that runs as an unprivileged user. Run migrations from the same image by overriding the command with node server/src/db/migrate.ts, then start the API with DATABASE_URL and the Clerk configuration. Publish port 3200 only on a loopback or private listener.

On this page