SchemaBrain + Windsurf
60 seconds: install SchemaBrain, run schemabrain init, restart Windsurf, ask Cascade about your database.
SchemaBrain is the trust and intelligence layer between Windsurf’s Cascade agent and your Postgres database — twelve read-only MCP tools, validated metrics, tamper-evident audit. Works on macOS, Linux, and Windows.
Install
postgresql+psycopg://... URL) or 2. Try with sample data (a 12-table SaaS fixture spins up in Docker; ~$0.03 to index). Press Enter to take the default (2).
The wizard then introspects the schema, classifies columns for PII, optionally calls Anthropic to suggest entities/metrics/joins, then writes the MCP entry to ~/.codeium/windsurf/mcp_config.json (Windsurf’s global MCP config — the Codeium namespace persists from before Windsurf split out as a standalone IDE).
Resulting config entry
mcpServers.{name} map exactly — no extra fields. The SCHEMABRAIN_DATABASE_URL env-var key is the wizard’s default, prefixed to avoid colliding with any app-level DATABASE_URL you already have in Windsurf’s env.
Restart Windsurf
Quit Windsurf fully and relaunch. The MCP config is only read on cold start.Ask Cascade
list the entities SchemaBrain knows aboutIf Cascade calls
list_entities and reports the entities curated during init, you’re done. Otherwise run schemabrain doctor --verify for an end-to-end smoke test that doesn’t require an Anthropic key.
Next: First 5 Queries walks you through exercising each load-bearing mechanism (read-only, PII refusal, audit chain, structured recovery) in ~10 minutes.
What you get
- 12 MCP tools, none of which can write. Full list in
/mechanism/read-only. - PII-aware refusal at the
get_metricboundary. Defaults blockcredential,payment_card,government_id.--pii-blockreplaces the set rather than extending it, so widen by listing the full target set, e.g.--pii-block credential,payment_card,government_id,contact,health. Details in/mechanism/pii-taxonomy. - Tamper-evident audit chain. Verify with
schemabrain audit verify. Details in/mechanism/audit-chain. - Structured recovery envelopes. Refusals ship typed contracts Cascade can act on programmatically. Details in
/mechanism/structured-recovery.
Sample interaction
You: What’s our total invoiced revenue per workspace? Cascade: (callsWhen two parallel joins exist between the same pair of entities, the response disambiguates with a structured choice:find_relevant_entities("invoiced revenue per workspace")→resolve_joinfinds the canonical join path →get_metricreturns the answer)
recovery.suggested_tool and suggested_args.name, calls resolve_join with the disambiguating canonical-join name, and continues. No guessing, no hallucinated SQL.
Troubleshooting
- Windsurf doesn’t list
schemabrainin its MCP UI — confirm~/.codeium/windsurf/mcp_config.jsonexists and contains the entry. Check the MCP status in Windsurf’s settings panel. uvxnot on PATH — install withpip install uv(orbrew install uv). Withoutuvx, the wizard falls back to the installed absolute path.postgresql://URL fails withModuleNotFoundError— usepostgresql+psycopg://.initauto-rewrites with a one-line confirmation.onnxruntimeinstall fails on Apple Silicon + Python 3.12 — downgrade to Python 3.11 or pass--no-embedto skip the embeddings layer.
docs/setup.md (wizard) · docs/setup/manual.md (manual flow, logs, troubleshooting).