# PostgreSQL — MCP Server

> Chat with any Postgres database using AI.

**Source:** https://mcpplaygroundonline.com/mcp-servers/postgres  
**Transport:** byo  
**Requires auth:** Yes

---

## What it does

A Postgres MCP server wraps a PostgreSQL connection and exposes its capabilities as MCP tools — listing tables, describing schemas, running parameterised SQL, explaining query plans, and (optionally) writing rows back. Models like Claude, GPT and Gemini can then plan multi-step questions ("which customers churned last quarter and why?") and execute them as a sequence of tool calls. The most popular implementations are crystaldba/postgres-mcp (open-source, MIT) and the hosted Neon MCP server, which lets you query Neon-hosted Postgres without running anything locally.

## Tools exposed

- list_schemas — enumerate all schemas in the database
- list_tables — list tables, optionally filtered by schema
- describe_table — return columns, types, indexes, foreign keys
- execute_sql — run a parameterised read query and return rows
- explain_query — return the EXPLAIN plan for tuning advice

## Example queries you can run

- "List all tables in the public schema and tell me which ones look like fact tables vs dimensions."
- "Show me the top 10 customers by total order value in the last 90 days."
- "There is a slow query on the orders table — can you find missing indexes?"
- "Summarise the schema of the users table and flag any columns that look like PII."

## Details

- **Recommended model:** anthropic/claude-sonnet-4.5 — Claude Sonnet 4.5 handles multi-step SQL planning and schema reasoning reliably. For cheap, high-volume reads use Haiku 4.5 or GPT-5.2 mini.
- **Transport:** byo
- **Authentication:** Required — Your Postgres connection string. Run the open-source crystaldba/postgres-mcp locally, or use a hosted option like Neon MCP.
- **Official source:** [crystaldba/postgres-mcp on GitHub](https://github.com/crystaldba/postgres-mcp)

## Frequently asked questions

### What is the Postgres MCP server?

It is an MCP-compatible bridge between an AI model and a PostgreSQL database. The server exposes tools like list_tables, describe_table and execute_sql so models can answer database questions by writing and running SQL on your behalf.

### Is there an official hosted Postgres MCP server?

There is no single canonical hosted server — Postgres connection strings are private. The most-used implementations are crystaldba/postgres-mcp (run locally with your DATABASE_URL) and Neon MCP (hosted, only works against Neon-managed databases).

### Is it safe to give an AI agent access to my production database?

Use a read-only role, restrict the server to a single schema or set of tables, and never paste service-role credentials. For exploration, point it at a staging copy. Most Postgres MCP servers also support a SQL allowlist or read-only mode.

### Which AI model is best for Postgres MCP queries?

Claude Sonnet 4.5 is the strongest at multi-step SQL reasoning. For cheaper, high-volume read queries Claude Haiku 4.5 and GPT-5.2 mini are usually sufficient. Compare them side-by-side in MCP Agent Studio before committing.

### How do I test a Postgres MCP server in the browser?

Open MCP Agent Studio, paste the URL of a running Postgres MCP server (HTTP or SSE), pick a model and start chatting. You can also bring up Neon MCP and connect to it without installing anything locally.

---

_Test this server across 40+ models on MCP Playground: https://mcpplaygroundonline.com/mcp-servers/postgres — free, no install._
