Postgres DBA MCP
Bounded, read-only PostgreSQL access for assistants, with compact CSV results
Postgres DBA MCP is an open-source MCP server for databases. It runs locally on your machine and is started by your AI client.
- Pricing
- Open source
- Platforms
- CLI, macOS, Linux
- Runs
- Locally
- What it can do
- Can change data (1 tool)
- Access
- Needs a secret key or token
Similar MCP servers
Install
Add with the CLI
Run in a terminal
claude mcp add postgres-dba-mcp --env DATABASE_URI='<DATABASE_URI>' -- docker run -i --rm -e DATABASE_URI ghcr.io/a-lafon/postgres-dba-mcp:0.4.3Add --scope user to use it in every project, or --scope project to share it in .mcp.json.
Or share it with your project
Add to .mcp.json
{
"mcpServers": {
"postgres-dba-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"DATABASE_URI",
"ghcr.io/a-lafon/postgres-dba-mcp:0.4.3"
],
"env": {
"DATABASE_URI": "<DATABASE_URI>"
}
}
}
}Add to claude_desktop_config.json
{
"mcpServers": {
"postgres-dba-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"DATABASE_URI",
"ghcr.io/a-lafon/postgres-dba-mcp:0.4.3"
],
"env": {
"DATABASE_URI": "<DATABASE_URI>"
}
}
}
}Settings → Developer → Edit Config, then quit and reopen Claude Desktop.
Add to ~/.cursor/mcp.json
{
"mcpServers": {
"postgres-dba-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"DATABASE_URI",
"ghcr.io/a-lafon/postgres-dba-mcp:0.4.3"
],
"env": {
"DATABASE_URI": "<DATABASE_URI>"
}
}
}
}Use .cursor/mcp.json in a project to share it with the project.
Add to ~/.copilot/mcp-config.json
{
"mcpServers": {
"postgres-dba-mcp": {
"type": "stdio",
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"DATABASE_URI",
"ghcr.io/a-lafon/postgres-dba-mcp:0.4.3"
],
"env": {
"DATABASE_URI": "<DATABASE_URI>"
}
}
}
}Or put the same entry in .mcp.json at your workspace root to share it.
Add with the CLI
Run in a terminal
codex mcp add postgres-dba-mcp --env DATABASE_URI='<DATABASE_URI>' -- docker run -i --rm -e DATABASE_URI ghcr.io/a-lafon/postgres-dba-mcp:0.4.3Or add to config.toml
Add to ~/.codex/config.toml
[mcp_servers.postgres-dba-mcp]
command = "docker"
args = ["run", "-i", "--rm", "-e", "DATABASE_URI", "ghcr.io/a-lafon/postgres-dba-mcp:0.4.3"]
env = { DATABASE_URI = "<DATABASE_URI>" }Add to your client's MCP settings (most use this shape)
{
"mcpServers": {
"postgres-dba-mcp": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"DATABASE_URI",
"ghcr.io/a-lafon/postgres-dba-mcp:0.4.3"
],
"env": {
"DATABASE_URI": "<DATABASE_URI>"
}
}
}
}Gemini CLI and Antigravity
Gemini CLI
Add to ~/.gemini/settings.json
{ "mcpServers": { "postgres-dba-mcp": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "DATABASE_URI", "ghcr.io/a-lafon/postgres-dba-mcp:0.4.3" ], "env": { "DATABASE_URI": "<DATABASE_URI>" } } } }Or run: gemini mcp add -s user -e DATABASE_URI='<DATABASE_URI>' postgres-dba-mcp docker -- run -i --rm -e DATABASE_URI ghcr.io/a-lafon/postgres-dba-mcp:0.4.3
Antigravity
Add to ~/.gemini/config/mcp_config.json
{ "mcpServers": { "postgres-dba-mcp": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "DATABASE_URI", "ghcr.io/a-lafon/postgres-dba-mcp:0.4.3" ], "env": { "DATABASE_URI": "<DATABASE_URI>" } } } }Use .agents/mcp_config.json to add it to one workspace only.
Devin Desktop (formerly Windsurf)
Add to ~/.config/devin/mcp_config.json
{ "mcpServers": { "postgres-dba-mcp": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "DATABASE_URI", "ghcr.io/a-lafon/postgres-dba-mcp:0.4.3" ], "env": { "DATABASE_URI": "<DATABASE_URI>" } } } }On Windows the file is %APPDATA%\devin\mcp_config.json. Use .devin/mcp_config.json to share it with a project.
Cline
Add to cline_mcp_settings.json
{ "mcpServers": { "postgres-dba-mcp": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "DATABASE_URI", "ghcr.io/a-lafon/postgres-dba-mcp:0.4.3" ], "env": { "DATABASE_URI": "<DATABASE_URI>" } } } }Open it from the MCP Servers icon → Configure → Configure MCP Servers.
Zed
Add to Zed settings.json
{ "context_servers": { "postgres-dba-mcp": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "DATABASE_URI", "ghcr.io/a-lafon/postgres-dba-mcp:0.4.3" ], "env": { "DATABASE_URI": "<DATABASE_URI>" } } } }Open it with zed: open settings file. Merge context_servers into the settings you already have.
JetBrains AI Assistant and Junie
AI Assistant
Add to Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add
{ "mcpServers": { "postgres-dba-mcp": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "DATABASE_URI", "ghcr.io/a-lafon/postgres-dba-mcp:0.4.3" ], "env": { "DATABASE_URI": "<DATABASE_URI>" } } } }The AI Assistant docs only show command and args. If the env block is ignored, use Junie for this server.
Junie
Add to ~/.junie/mcp/mcp.json
{ "mcpServers": { "postgres-dba-mcp": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "DATABASE_URI", "ghcr.io/a-lafon/postgres-dba-mcp:0.4.3" ], "env": { "DATABASE_URI": "<DATABASE_URI>" } } } }Use .junie/mcp/mcp.json to share it with a project.
Kiro
Add to ~/.kiro/settings/mcp.json
{ "mcpServers": { "postgres-dba-mcp": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "DATABASE_URI", "ghcr.io/a-lafon/postgres-dba-mcp:0.4.3" ], "env": { "DATABASE_URI": "<DATABASE_URI>" } } } }Use .kiro/settings/mcp.json to add it to one workspace only.
Using several servers? Build one config file with the MCP config generator.
Configuration
DATABASE_URIPostgreSQL connection URI of the database to serveRequired
About Postgres DBA MCP
This Go server is pitched as a drop-in replacement for crystaldba/postgres-mcp 0.3.0, keeping its nine tools under the same names and parameters and adding analyze_locks. The README's complaints about the original are specific: unbounded Python-repr results that can run to hundreds of thousands of tokens, a restricted mode that could be bypassed through function calls such as pg_read_file, and a heavy container.
Results come back as compact CSV with a footer giving row count and timing, capped at 32 kB, with NULL kept distinct from an empty string and every cut announced. Restricted mode is on by default: each statement is parsed with PostgreSQL's own parser (libpg_query), every function call is checked, and the work runs in a read-only transaction. The author reports 131 of 131 attack statements refused, about 61% fewer tokens per execute_sql response, 9 MB of memory against 246 MB and a 13 ms cold start, measured on a PostgreSQL 17 database against the original, and says the tool definitions are 39% larger.
It ships as a single static binary, a Homebrew formula, an install script or a Docker image, and needs a DATABASE_URI for the database it serves. The first tool call opens the connection.
Tools this server provides (2)
Taken from the project documentation; the running server may differ.
From the tool list in its README, going by the names, 1 of 2 tools changes data.
From the server's own tool labels and tool names; not verified by us.
- execute_sqlName suggests: changes
- Run a bounded SQL statement and return compact CSV
- analyze_locksName suggests: reads
- Analyze database locks
What it does
- Capped CSV output
- Results are bounded by rows, bytes and cell length, with a footer saying what was cut.
- Parser-checked SQL
- Statements are parsed with libpg_query and every function call is checked.
- Read-only transaction
- Queries run inside a read-only transaction in the default restricted mode.
- DBA tool set
- Schema, SQL, plans with hypothetical indexes, top queries and health checks.
- Lock analysis
- analyze_locks is an extra tool beyond the original nine.
- Single static binary
- Starts in milliseconds; also available as a non-root Docker image.
Good for
- Let an assistant explore a production schema safely
- Find the slowest queries and read their plans
- Test hypothetical indexes before creating them
- Check database health from a chat
- Replace crystaldba/postgres-mcp with one config line
Pricing
Open source
Open-source project; no price listed
More servers for the same service
Postgres DBA MCP FAQ
Is Postgres DBA MCP really read-only?
In its default restricted mode, yes: statements are parsed, function calls checked and run in a read-only transaction.
How do I connect to a database?
Set DATABASE_URI in the environment or pass the URI as the first argument.
How do I install Postgres DBA MCP?
Via Homebrew, an install script, Docker, a release archive or go install.
Does Postgres DBA MCP cost anything?
The README lists no price; it is an open-source project.
How do I add Postgres DBA MCP to Claude Code?
Run this command in your terminal: claude mcp add postgres-dba-mcp --env DATABASE_URI='<DATABASE_URI>' -- docker run -i --rm -e DATABASE_URI ghcr.io/a-lafon/postgres-dba-mcp:0.4.3
What are the best alternatives to Postgres DBA MCP?
The closest alternatives to Postgres DBA MCP are Midplane, Datatomcp, Gulliver, GaussDB Read-Only MCP and Zektor.
Where this comes from
- Description: written from the project's README.
- Install steps: from the official MCP Registry entry.