# Give Codex a real backend: Postgres, auth and storage

> Add Scribase to the Codex CLI as a remote MCP server, put the backend rules in AGENTS.md, and let Codex create the database, sign-in and storage for your app.

Source: https://scribase.com/agents/codex

Add four lines to your Codex config and Codex can create a Scribase backend, apply migrations after a row-level-security test, and ask you before merging into production.

## Connect Codex

_~/.codex/config.toml_

```toml
# ~/.codex/config.toml
[mcp_servers.scribase]
url = "https://api.scribase.com/mcp"
bearer_token_env_var = "SCRIBASE_ACCESS_TOKEN"
```

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. Export it before you start Codex. Remote MCP servers need a recent Codex CLI.

## Project rules file: AGENTS.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

**Where does Codex read project rules from?**

AGENTS.md in the repository root. Put the Scribase section there so every session follows the same safe-change flow.

**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, flat, with no usage surprises. See the pricing page for the current price. Sign-up includes a $1 card check that is credited back.

**Can I leave?**

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