mcpservers.md

PostgreSQL MCP

Official PostgreSQL MCP server — query and inspect Postgres databases with read-only access for safe AI-powered data analysis.

TRUSTED · Official
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://user:pass@host:5432/dbname"]
    }
  }
}

Paste into your client's MCP configuration file.

"List all tables in my database and show row counts for each"

Easy Setup

API key or simple config

Light usage
  • You want to explore an unfamiliar database schema
  • You need to run ad-hoc SELECT queries to investigate data or bugs
  • You're learning SQL and want AI to draft queries you can review
  • You're doing analytics on a read replica and want conversational queries
  • You use MySQL, SQLite, or MongoDB (use those specific servers)
  • You want to give AI unrestricted write access to production
  • You need streaming replication or CDC — that's outside this server's scope
1

Schema Exploration

Get a natural-language tour of an unfamiliar database.

"Describe the schema of my database — list tables, key columns, and how they relate to each other"

2

Data Investigation

Run SELECT queries to answer product or debugging questions.

"How many orders were placed in the last 24 hours and what's the total revenue?"

3

Query Drafting

Let AI draft complex queries with joins and CTEs that you can review and run.

"Write a query to find users who signed up in the last 30 days but haven't made a purchase"

Imagine asking your AI: 'What tables are in my database and how are they related?' or 'Show me the top 10 slowest queries from the last hour' — and it connects directly to your Postgres database. This server lets your AI query and inspect Postgres databases through conversation, without you writing SQL by hand.

The official PostgreSQL MCP server provides read-only access to PostgreSQL databases. AI assistants can explore schemas, run SELECT queries, inspect table structures, and analyze data — with safety constraints that prevent accidental data modification.

Used by developers to let Claude help with database exploration, query optimization, and data analysis without risk.

Claude Cursor Cline
#official#anthropic#postgres#postgresql#database#sql