scribase
MCP server

The backend an agent cannot wreck

scribase-mcp gives Claude Code, Cursor, and any MCP client 44 tools over your Scribase projects. Reads run immediately; every write waits for an explicit confirm, and schema changes must pass an RLS isolation test first.

Server
scribase-mcp
Transport
stdio, or streamable HTTP at /mcp
Control plane
https://api.scribase.com
Auth
Personal access token or org API key, audited per call

Mutations need confirm

Every tool that changes something refuses without confirm: true and returns the exact request it would send, so a human approves that specific change.

RLS is proven before it ships

schema.apply only takes a token from policy.test, which proves the isolation matrix and then breaks each guarantee on purpose to show the proof can fail.

Changes land on a preview first

Preview branches are TTL-swept copies of production with sanitized data. Merges are foreign-key safe and preceded by a backup.

Connect

Install once, then add it to your editor

Create a scoped agent token in the console under Account, Tokens. Give it only the organizations the agent should see.

Installbash
# Remote: nothing to install. Use the URL below with a personal
# access token (scb_pat_) or organization API key (sbk_).

# Local instead: build the server from the Scribase repository (Rust 1.85+)
cargo install --path crates/mcp

# Over stdio your editor starts it; `scribase-mcp serve --http :8787`
# serves the same tools remotely (needs SCRIBASE_API_URL).
# Schema tools run on a scratch Postgres the server starts itself
# (initdb, pg_ctl and psql on PATH), or on the cluster in PGHOST if set.
# Control-plane tools use SCRIBASE_API_URL and SCRIBASE_ACCESS_TOKEN.
Claude Codebash
claude mcp add --transport http scribase https://api.scribase.com/mcp \
  --header "Authorization: Bearer $SCRIBASE_ACCESS_TOKEN"
Cursor (.cursor/mcp.json)json
{
  "mcpServers": {
    "scribase": {
      "url": "https://api.scribase.com/mcp",
      "headers": {
        "Authorization": "Bearer ${env:SCRIBASE_ACCESS_TOKEN}"
      }
    }
  }
}
Tools

44 tools, grouped by what they touch

Schema and policy

Run on a scratch branch owned by the session. schema.apply only accepts a token that policy.test (or policy.simulate) issued for the exact same schema, so an unproven policy cannot be applied.

schema.proposeParse and plan a schema change without applying it.read
policy.simulateApply to a scratch branch and run the cross-user isolation matrix. Issues an apply token on pass.read
policy.testThe Aegis mutation harness: prove isolation, then break each guarantee on throwaway branches and require every break to be caught. Issues an apply token on pass.read
schema.applyApply a schema that policy.test already proved, using its token.needs confirm
sql.explainEXPLAIN a statement against the session branch.read

Branches and previews

Preview environments are TTL-swept branches of production with sanitized data.

environment.createCreate an environment, including a preview with a TTL.needs confirm
environment.listList environments in a project.read
environment.getRead one environment and its phase.read
environment.deleteDelete an environment.needs confirm
environment.suspendSuspend an environment.needs confirm
environment.resumeResume a suspended environment.needs confirm
branch.registerRegister an environment as a branch of a base.needs confirm
branch.listList branches and their lineage.read
branch.diffSchema diff between a base and a head environment.read
branch.mergeMerge a head branch into its base, foreign-key safe.needs confirm
branch.link_pull_requestLink a branch to a GitHub, GitLab, or Bitbucket pull request.needs confirm
operation.getPoll an asynchronous operation to a terminal state.read

Data and runtime

Read-only views of a live environment.

database.tablesList tables with row estimates and RLS state.read
database.queryRun a read-only SQL query.read
auth.usersList auth users (no secrets).read
storage.bucketsList storage buckets.read
functions.listList deployed functions.read
logs.tailTail recent logs.read
metrics.getRead environment metrics.read
insights.getSecurity and performance advisors.read
usage.getUsage against the plan caps.read

Migrations, backups, and portability

Every write is gated behind confirm and audited.

migrate.runPlan and lint migrations; apply only with apply and confirm.needs confirm
backup.listList backups.read
backup.getRead one backup and its verification evidence.read
backup.createTake a backup.needs confirm
backup.restoreRestore a backup into a target environment.needs confirm
import.supabaseDry-run or start a project import in the background.needs confirm
import.statusFollow a background import: phase, counts, errors, report.read
export.runProduce a portable export bundle.read

Organization and access

Membership and key management.

org.listList organizations the token can see.read
org.getRead an organization.read
org.putCreate or update an organization.needs confirm
member.putSet a member role.needs confirm
project.listList projects.read
project.getRead a project.read
project.putCreate or update a project.needs confirm
apikey.listList API keys (never their values).read
apikey.revokeRevoke an API key.needs confirm
audit.listRead the audit log.read
Claude Code skill

Preview branch, RLS tests, human confirm, merge

Drop this skill into a project and Claude Code follows the safe-change flow every time it touches your schema: it rehearses on a preview, proves isolation, shows you the diff, and waits for your approval before merging.

Install into a projectbash
mkdir -p .claude/skills/scribase-safe-change
curl -fsSL https://scribase.com/mcp/skill -o .claude/skills/scribase-safe-change/SKILL.md

Or download SKILL.md directly. It works with the CLI alone, and uses the MCP tools when the server is connected.

Moving an existing app first? See the migration guide.

.claude/skills/scribase-safe-change/SKILL.mdmd
---
name: scribase-safe-change
description: Ship a schema or row-level-security change to a Scribase project safely. Creates a preview branch, applies the migration there, proves RLS isolation with policy.test (the Aegis mutation harness), shows the diff, waits for explicit human confirmation, then merges and cleans up. Use whenever you add or change tables, columns, indexes, functions, or policies on Scribase.
---

# Scribase safe change: preview, test, confirm, merge

Never change production schema directly. Every change goes through this flow,
in order. If any step fails, stop and report; do not skip ahead.

Inputs you need: `ORG`, `PROJECT`, the project `REGION`, a short change
name `CHANGE` (for example `add-invoices`), and the migration files under
`migrations/`.
Credentials come from the environment only (`SCRIBASE_API_URL`,
`SCRIBASE_ACCESS_TOKEN`). Never print them.

## 1. Create a preview branch

A preview is a copy of production with sanitized data and a TTL, so a forgotten
preview deletes itself.

```bash
PREVIEW="preview-$CHANGE"
scribase env create "$ORG" "$PROJECT" "$PREVIEW" preview sanitized "$REGION" "$PREVIEW" 24
scribase operation get "$ORG" "$OPERATION_ID"      # repeat until state is succeeded
scribase branch register "$ORG" "$PROJECT" "$PREVIEW" --base production
```

With the MCP server: `environment.create` (kind `preview`, data mode
`sanitized`, TTL 24), then `operation.get` until it succeeds, then
`branch.register`. Both mutations need `confirm: true`; creating a
preview is safe to confirm yourself because it cannot touch production.

## 2. Apply the migration to the preview only

```bash
scribase migrate "$ORG" "$PROJECT" "$PREVIEW" --dir migrations           # plan + lint
scribase migrate "$ORG" "$PROJECT" "$PREVIEW" --dir migrations --apply   # apply to the preview
```

If the linter blocks a change (a lock-heavy ALTER, a dropped column still in
use), fix the migration. Do not force it.

## 3. Prove row level security

Every table that holds user data must have RLS enabled and policies that keep
user A out of user B's rows.

- MCP: call `policy.test` with the full schema source. It applies the
  schema to a scratch branch, runs the cross-user isolation matrix, then
  breaks each guarantee on purpose (FORCE removed, USING (true), a dropped
  WITH CHECK) on throwaway branches and requires every break to be caught.
  A pass returns an apply token; a failure lists every leak or missed mutant.
- CLI: run Aegis against the preview. `--mutate` breaks each policy on
  purpose and checks the tests notice, which proves the tests can fail.

```bash
aegis compile aegis.yaml
aegis test
aegis test --mutate
scribase insights "$ORG" "$PROJECT" "$PREVIEW"   # advisors: missing RLS, unindexed FKs
```

A single leak or a surviving mutation is a failure. Fix the policies and
return to step 2.

## 4. Show the change and wait for a human

```bash
scribase branch diff "$ORG" "$PROJECT" production "$PREVIEW"
scribase branch merge "$ORG" "$PROJECT" production "$PREVIEW" --dry-run
```

Present, in one message: the schema diff, the merge dry run, the RLS results
(simulate verdict, Aegis pass and mutation score), and any insights findings.
Then stop and ask for explicit approval to merge into production. Do not
treat silence, an earlier approval, or approval of a different change as
consent. With MCP, `branch.merge` without `confirm` returns the exact
request; show it and wait.

## 5. Merge after approval

```bash
scribase backup create "$ORG" "$PROJECT" production "pre-$CHANGE"   # restore point
scribase branch merge "$ORG" "$PROJECT" production "$PREVIEW"
```

With MCP: `backup.create` then `branch.merge` with `confirm: true`, only
after the human approved in step 4. Poll any returned operation with
`operation.get` until it reaches a terminal state. A 202 is not success.

## 6. Clean up and report

```bash
scribase env delete "$ORG" "$PROJECT" "$PREVIEW" "$PREVIEW-delete"
```

Report: the migration files applied, the RLS evidence, the backup id taken
before the merge, and the operation ids. If anything failed after the merge,
say so first and offer `scribase restore start` from the pre-merge backup.