blueprints × patterns × OpenClaw
🐘
MCP ServerOpen Source · MIT

POSTGRESQLMCP Server

Query and manage your PostgreSQL databases through natural language. Run SELECT queries, inspect schemas, and generate reports without writing SQL.

npx @modelcontextprotocol/server-postgres
At a glance
15Builders use this
6Capabilities
v1.3Latest
Compatibility
Claude CodeVerified
Claude DesktopVerified
CursorVerified
WindsurfVerified
ZedPartial
Capabilities

WHAT IT DOES

Run queries
Schema inspection
Table listing
Data export
Query explanation
Index analysis

The PostgreSQL MCP Server gives your AI agent direct access to your Postgres databases. Invaluable during development — instead of switching to a SQL client, ask your agent and get the answer inline. Runs read queries by default, so you can explore data without worrying about accidental mutations.

What you can do:

  • Schema inspection — list tables, describe columns, indexes, and foreign keys
  • Run queries — natural language to SQL, results in a readable format
  • Index analysis — identify missing indexes and optimization opportunities
  • Data export — pull query results for debugging or reporting

Setup

  1. Prepare a connection string: postgresql://user:password@host:port/database
  2. Add the server to your MCP config with the POSTGRES_CONNECTION_STRING environment variable
  3. Run npx @modelcontextprotocol/server-postgres to verify

For production databases, use a read-only connection string to enforce safe access at the database level.

Example prompts

"Show me the schema for the users and orders tables, including indexes and foreign keys."

"How many orders were placed in the last 7 days, grouped by status?"

"Compare the current schema of the payments table with this migration file — anything missing?"

"Find all users who signed up in the last 24 hours but have zero orders."

Quick links
Sponsor
Your ad here

Reach OpenClaw builders and blueprint architects.

Learn more →