Skip to content
DBA Brain
PostgreSQL MCP server

A PostgreSQL MCP server that answers like a DBA

DBA Brain MCP gives Claude and other AI agents the tools a DBA reaches for on PostgreSQL: is the cluster up and usable, what is it running now, who is blocking whom, what does this table look like, what would this query cost, did last night's backup restore. A request names a server, never a password - the login comes from the encrypted store on your machine - and the tools that only read answer without a key.

What the agent can ask

Six questions a PostgreSQL DBA answers every day

Is it up and usable?

db-status answers with a verdict - OK, WARNING or CRITICAL - at cluster, database and schema depth, instead of rows the agent has to judge. list-objects says what exists - databases, schemas - and its jobs read pg_cron where it is installed.

What is it running now?

db-activity lists the queries running now, the blocking - who holds the lock and who waits on it - and the waits. Its top queries come from pg_stat_statements; without the extension it says so instead of guessing.

What does this table look like?

table-info gives the columns, the indexes - keys, included columns, partial-index filters - the row count and the space taken; object-source the definition of a function, procedure, view or trigger. The agent reads them before it writes a query.

What would this query cost?

query-plan returns EXPLAIN without ANALYZE - the plan is made, the statement never runs: a pg_sleep(8) came back in 0.2 s. A second statement after the one asked about is refused.

Run this SELECT

run-sql runs one SELECT and always rolls back; run-sql-write keeps a change only with commit. Both run with the rights of the role your machine stores, so they are marked destructive: give the machine a role that can only read.

Did the backup restore?

store-query reads DBA Brain's own catalog: each base backup and WAL segment with its SHA-256, and each scheduled restore drill - when it ran, how far it got, and which databases passed its checks. How the drills work.

Why it is safe to hand an agent

The agent names a server; your machine does the rest

No password in the context

A request names a server_id, and your machine fills the login from its encrypted store. A request carrying a password, a key or a token is refused, and every answer is redacted.

Changes ask first

A tool that changes something - run-sql-write, a backup - is marked destructive, needs a dbabrain key and asks for its own confirmation. The tools that only read answer without a key.

A record of every call

Your machine records each call - the tool, the server, who asked - in its own store, beside the metrics, backups and job runs the agent can read without collecting them again.

Set it up

Install, name your clusters, add it to your agent

The MCP server runs on your machine and talks to the agent over stdin and stdout - nothing from DBA Brain goes on the network. claude.ai on the web or a phone reaches it through the connector instead (every step).

shell
pip install "dbabrain[postgres,mcp]"
dbabrain init
claude mcp add dbabrain --env DBABRAIN_HOME=D:/dbabrain -- dbabrain mcp serve

Between the second and the third line, your PostgreSQL clusters go into data/db_instances.json and their logins into the encrypted store: the MCP setup, and everything else DBA Brain does.

FAQ

Questions asked first

Does it install anything on the PostgreSQL server?

No agent and no extension. DBA Brain runs on a machine of its own and connects with the role you give it; the tools that read run plain queries against the system catalogs and statistics views. pg_stat_statements is used where you already have it.

Which AI clients does it work with?

Claude Code, Claude Desktop and any client that speaks MCP start dbabrain mcp serve on the same machine. claude.ai on the web or a phone uses the connector at mcp.dbabrain.dev, linked from your machine with dbabrain mcp connect.

Does it work beyond PostgreSQL?

The same tools answer for SQL Server (SQL Server MCP server), Oracle (Oracle MCP server) and MySQL, each with its own SQL. All 94 tools.

Can someone set it up for us?

Yes - setting up DBA Brain on your servers, and PostgreSQL work in general, are among the DBA work we do: see what we do.