Server data from the Official MCP Registry
PostgreSQL MCP — query databases, inspect schemas, explain queries.
About
PostgreSQL MCP — query databases, inspect schemas, explain queries.
Security Report
A well-architected PostgreSQL MCP server with strong security fundamentals. Authentication is properly delegated to PostgreSQL (via DATABASE_URL or per-call connectionString), write operations are read-only by default with explicit opt-in, and input handling is sound. Minor code quality observations exist but do not constitute security risks. Permissions align well with stated purpose for a data analytics database tool. Supply chain analysis found 3 known vulnerabilities in dependencies (1 critical, 0 high severity). Package verification found 1 issue.
7 files analyzed · 8 issues found
Security scores are indicators to help you make informed decisions, not guarantees. Always review permissions before connecting any MCP server.
Permissions Required
This plugin requests these system permissions. Most are normal for its category.
How to Install
Add this to your MCP configuration file:
{
"mcpServers": {
"io-github-ofershap-postgres": {
"args": [
"-y",
"mcp-pg-server"
],
"command": "npx"
}
}
}Documentation
View on GitHubFrom the project's GitHub README.
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-server
Works with Claude Desktop, Cursor, VS Code Copilot, and any MCP client. Connects via
DATABASE_URLor per-callconnectionString.
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
| Tool | What it does |
|---|---|
query | Execute SQL (SELECT, WITH, EXPLAIN, SHOW, ANALYZE). Returns a text table. |
schema | Tables in a schema (default public) with columns and approximate row counts |
table_info | One table: columns, types, null/default, PK, exact row count |
explain | EXPLAIN (FORMAT TEXT), optional ANALYZE |
list_schemas | List non-system schemas |
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 claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.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 lint
See also
More MCP servers and developer tools on my portfolio.
Author
License
MIT © 2026 Ofer Shapira
Reviews
No reviews yet
Be the first to review this server!
More Data & Analytics MCP Servers
Toleno
Freeby Toleno · Developer Tools
Toleno Network MCP Server — Manage your Toleno mining account with Claude AI using natural language.
mcp-creator-python
Freeby mcp-marketplace · Developer Tools
Create, build, and publish Python MCP servers to PyPI — conversationally.
MarkItDown
Freeby Microsoft · Content & Media
Convert files (PDF, Word, Excel, images, audio) to Markdown for LLM consumption
MCP Marketplace
Freeby mcp-marketplace · Developer Tools
Search and install MCP servers from inside your AI client.
FinAgent
Freeby mcp-marketplace · Finance
Free stock data and market news for any MCP-compatible AI assistant.
Google Workspace MCP
Freeby Taylorwilsdon · Productivity
Control Gmail, Calendar, Docs, Sheets, Drive, and more from your AI
