> ## Documentation Index
> Fetch the complete documentation index at: https://schemabrain.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SchemaBrain

> The trust and intelligence layer between AI agents and your database. Read-only, PII-aware, audit-evident — by architecture, not by trust.

## Why SchemaBrain exists

You connected an AI agent to your production database. It can now read every column, including the ones it should never see. It can fabricate a `payment_card` join because nothing in the API surface says no. And when something goes wrong, the audit trail is whatever the agent decided to tell you.

SchemaBrain sits between the agent and the database and changes that contract.

## Five minutes to first query

<Steps>
  <Step title="Install">
    <CodeGroup>
      ```bash uvx theme={null}
      uvx schemabrain init
      ```

      ```bash pipx theme={null}
      pipx install schemabrain
      ```

      ```bash pip theme={null}
      pip install schemabrain
      ```

      ```bash docker theme={null}
      docker pull ghcr.io/arun-kc/schemabrain:latest
      ```
    </CodeGroup>
  </Step>

  <Step title="Initialize">
    ```bash theme={null}
    schemabrain init
    ```

    The wizard detects your installed MCP hosts (Claude Desktop, Claude Code, Cursor, Windsurf) and shows a menu — press Enter for the detected default, or pass `--host X` to skip the prompt. It spins up a local Postgres demo with a 12-table SaaS schema and writes a ready-to-use config. Press Enter at every prompt for the demo defaults.
  </Step>

  <Step title="See your schema as a graph">
    ```bash theme={null}
    pip install 'schemabrain[ui]'
    schemabrain dashboard
    ```

    The payoff: your schema rendered as an interactive **knowledge graph** — entities as nodes, joins as edges, catastrophic-PII hotspots flagged — alongside a PII matrix of every tagged column, a Refusal Explorer of every blocked query, and a hash-chained Audit Viewer. The dashboard reads the local store directly, so it works before you restart the host.
  </Step>

  <Step title="Restart the host and ask">
    Restart your MCP host so the agent picks up the new tools, then ask: *"list the entities you know about, then describe the user entity."*

    The demo ships a pre-curated entity pack, so this works **without an `ANTHROPIC_API_KEY`**. If you connected your own Postgres and skipped entity curation (no Anthropic key on hand), ask *"list the tables in my database"* instead — that uses the physical-schema tools, which need no entities.
  </Step>
</Steps>

Full walkthrough in [Setup](/setup). Want the 10-minute tour where you watch an agent get refused a query it can't answer honestly? Start with [First 5 Queries](/first-5-queries).

## Why it's safe by architecture, not by trust

<CardGroup cols={2}>
  <Card title="Read-only by architecture" icon="lock" href="/mechanism/read-only">
    No `execute()`. No `query()`. No session flag the agent can flip. Writes are impossible because no tool accepts arbitrary SQL.
  </Card>

  <Card title="PII-aware by default" icon="shield" href="/mechanism/pii-taxonomy">
    Twelve PII categories with three catastrophic-leak categories (credential, payment card, government ID) blocked out of the box.
  </Card>

  <Card title="Audit-evident" icon="signature" href="/mechanism/audit-chain">
    Hash-chained audit log. Every tool call writes a row. `audit verify` proves the chain hasn't been tampered with.
  </Card>

  <Card title="Structured recovery" icon="rotate" href="/mechanism/structured-recovery">
    When SchemaBrain refuses, it returns a typed envelope with a recovery hint — not a string error the agent has to guess at.
  </Card>
</CardGroup>

## Pick your host

Five MCP-compatible hosts ship with first-class wiring:

<CardGroup cols={3}>
  <Card title="Claude Desktop" href="/setup/claude-desktop" />

  <Card title="Claude Code" href="/setup/claude-code" />

  <Card title="Cursor" href="/setup/cursor" />

  <Card title="Windsurf" href="/setup/windsurf" />

  <Card title="ChatGPT" href="/setup/chatgpt" />
</CardGroup>

## Compare

How SchemaBrain differs from the obvious neighbours in the AI-database tooling space:

<CardGroup cols={2}>
  <Card title="vs. Querybear" href="/compare/querybear">
    Read-only SQL agent for analytics. SchemaBrain is the trust and intelligence layer between any agent and your database — definition-driven, so the agent never writes raw SQL.
  </Card>

  <Card title="vs. Anthropic Postgres MCP" href="/compare/anthropic-postgres-mcp">
    Reference MCP server with direct SQL execution. SchemaBrain refuses SQL at the type level.
  </Card>
</CardGroup>
