# Give Gemini CLI a real backend: Postgres, auth and storage

> Add Scribase to Gemini CLI as a remote MCP server in settings.json, add the rules to GEMINI.md, and let it create the database, sign-in and storage for your app.

Source: https://scribase.com/agents/gemini-cli

One `gemini mcp add` command (or four lines of settings.json) connects Gemini CLI to Scribase. From then on it can create the backend, apply tested migrations and ask before touching production.

## Connect Gemini CLI

_~/.gemini/settings.json_

```json
{
  "mcpServers": {
    "scribase": {
      "httpUrl": "https://api.scribase.com/mcp"
    }
  }
}
```

Or run `gemini mcp add --transport http scribase https://api.scribase.com/mcp` to write the same entry for you. For clients that need a header, create an agent token (it starts with scb_agt_: scoped, expiring and revocable) and keep it in the SCRIBASE_ACCESS_TOKEN environment variable, never in the repository. Never hand an agent a personal access token or a service-role key. httpUrl is the streamable-HTTP field — Gemini CLI's plain url field is SSE-only and will fail the handshake against this server.

## Project rules file: GEMINI.md

```markdown
## Scribase backend
- The backend is Scribase (Postgres, Auth, Storage, Realtime). App code uses @supabase/supabase-js with the URL and anon key that `npx scribase init` writes.
- Never ask me for keys. To sign in, run `scribase login --json`, show me the link and code, and wait for my approval.
- Schema changes are SQL files in supabase/migrations/, rehearsed on a preview branch; every new table enables row-level security with owner policies.
- Merging into production, deleting environments and rotating keys need my explicit approval for that operation.
- Never print, log or commit keys. Full rules: https://docs.scribase.com/llms.txt
```

## FAQ

**Project or user config?**

`gemini mcp add --scope project` writes .gemini/settings.json for this repository only; the default (no --scope) writes ~/.gemini/settings.json for every project.

**Can the agent break production?**

Every write tool waits for an explicit confirm, and schema_apply only accepts a token that policy_test issued for the same schema, so an unproven row-level-security policy cannot be applied. Agent tokens are scoped and expiring, and every call is audited.

**What does it cost?**

Scribase is priced per project, with no usage surprises. See the pricing page for the current prices. Every new organization is free for 14 days, no card.

**Can I leave?**

Yes. export_run produces a portable bundle (Postgres dump, auth users, storage objects) you can restore anywhere Postgres runs.