Sandbox
@butterbase-ai/butterbase

Backend-as-a-service with MCP tools for agents

Butterbase gives you a self-hosted backend platform with Postgres, auth, storage, functions, realtime, RAG, and an AI gateway. Its control API exposes those capabilities over REST and MCP, so agents can manage apps and data through tools instead of custom glue.

3,425 stars164 forksTypeScriptUpdated 7d ago
Who it's for

Builders who want a self-hosted backend that agents can control through REST, MCP, and CLI tools.

What it delivers

You can build and operate apps with a backend your agent can query, change, and deploy through one tool surface.

What it does

Postgres-backed app data

Per-app databases with declarative schema, automatic REST endpoints, migrations, and row-level security helpers.

Auth and API keys

Email and OAuth sign-in, JWT tuning, post-login hooks, service keys, and OAuth config.

Storage and indexing

S3 or R2-backed file storage with presigned URLs, ACLs, async indexing, and storage APIs.

Serverless functions and runtimes

TypeScript functions on Deno, plus durable objects for stateful per-key actors and long-running tasks.

AI gateway and RAG

A single endpoint for chat, embeddings, and model listing, plus managed collections and document ingestion for RAG.

MCP server and Claude Code plugin

MCP tools for the platform at `/mcp`, plus a Claude Code plugin with guided skills for app building.

How to get it

  1. 1The Claude Code plugin containing skills (packages/plugin) is a git submodule…
    git clone --recurse-submodules https://github.com/butterbase-ai/butterbase.git
    cd butterbase
  2. 2If you already cloned without submodules
    git submodule update --init --recursive
  3. 3Optional — keep submodules updated on every pull
    git config --global submodule.recurse true
  4. 4Run
    npm ci
    cp .env.example .env
  5. 5First run builds images and can take several minutes.
    docker compose -f docker-compose.local.yml up -d
  6. 6Wait until control-api is healthy
    curl -sf http://localhost:4000/health/ready

README

Butterbase

AI-native, open-source backend-as-a-service.
Postgres · Auth · Storage · Functions · AI Gateway · MCP server

License: Apache 2.0 GitHub stars GitHub forks
Join Discord Follow us on LinkedIn TypeScript Postgres Docker

Website · Discord · LinkedIn · Self-host · Docs · Roadmap · Examples · Contributing


Butterbase gives you the building blocks for AI-driven applications without lock-in: a Postgres-backed backend with row-level security, serverless functions, an LLM gateway, realtime subscriptions, key-value store, file storage, RAG, durable per-key actors, and a built-in Model Context Protocol (MCP) server so agents can operate your backend with tools instead of glue code.

Features

Data

  • Postgres data plane — per-app databases with declarative schema (/schema), automatic REST endpoints (/auto-api), and migrations.
  • Row-Level Security — first-class RLS policy management with user-isolation helpers (/rls).
  • Key-Value store — regional, quota-protected KV with TTL, audit trail, and dashboard expose rules (/v1/:app/kv/*). New in v0.2.0.
  • File storage — S3/R2-backed object storage with presigned URLs, ACLs, and async indexing (/storage).

Compute

  • Serverless functions — TypeScript functions executed on the Deno runtime (/functions).
  • Durable Objects — stateful per-key actors for chat rooms, multiplayer, rate limiters, long-running agents (/durable-objects).
  • Realtime — WebSocket subscriptions to table changes for live UIs and presence (/realtime).
  • Edge SSR — deploy Next.js / Remix / Astro edge handlers from source (/edge-ssr, /edge-ssr-from-source).
  • Frontend hosting — zip or build-from-source static / SPA deploys with custom domains (/frontend, /custom-domains).

AI

  • AI gateway — single endpoint for chat, embeddings, model listing; pluggable router adapters (/gateway, /ai-config).
  • RAG — managed collections, document ingestion, semantic search and synthesized answers (/rag).
  • Integrations — third-party tool access via Composio (/integrations).

Identity & ops

  • Auth — email + OAuth (Google, GitHub, Apple, X, …), JWT tuning, post-login hooks, service keys (/auth, /oauth-config, /api-keys).
  • Audit logs — structured request audit trail across KV and other surfaces (/audit-logs).
  • Webhooks — outbound webhooks for app events (/webhooks).
  • Multi-region app moves — relocate an app across regions with retained source replicas (scripts/move-app/).

Agent surface

  • MCP server — every capability above is exposed as MCP tools at /mcp (HTTP) or via stdio (@butterbase/mcpnpx @butterbase/mcp).
  • Claude Code pluginpackages/plugin (submodule of butterbase-skills) ships 30+ guided skills (idea → plan → schema → auth → functions → deploy → submit) for agentic app building.

Open-source vs. managed

This repo ships the runtime data plane — everything required to self-host a fully featured Butterbase instance. The managed offering at butterbase.ai adds multi-region orchestration, billing, upstream AI router adapters, lease-based quota enforcement, and ops dashboards (those live in a private repo that consumes this one as a submodule).

When you self-host, the AI gateway runs without upstream router adapters, billing uses a no-op provider, and quotas are unlimited. Wire your own implementations via the BillingProvider, QuotaEnforcer, and RouterAdapter interfaces in packages/shared.

Quickstart (self-host)

Requirements: Docker, Node 22+, npm.

1. Clone (with submodules)

The Claude Code plugin containing skills (packages/plugin) is a git submodule (butterbase-skills). A plain clone leaves packages/plugin/ empty and npm install silently skips that workspace.

git clone --recurse-submodules https://github.com/butterbase-ai/butterbase.git
cd butterbase

If you already cloned without submodules:

git submodule update --init --recursive

Optional — keep submodules updated on every pull:

git config --global submodule.recurse true

2. Install dependencies and configure env

npm ci
cp .env.example .env

docker-compose.local.yml sets KV_REDIS_URL_US_EAST_1 for you. Edit .env only if you override defaults (e.g. run control-api on the host — use redis://localhost:6379).

3. Start the stack

First run builds images and can take several minutes.

docker compose -f docker-compose.local.yml up -d

Wait until control-api is healthy:

curl -sf http://localhost:4000/health/ready

4. Run database migrations

Schema is not applied automatically on container start. From the repo root (with the stack running):

export NEON_PLATFORM_PRIMARY_URL=postgresql://butterbase:butterbase_dev@localhost:5433/butterbase_control
export NEON_RUNTIME_PROJECT_ID_US_EAST_1=postgresql://butterbase:butterbase_dev@localhost:5437/butterbase_runtime_us
export BUTTERBASE_REGIONS=us-east-1

npm run migrate:all

5. Seed the local dev user

With AUTH_ENABLED=false, the API uses DEV_OWNER_ID from compose. That user must exist in platform_users (fresh volumes start empty):

export NEON_PLATFORM_PRIMARY_URL=postgresql://butterbase:butterbase_dev@localhost:5433/butterbase_control
npm run seed:dev

6. Smoke test

Auth is disabled in the local compose profile (AUTH_ENABLED=false):

curl -X POST http://localhost:4000/init \
  -H "Content-Type: application/json" \
  -d '{"name": "my-app"}'

curl http://localhost:4000/apps

Local endpoints

ServiceURL / port
Control APIhttp://localhost:4000
MCP (HTTP, via control-api)http://localhost:4000/mcp
Deno runtimehttp://localhost:7133
Docs sitehttp://localhost:4321
Control plane Postgreslocalhost:5433
Data plane Postgreslocalhost:5435
Runtime plane Postgreslocalhost:5437
LocalStack (S3)http://localhost:4566

Full setup (auth, MCP clients, troubleshooting, production notes): SETUP.md.

Architecture

              ┌──────────────────────────────────────────┐
              │    Your app · agent · MCP client · CLI   │
              └──────────────────────┬───────────────────┘
                                     │  REST · WebSocket · MCP
              ┌──────────────────────▼───────────────────┐
              │            control-api (Fastify)         │
              │   apps · auth · schema · auto-api · RLS  │
              │   storage · functions · KV · realtime    │
              │   AI gateway · RAG · DOs · MCP at /mcp   │
              └──┬──────┬───────┬───────┬────────┬───────┘
                 │      │       │       │        │
        ┌────────▼─┐ ┌──▼───┐ ┌─▼──┐ ┌──▼─────┐ ┌▼─────────────┐
        │ Postgres │ │ S3 / │ │Redis│ │ Deno   │ │ Python agent │
        │ 3 planes │ │ R2   │ │ KV  │ │runtime │ │   runtime    │
        └──────────┘ └──────┘ └────┘ └────────┘ └──────────────┘
                                              ┌──────────────────┐
                                              │ Cloudflare:      │
                                              │ build-runner ·   │
                                              │ dispatch-worker  │
                                              └──────────────────┘

Three Postgres planes:

  • control-plane (db/control-plane/) — platform metadata: users, apps, billing, audit.
  • runtime-plane (db/runtime-plane/) — hot-path runtime tables (KV expose rules, realtime channels, sessions).
  • data-plane (db/data-plane/) — per-app user data; each app gets isolated schemas with RLS.

Repo layout

Services (services/)

ServiceLanguageWhat it does
control-apiNode.js / FastifyMain entry point. All public APIs, embeds MCP at /mcp.
mcp-serverNode.jsMCP tool implementations (built into control-api; also ships as butterbase-mcp stdio binary).
deno-runtimeDenoExecutes user serverless functions in isolates.
agent-runtimePython (uv)Long-running agent executor for manage_ai / agent tasks.
build-runnerCloudflare WorkerBuilds frontends and edge-SSR bundles from source.
storage-indexerNode.jsAsync indexer for uploaded objects.
docsAstroPublic documentation site (also served locally at :4321).

Packages (packages/)

PackageDescription
@butterbase/sdkUniversal TypeScript SDK (browser + server).
@butterbase/clibutterbase CLI for scaffolding and backend management.
@butterbase/pluginClaude Code plugin — 30+ guided skills for AI-driven app building. Git submodule of butterbase-skills.
@butterbase/sharedShared types, constants, and pluggable interfaces (BillingProvider, QuotaEnforcer, RouterAdapter).

Other top-level pieces

  • dispatch-worker/ — Cloudflare Worker that routes per-app subdomain traffic.
  • bb-placeholder/ — placeholder origin for unprovisioned subdomains.
  • infra/pgbouncer and traefik configs for self-host.
  • db/ — SQL migrations for the three Postgres planes.
  • Examples/todo-2026-04-02, grocery-list-2026-04-03.
  • templates/ — full production-shaped apps: butterSupport, butterbaseCRM.

What's not in this repo

The OSS / managed boundary is intentional. The following are private to the managed offering:

  • Multi-region orchestration and the cross-region scheduler.
  • Billing logic, lease-based quota math, and Stripe wire-up beyond the no-op provider.
  • Upstream AI router adapters (OpenAI / Anthropic / Bedrock provider integrations beyond the gateway interface).
  • Customer / admin dashboards, hackathon-host dashboards, and ops tooling.

If you need these for self-host, implement against the interfaces in packages/shared — see CONTRIBUTING.md for the scope rules.

Documentation

Project status

Latest release: v0.2.0 (2026-05-25) — adds the KV store across SDK / REST / CLI / MCP. The data plane is production-tested by the managed offering; the OSS distribution is young — please file self-host issues and we'll tighten docs and defaults from feedback. See CHANGELOG.md for the full history.

Community & support

Contributing

See CONTRIBUTING.md. The boundary between OSS and the managed offering is intentional — please read the scope section before opening a PR that touches billing, quota math, or upstream router adapters.

Security

See SECURITY.md. Report vulnerabilities to security@butterbase.ai.

License

Apache-2.0. Copyright 2026 NetGPT Inc.

Contributors

Contributors

Star history

Star History ChartStar History Chart

Files in the repo

Repository payload38 top-level entries
  • .github
  • bb-placeholder
  • dashboard-agent-template
  • db
  • dispatch-worker
  • docs
  • Examples
  • infra
  • localstack-init
  • packages
  • scripts
  • services
  • templates
  • tests
  • .dockerignore
  • .env.example
  • .env.production.example
  • .gitignore
  • .gitleaks.toml
  • .gitmodules
  • AGENTS.md
  • CHANGELOG.md
  • CONTRIBUTING.md
  • docker-compose.local.yml
  • glama.json
  • LICENSE
  • Makefile
  • package-lock.json
  • package.json
  • pnpm-lock.yaml
  • pyproject.toml
  • README.md
  • ROADMAP.md
  • SECURITY.md
  • SETUP.md
  • SKILL.md
  • tsconfig.base.json
  • vitest.e2e.config.ts

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More other

🎨 Best DeepSeek Harness Design Plugin. The open-source Claude Design alternative. 🖥️ Local-first desktop app. 🖼️ Your coding agent becomes the design engine: prototypes, landing pages, dashboards, slides, images & video — real files, HTML/PDF/PPTX/MP4 export. 🤖 Claude Code / Codex / Cursor / DeepSeek Harness / OpenCode & 20+ CLIs via BYOK.

95k
tinyhumansai/
openhuman

OpenHuman is an open source personal AI for Mac, Windows and Linux — local-first memory, agent orchestration, and deep research.

40k

Your Personal AI Assistant; easy to install, deploy on your own machine or on the cloud; supports multiple chat apps with easily extensible capabilities.

35k

😎 Awesome lists about all kinds of interesting topics [NOTE: Pull requests are temporarily disabled until I have a chance to catch up with the existing ones]

505k

AIPOCH Open-Science is an open-source, local-first, model-agnostic AI research workbench for macOS, Windows, and Linux, with scientific agents, Python/R notebooks, data connectors, and reproducible provenance.

4k