MCP SERVER

PostgreSQL MCP Server — Give AI Agents Live SQL Access

Install the PostgreSQL MCP server to let Claude Code, Cursor, and Windsurf query your live database. Read schemas, run SELECTs, inspect query plans, and debug slow queries — all without copy-pasting SQL back and forth with the AI.

21 tools

Install PostgreSQL MCP Server

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://user:password@localhost:5432/dbname"
      ]
    }
  }
}
Paste into ~/.cursor/mcp.json, replace the connection string, restart Cursor
PostgreSQL MCP Server — Database Queries for AI logo

PostgreSQL MCP Server — Database Queries for AI

MCP server for PostgreSQL database access. Run read-only SQL queries, inspect schemas, list tables, and analyze data directly from Claude Code or Cursor.

MCP Hub 212MCP Configs
Postgres MCP Pro — Index Tuning + Safe SQL Tools logo

Postgres MCP Pro — Index Tuning + Safe SQL Tools

Postgres MCP Pro is an MCP server for PostgreSQL that runs safe SQL, explains plans, and recommends indexes so agents can tune databases faster.

MCP Hub 96MCP Configs
pgEdge Postgres MCP — Read-Only by Default + Web UI logo

pgEdge Postgres MCP — Read-Only by Default + Web UI

pgEdge Postgres MCP is a Go MCP server for Postgres with read-only defaults, optional HTTP auth, and a web UI for database exploration and diagnostics.

MCP Hub 93MCP Configs
pg-mcp-server — Postgres MCP Server (Read-Only) logo

pg-mcp-server — Postgres MCP Server (Read-Only)

Connect LLMs to PostgreSQL via MCP with pg-mcp-server: run via npx, default stdio transport, and keep writes disabled unless explicitly enabled.

MCP Hub 67MCP Configs
Neon — Serverless Postgres with Database Branching logo

Neon — Serverless Postgres with Database Branching

Serverless PostgreSQL with instant database branching, autoscaling, and a generous free tier. Branch your database like git branches — test schema changes without touching production. 16,000+ stars.

MCP Hub 264MCP Configs
Neon MCP — Serverless Postgres via AI Agents logo

Neon MCP — Serverless Postgres via AI Agents

MCP server for Neon serverless Postgres. Create projects, branch databases, run SQL, optimize queries via natural language. Safe migration workflow with branching. MIT, 574+ stars.

MCP Hub 235MCP Configs
DBHub — Universal Database MCP Server, Zero Dependencies logo

DBHub — Universal Database MCP Server, Zero Dependencies

Token-efficient database MCP server supporting Postgres, MySQL, MariaDB, SQL Server, and SQLite. Just two MCP tools, zero dependencies, read-only safe.

TokRepo精选 223MCP Configs
Supabase MCP — Postgres + Auth Server for AI Agents logo

Supabase MCP — Postgres + Auth Server for AI Agents

MCP server for Supabase that gives AI agents access to PostgreSQL databases, authentication, storage, and edge functions. Query data, manage users, and build full-stack features. 4,000+ stars.

Supabase 219MCP Configs
PostgreSQL MCP — SQL Database Server for AI Agents logo

PostgreSQL MCP — SQL Database Server for AI Agents

MCP server that gives AI agents direct access to PostgreSQL databases. Run queries, explore schemas, manage tables, and analyze data through natural language. 3,000+ stars.

MCP Hub 218MCP Configs
GenAI Toolbox — MCP Server for Databases by Google logo

GenAI Toolbox — MCP Server for Databases by Google

Open-source MCP server for databases by Google. Connect AI agents to PostgreSQL, MySQL, Cloud SQL, AlloyDB, and Spanner with built-in auth, connection pooling, and safety. 13K+ stars.

MCP Hub 190MCP Configs
MCP Toolbox for Databases — AI Agent Database Server logo

MCP Toolbox for Databases — AI Agent Database Server

MCP Toolbox for Databases is an open-source MCP server by Google that gives AI agents secure, governed access to databases including PostgreSQL, MySQL, Spanner, BigQuery, and more.

Script Depot 149Skills
Tiger CLI — Tiger Cloud + MCP Server logo

Tiger CLI — Tiger Cloud + MCP Server

Tiger CLI is the command-line interface for Tiger Cloud, including an integrated MCP server so AI assistants can help manage Postgres services safely.

MCP Hub 116CLI Tools
tabularis — Desktop DB Client (AI + MCP Built-In) logo

tabularis — Desktop DB Client (AI + MCP Built-In)

tabularis is an open-source desktop DB client for PostgreSQL, MySQL/MariaDB, and SQLite, with notebooks plus optional AI and plugins for extra drivers.

Script Depot 95CLI Tools
Stash — Self-Hosted Memory + MCP SSE on Postgres/pgvector logo

Stash — Self-Hosted Memory + MCP SSE on Postgres/pgvector

Stash is a self-hosted memory layer for agents with an MCP SSE endpoint, backed by Postgres + pgvector and a consolidation pipeline for long-lived recall.

MCP Hub 94MCP Configs
DBHub — Token-Efficient Database MCP Server logo

DBHub — Token-Efficient Database MCP Server

Database MCP server for Postgres/MySQL/MariaDB/SQL Server/SQLite. Includes execute_sql + schema search with guardrails: read-only, row limits, timeouts.

MCP Hub 91MCP Configs
pg-aiguide — Postgres Skills + MCP Search logo

pg-aiguide — Postgres Skills + MCP Search

pg-aiguide upgrades AI coding assistants for PostgreSQL: install best-practice skills via `npx skills` and add an MCP server for semantic doc search.

MCP Hub 86MCP Configs
Eion — Shared Memory Server + MCP for Agents logo

Eion — Shared Memory Server + MCP for Agents

A shared-memory server for multi-agent systems with Postgres+Neo4j and embedded MCP tools; verified 155★, pushed 2025-07-02.

MCP Hub 77MCP Configs
Supabase MCP Server — Postgres + Admin Tools (API Key Gate) logo

Supabase MCP Server — Postgres + Admin Tools (API Key Gate)

Supabase MCP Server connects MCP clients to Supabase Postgres and admin APIs, using env-based config and an API key gate to reduce unsafe default exposure.

MCP Hub 72MCP Configs
SmartDB_MCP — Universal Database MCP Gateway logo

SmartDB_MCP — Universal Database MCP Gateway

Universal database MCP gateway (MySQL/Postgres/Oracle/SQL Server) with role-based SQL permissions + health checks; verified 79★, pushed 2025-09-14.

MCP Hub 63MCP Configs
MCP-PostgreSQL-Ops — PostgreSQL DBA MCP (30+ tools) logo

MCP-PostgreSQL-Ops — PostgreSQL DBA MCP (30+ tools)

Give Claude Desktop/Claude Code a PostgreSQL DBA toolbox (30+ tools) for locks, bloat, autovacuum, and stats. Works on PG 12–18; stdio or HTTP transport.

MCP Hub 22MCP Configs
DryRun — Offline PostgreSQL MCP (No DB Creds) logo

DryRun — Offline PostgreSQL MCP (No DB Creds)

DryRun snapshots your PostgreSQL schema once and provides offline linting plus migration/query checks via CLI + MCP, without sharing prod credentials.

MCP Hub 21MCP Configs

Live database context for AI agents

The PostgreSQL MCP server solves the most frustrating failure mode in AI-assisted development: the model writes perfect-looking SQL against a schema that doesn't exist. With the MCP server installed, Claude Code and Cursor can inspect your real tables, read live column types, check actual indexes, and test queries before suggesting them. No more "hallucinated table names" — the model is grounded in what's actually in your database.

The official reference implementation ships in read-only mode by default, which is exactly what you want for a production connection. The AI can SELECT, run EXPLAIN ANALYZE, and explore pg_catalog — but it can't accidentally DROP TABLE users. For write access, point it at a separate dev database or create a bounded role with explicit grants. Both modes are production-safe when configured correctly.

Where this gets transformative is pairing the PostgreSQL MCP server with a GitHub MCP server. An agent can now: read a failing migration from a PR, check the current schema in staging, detect the conflict, rewrite the migration, and open a follow-up PR — all in one conversation. For broader database tooling including MySQL, MongoDB, and Supabase, browse the TokRepo database directory. For agent frameworks that chain these tools together, see our agent building tools.

The moment your AI stops hallucinating table names is the moment it starts shipping real migrations.

Frequently Asked Questions

What is the PostgreSQL MCP server?+

The PostgreSQL MCP server is an open-source implementation of the Model Context Protocol that lets AI agents query a Postgres database. It exposes a set of structured tools — list tables, describe schema, run query, explain query — and handles connection pooling and error handling. The reference implementation is read-only by default and ships under @modelcontextprotocol/server-postgres on npm.

How do I install the Postgres MCP server in Claude Code?+

Run `claude mcp add postgres -- npx -y @modelcontextprotocol/server-postgres postgresql://user:pass@host:5432/db` in your terminal, then restart Claude Code. Verify with `claude mcp list`. For production databases, we strongly recommend creating a dedicated read-only Postgres role and putting its credentials in the connection string — never use a superuser account.

Is it safe to connect the MCP server to a production database?+

Yes, if you use a read-only role and enable statement timeouts. Create a Postgres role with only SELECT permissions on the schemas the AI needs, set `statement_timeout` on the role to prevent runaway queries, and consider putting the connection through pgbouncer with a capped pool size. Never give the AI an account with DROP or TRUNCATE privileges on production data.

Can the MCP server write to the database?+

The official reference implementation is read-only. For write access you have two options: (1) Use a fork that supports INSERT/UPDATE with approval workflows, or (2) Run a second instance of the server against a separate dev/staging database where write access is safe. Many teams keep a read-only production connection AND a writable staging connection configured simultaneously.

Does it work with Supabase, Neon, and other hosted Postgres?+

Yes. Anything that speaks the Postgres wire protocol works — Supabase, Neon, Railway, AWS RDS, Azure Database for PostgreSQL, Google Cloud SQL, and self-hosted clusters. Just point the connection string at the host. For Supabase specifically, check the TokRepo database directory — there's a dedicated Supabase MCP server that also exposes auth and storage APIs.

What PostgreSQL versions are supported?+

The reference server uses the node-postgres driver, which supports PostgreSQL 9.4 through 17. For query-plan inspection features (EXPLAIN ANALYZE with JSON output), you need PostgreSQL 9.6+. For the best experience with modern AI workflows, we recommend PostgreSQL 15 or 16 since they expose richer pg_stat views the AI can use for performance diagnosis.

Explore Related Categories