Postgres MCP server
PostgreSQL MCP — query databases, inspect schemas, explain queries.
0 stars25 downloads/wk
Reviews
Write oneNobody has reviewed Postgres yet.
If you have run it, two minutes of your experience saves the next person an afternoon.
Postgres tools (5, 1 write)
write = sends, deletes, buys or postsRead from the package source without running it. The installed server may list more.
explainExplain the execution plan for a SQL query (EXPLAIN FORMAT TEXT, optional ANALYZE).
list_schemasList non-system PostgreSQL schemas in the connected database.
querywrite actionExecute a SQL query against PostgreSQL. Returns results as a formatted table. Read-only by default.
schemaGet tables in a PostgreSQL schema with columns and approximate row counts.
table_infoGet detailed info about a single table: columns, types, constraints, and exact row count.
Public scan report
scanner v0.1.9 · 2026-09-23 · same rubric, same numbers if you re-run it
- Code scan2 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 qualitylocal package, no credentials required12/15
- Maintenancelast push 42 days ago12/15
- Maintainer identityregistry namespace matches repository owner; GitHub account older than a year8/10
Install Postgres in Claude Code, Cursor or VS Code
Runs npx -y mcp-pg-server on your machine. Read the scan report first; the gateway never runs local packages.
claude mcp add postgres -- npx -y mcp-pg-server
What the publisher says
From the Postgres repository's README, as published. We do not edit it. Read it on GitHub
mcp-server-postgres
Query PostgreSQL, inspect schemas, and explain queries from your AI assistant. A daily-driver MCP for local and dev Postgres — same belt as docker and sqlite servers, not an enterprise DBA suite.
DATABASE_URL=postgres://user:pass@localhost:5432/mydb npx mcp-pg-serverWorks with Claude Desktop, Cursor, VS Code Copilot, and any MCP client. Connects via DATABASE_URL or per-call connectionString.
Why
Postgres is the default for most new backends, local dev stacks, and agent workflows that need a real SQL database. You already run it in Docker or on localhost — this server lets your assistant query it, read schemas, and explain plans without leaving the IDE. Read-only by default so exploration stays safe; opt into writes when you need them.
Tools
Quick Start
Cursor
Add to .cursor/mcp.json:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["mcp-pg-server"],
"env": {
"DATABASE_URL": "postgres://user:pass@localhost:5432/mydb"
}
}
}
}Claude Desktop
Add to claudedesktopconfig.json (macOS: ~/Library/Application Support/Claude/claudedesktopconfig.json):
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["mcp-pg-server"],
"env": {
"DATABASE_URL": "postgres://user:pass@localhost:5432/mydb"
}
}
}
}VS Code
Configure the MCP server in your VS Code settings to run npx mcp-pg-server with DATABASE_URL set.
Example prompts
- "Show me the schema of the public tables"
- "Query users: SELECT * FROM users LIMIT 10"
- "Explain this join query"
- "What schemas exist in this database?"
- "How many rows are in the orders table?"
Safety
Read-only by default. The query tool accepts only SELECT, WITH, EXPLAIN, SHOW, and ANALYZE in readonly mode. Set readonly=false to enable INSERT, UPDATE, DELETE, and DDL.
Pass connectionString on any tool to override DATABASE_URL for a single call.
Development
npm install
npm run typecheck
npm run build
npm test
npm run format
npm run lintSee also
More MCP servers and developer tools on my portfolio.
Author
License
MIT © 2026 Ofer Shapira
Nothing above is checked by us. What we check is on the safety report.
Postgres: common questions
- Is Postgres MCP server safe?
- Yes, by our scan: it is graded A (88/100). Read the Postgres safety report
- How do I install Postgres?
- It runs on your machine. Copy the Claude Code, Cursor, VS Code or Claude Desktop config from the install section.
- Does Postgres need an API key?
- Not as far as the registry entry and our scan can tell: no credentials are declared or required.
- Is Postgres maintained?
- The last commit was 62 days ago (2026-08-12). The latest release is v1.0.0.
- What can I use instead of Postgres?
- Servers from other publishers that do the same job: LINQ to DB MCP server, PostgreSQL MCP Server and Grain SQL MCP server. Compare all Postgres alternatives.
Alternatives to Postgres
Same job from other publishers: the closest match first, then the best rated.
- LINQ to DBInspect database schemas and execute SQL queries across multiple database providers with LINQ to DB.not reviewedEstablishedA
- PostgreSQL MCP ServerPostgreSQL MCP server - query, schema introspection, explain, and health checks for AI assistantsnot reviewedEstablishedB
Grain SQLRun SQL queries and inspect database schemas through safe, visible MCP tools.not reviewedGrowingB- MCP Local WPWordPress database access via Local by Flywheel. Execute read-only MySQL queries and inspect schema.not reviewedGrowingA
- Read Only Local PostgresMCP server for read-only PostgreSQL database queries in Claude Desktopnot reviewedGrowingA