SchemaBrain — Claude Code MCP server: what it does, install
SchemaBrain gives AI agents controlled, read-only access to a Postgres schema with PII checks and an audit trail. Use it for governed data queries.
claude mcp add schemabrain -e DATABASE_URL=<DATABASE_URL> -- uvx schemabrainWhat SchemaBrain does
SchemaBrain places a controlled layer between an AI agent and a Postgres database. It exposes twelve MCP tools built around defined entities, joins, and metrics. None of them writes to the database or offers arbitrary SQL execution, so a prompt cannot directly turn into a database write.
PII labels flow from the physical schema through joins and metrics. When a request reaches a blocked category, the server refuses it before querying the database. Calls, refusals, and recovery events go into an append-only SHA256-hashed audit log; audit verify reports rewritten rows. Postgres is supported, while the local store uses SQLite. Set DATABASE_URL before connecting, or the server will not start.
What it helps with
- inspect the entities available to an agent
- calculate metrics through approved joins
- block PII access before a query runs
- record calls and refusals in an audit log
- detect rewritten audit records
Example prompts for the agent
- List the entities SchemaBrain knows about in the connected database.
- Calculate revenue by plan tier using only approved joins.
- Check this customer-data request and refuse it if it touches PII.
How to install SchemaBrain
Platform CLI
claude mcp add schemabrain -e DATABASE_URL=<DATABASE_URL> -- uvx schemabrainReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from schemabrain <command>
Platform CLI
codex mcp add schemabrain --env DATABASE_URL=<DATABASE_URL> -- uvx schemabrainReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from schemabrain <command>
Config file
{
"mcpServers": {
"schemabrain": {
"command": "uvx",
"args": [
"schemabrain"
],
"env": {
"DATABASE_URL": "<DATABASE_URL>"
}
}
}
}Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from schemabrain <command>
Config file
{
"servers": {
"schemabrain": {
"type": "stdio",
"command": "uvx",
"args": [
"schemabrain"
],
"env": {
"DATABASE_URL": "<DATABASE_URL>"
}
}
}
}Replace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from schemabrain <command>
Platform CLI
gemini mcp add -e DATABASE_URL=<DATABASE_URL> schemabrain uvx schemabrainReplace <…> with your own values. uvx runs the command named after the package; if the README names another one, use uvx --from schemabrain <command>
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about SchemaBrain
How do I install SchemaBrain in Claude Code?
Run claude mcp add schemabrain -e DATABASE_URL=<DATABASE_URL> -- uvx schemabrain. Set DATABASE_URL to the Postgres connection URL.
What does SchemaBrain do?
It gives an agent access to defined Postgres entities, joins, and metrics. PII requests are refused before the database is queried, and activity is written to an audit log.
Which databases does SchemaBrain support?
The server supports Postgres. Its local store is SQLite.