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:gatewaySet 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>/callbackDesktop 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,proandpro_plusunder Organization plans, give each the featuressandboxes,tailscaleandfleet, 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_URLset tohttps://<your API host>/billingturns 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 needsCLERK_PUBLISHABLE_KEYfor the same Clerk instance asCLERK_ISSUER, and the API's own origin must not be inCLERK_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_URLthe app shows no billing buttons, and every organization has Free limits unless you set its plan withscripts/set-entitlement-override.ts. KAIROKU_BILLING_ENFORCEisoff,shadoworon.offleaves limits as they were.shadowlogs each refusal it would make and allows it.onrefuses, and locks the controls that would go past a limit.CLERK_SECRET_KEYis 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_SECRETis the signing secret of a Clerk webhook endpoint at<KAIROKU_PUBLIC_URL>/v1/webhooks/clerk. Subscribe it toorganization.deleted,organizationMembership.created,organizationMembership.deletedanduser.deleted, plussubscription.*andsubscriptionItem.*, which tell the server a plan changed. Until it is set, that endpoint answers 503.
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_FROMis the sender, for exampleKairoku <notify@mail.example.com>. It needsKAIROKU_SECRET_KEYandKAIROKU_PUBLIC_URL, which sign and build the unsubscribe links, andCLERK_SECRET_KEY, which gives the API each workspace's members and their addresses. Without them, the API sends no mail.KAIROKU_MAIL_REPLY_TOis an optional reply-to address.- Verify the sender's domain in SES, let the API call
ses:SendEmailfor 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=truelets organizations connect a tailnet and lets sandboxes join it. It needsKAIROKU_SECRET_KEYto store the tailnet secret.KAIROKU_FLEET_ENABLED=truelets organizations set up cloud sandboxes. The server won't start with it on unlessKAIROKU_FLEET_CLI_URL,KAIROKU_FLEET_CLI_SHA256,KAIROKU_FLEET_PRINCIPAL_ARN,KAIROKU_PUBLIC_URLandKAIROKU_SECRET_KEYare set.KAIROKU_FLEET_CLI_URLis the https address of a releasedkairokubinary for Linux arm64, the file itself and not an archive, with an exact version in it, neverlatest. Each cloud box downloads it.KAIROKU_FLEET_CLI_SHA256is that file's SHA-256.KAIROKU_FLEET_PRINCIPAL_ARNis the ARN of the AWS role the API runs as. Customer stacks trust that role, and the role needs permission to assumeKairokuFleetControl-*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.