PostgreSQL MCP server
io.github.antonorlov/mcp-postgres-server·v0.3.1·23 starsMCP server for PostgreSQL: local, Docker, RDS, Neon, Supabase, or behind an SSH bastion.
23 stars1.2k downloads/wk
Reviews
Write oneNobody has reviewed PostgreSQL yet.
If you have run it, two minutes of your experience saves the next person an afternoon.
PostgreSQL tools (6, 1 write)
write = sends, deletes, buys or postsRead from the package source without running it. The installed server may list more.
connect_dbSwitch the server to a different PostgreSQL database at runtime, replacing the current connection.
describe_tableShow the structure of one table: column names, data types, nullability, defaults, and primary-key membership. Call this before writing non-trivial queries against a table.
executewrite actionlist_schemasList every schema in the connected database. Start here when exploring an unfamiliar database, then call list_tables for the schema you care about.
list_tablesList all tables in a schema (default: 'public'). Use this before querying tables you have not seen yet, then call describe_table for column details.
query
Public scan report
scanner v0.1.10 · 2026-10-03 · same rubric, same numbers if you re-run it
- Code scan4 source files scanned25/25
- –Live reliabilityno gateway calls yet and no remote to proben/a
- –Tool poisoningtools not inspected (local package is not executed); not countedn/a
- Auth qualitystatic API keys via environment variables6/15
- Maintenancelast push 17 days ago15/15
- Maintainer identityregistry namespace matches repository owner; GitHub account older than a year8/10
How PostgreSQL compares
Against every graded Databases MCP server, from our own scans and uptime checks. Updated after each scan run.
- Safety score
- 83/100
- higher than 60% of 802 Databases servers
- Tools
- 6
- the typical Databases server has 8
- Tools that change things
- 17%
- typical: 10%. Fewer write tools means less an agent can break
- GitHub stars
- 23
- more than 85% of 602 Databases servers
- Downloads a week
- 1,206
- more than 91% of 328 Databases servers with a package
What its tools let an agent do: 5 read · 1 run or deploy
Install PostgreSQL in Claude Code, Cursor or VS Code
Runs npx -y mcp-postgres-server on your machine. Read the scan report first; the gateway never runs local packages.
claude mcp add mcp-postgres-server -- npx -y mcp-postgres-server
What the publisher says
From the PostgreSQL repository's README, as published. We do not edit it. Read it on GitHub
MCP PostgreSQL Server
A Model Context Protocol (MCP) server for PostgreSQL: local, Docker, RDS, Neon, and Supabase databases.
The server is small and auditable, with four runtime dependencies: the MCP SDK, pg, pg-connection-string, and zod (plus ssh2, an optional dependency used only for SSH tunneling).
Requires Node.js 20 or newer.
Quick start
The preferred way to configure the server is a single DATABASE_URL:
{
"mcpServers": {
"postgres": {
"type": "stdio",
"command": "npx",
"args": ["-y", "mcp-postgres-server"],
"env": {
"DATABASE_URL": "postgres://user:password@localhost:5432/mydb",
"PG_ALLOW_WRITE": "false"
}
}
}
}With PGALLOWWRITE set to "false" the server has read-only access to the database. This is the default; set it to "true" only if the model must write.
The same JSON works in any MCP client that speaks stdio: VS Code, Cursor, Claude Code, Codex, Windsurf.
Alternatively, set the individual PG variables; they are used when DATABASEURL is not set:
{
"mcpServers": {
"postgres": {
"type": "stdio",
"command": "npx",
"args": ["-y", "mcp-postgres-server"],
"env": {
"PG_HOST": "your_host",
"PG_PORT": "5432",
"PG_USER": "your_user",
"PG_PASSWORD": "your_password",
"PG_DATABASE": "your_database",
"PG_ALLOW_WRITE": "false"
}
}
}
}Manual Installation
npm install mcp-postgres-serverOr run directly with:
npx mcp-postgres-serverConnect to your database
Local Postgres:
DATABASE_URL=postgres://mcp_readonly:secret@localhost:5432/mydbPostgres in Docker: if the database runs in a container with a published port, connect to localhost: as usual. If the MCP server itself runs inside a container and the database runs on your host machine, use host.docker.internal instead of localhost:
DATABASE_URL=postgres://mcp_readonly:secret@host.docker.internal:5432/mydbAmazon RDS:
DATABASE_URL=postgres://mcp_readonly:secret@mydb.xxxxxx.us-east-1.rds.amazonaws.com:5432/mydb?sslmode=requireNeon:
DATABASE_URL=postgres://mcp_readonly:secret@ep-xxx-xxx.us-east-2.aws.neon.tech/mydb?sslmode=requireSupabase:
DATABASE_URL=postgres://postgres.xxxxxxxx:secret@aws-0-us-east-1.pooler.supabase.com:5432/postgres?sslmode=requireTools
Tool availability depends on configuration:
1. query
Execute a read-only SQL statement. Accepts SELECT, WITH ... SELECT, EXPLAIN, and SHOW. One statement per call - multi-statement input is rejected by the extended query protocol. In read-only mode (the default) the statement runs as BEGIN READ ONLY, the query, and ROLLBACK - three commands, roughly two network round trips with pipelining - so the database itself refuses any write. With PGALLOWWRITE=true the statement is sent directly, without that wrapper, so a write run through query would execute - use execute for writes. Supports PostgreSQL-style $1, $2 prepared-statement parameters; values are bound by the driver and never spliced into the SQL text.
use_mcp_tool({
server_name: "postgres",
tool_name: "query",
arguments: {
sql: "SELECT * FROM users WHERE id = $1",
params: [1]
}
});Shortened. The full README is on GitHub.
Nothing above is checked by us. What we check is on the safety report.
PostgreSQL: common questions
- Is PostgreSQL MCP server safe?
- Mostly: it is graded B (83/100). Read the PostgreSQL safety report
- How do I install PostgreSQL?
- It runs on your machine. Copy the Claude Code, Cursor, VS Code or Claude Desktop config from the install section.
- Does PostgreSQL need an API key?
- Yes. The registry entry asks for
DATABASE_URL,PG_PASSWORD,PG_SSH_PASSPHRASE,PG_SSH_PASSWORD. - Is PostgreSQL maintained?
- The last commit was 49 days ago (2026-09-16). The latest release is v0.3.1.
- What can I use instead of PostgreSQL?
- Servers from other publishers that do the same job: Ekwo OS — open source accounting: ledger, invoices and VAT on your own Supabase or Postgres MCP server, Neon MCP server and Postgres MCP server. Compare all PostgreSQL alternatives.
- How does PostgreSQL compare with other Databases MCP servers?
- safety score 83/100 (higher than 60% of 802 Databases servers); tools 6 (the typical Databases server has 8); tools that change things 17% (typical: 10%. Fewer write tools means less an agent can break). Full comparison.
Alternatives to PostgreSQL
Same job from other publishers: the closest match first, then the best rated.
- Ekwo OS — open source accounting: ledger, invoices and VAT on your own Supabase or PostgresDouble-entry books an agent keeps as the user: invoices, VAT returns, 174 country packs.not reviewedEstablishedA
- NeonOfficial Neon MCP server for managing Neon projects and Lakebase Postgres databases.not reviewedEstablishedA
- PostgresEnterprise PostgreSQL MCP server with NL queries, hybrid search (pgvector+BM25), and web UInot reviewedGrowingA
SupabaseMCP server for interacting with the Supabase platformnot reviewedWidely usedA- DBHubToken-efficient database MCP server for PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, SQLitenot reviewedWidely usedA