workflows ร— automations ร— 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
15Makers 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. You can inspect schemas, run queries, analyze indexes, and generate reports through natural language. It is invaluable during development โ€” instead of switching to a SQL client to check table structures or verify data, you ask your agent and get the answer inline. The server runs read queries by default, so you can explore your data without worrying about accidental mutations.

To connect, you need a PostgreSQL connection string in the format postgresql://user:password@host:port/database. Add the server to your MCP config and set the POSTGRES_CONNECTION_STRING environment variable. Run npx @modelcontextprotocol/server-postgres and the agent will immediately have access to list tables, describe schemas, and run queries. For production databases, use a read-only connection string to enforce safe access at the database level.

Prompts makers reach for regularly: "Show me the schema for the users and orders tables, including indexes and foreign keys." Or "How many orders were placed in the last 7 days, grouped by status?" It also helps when writing migrations: "Compare the current schema of the payments table with this migration file and tell me if anything is missing." For debugging, try: "Find all users who signed up in the last 24 hours but have zero orders โ€” give me their emails and signup timestamps." The agent translates your intent into SQL, runs it, and presents results in a readable format.

Quick links
Sponsor
Your ad here

Reach OpenClaw builders and developers.

Learn more โ†’