# Postgres MCP Pro

> Query PostgreSQL, tune indexes, review explain plans and run health checks with configurable read-only or read/write access.

- Listing: https://mcp.tc/i/postgres
- Connect: this is a local (stdio) server; install it on your machine (see Install). The listing link is a page, not an MCP endpoint.
- Type: local (stdio)
- Auth: no API key needed
- Category: [Databases & Backend](https://mcp.tc/c/databases)
- Vendor: Crystal DBA
- Homepage: <https://github.com/crystaldba/postgres-mcp>
- Repository: <https://github.com/crystaldba/postgres-mcp>
- Package: pypi `postgres-mcp`

## About

Postgres MCP Pro connects an AI assistant to a PostgreSQL database. It covers SQL execution, schema exploration, EXPLAIN plan review with hypothetical index simulation, index tuning for a workload, and database health checks such as index health, connection use, buffer cache, vacuum, sequence limits and replication lag.

It runs locally over stdio (SSE is also supported), started with uvx or Docker. It needs a DATABASE\_URI connection string in the environment. The access mode is set with --access-mode: unrestricted allows read/write, restricted limits to read-only transactions with an execution time limit.

## What it can do

- Run SQL against PostgreSQL with restricted or unrestricted access modes
- Review EXPLAIN plans and simulate hypothetical indexes
- Recommend indexes for a workload
- Check index health, vacuum, cache and replication lag
- Inspect schema for context-aware SQL generation

## Example prompts

- "Run a health check on my Postgres database"
- "Why is this query slow? Show the explain plan and suggest indexes"
- "List the tables in my database and describe their schema"
- "Recommend indexes for my most frequent queries"

## Install

### Claude Code

1. Run this in a terminal, in your project folder:

```bash
claude mcp add --transport stdio postgres -- uvx postgres-mcp --access-mode=restricted
```

2. Start Claude Code and type `/mcp`. **postgres** should show as connected.

Add `--scope user` to make it available in every project.

### Claude Desktop

1. Open **Settings → Developer → Edit Config**. It opens `claude_desktop_config.json`. Add:

`claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "postgres": {
      "command": "uvx",
      "args": [
        "postgres-mcp",
        "--access-mode=restricted"
      ]
    }
  }
}
```

2. Save the file and restart Claude Desktop.

Needs uv (Python) on your computer. The file lives in `~/Library/Application Support/Claude/` on macOS and `%APPDATA%\Claude\` on Windows.

### Cursor

[Add to Cursor](<https://cursor.com/install-mcp?name=postgres&config=eyJjb21tYW5kIjoidXZ4IiwiYXJncyI6WyJwb3N0Z3Jlcy1tY3AiLCItLWFjY2Vzcy1tb2RlPXJlc3RyaWN0ZWQiXX0%3D>) (opens Cursor)

Or add it by hand to `~/.cursor/mcp.json` (all projects) or `.cursor/mcp.json` (this project):

`mcp.json`:

```json
{
  "mcpServers": {
    "postgres": {
      "command": "uvx",
      "args": [
        "postgres-mcp",
        "--access-mode=restricted"
      ]
    }
  }
}
```

Needs uv (Python) on your computer.

### VS Code

[Install in VS Code](<https://vscode.dev/redirect/mcp/install?name=postgres&config=%7B%22type%22%3A%22stdio%22%2C%22command%22%3A%22uvx%22%2C%22args%22%3A%5B%22postgres-mcp%22%2C%22--access-mode%3Drestricted%22%5D%7D>) (opens VS Code)

Or from a terminal:

```bash
code --add-mcp '{"name":"postgres","type":"stdio","command":"uvx","args":["postgres-mcp","--access-mode=restricted"]}'
```

Or commit it to the repo in `.vscode/mcp.json`:

`.vscode/mcp.json`:

```json
{
  "servers": {
    "postgres": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "postgres-mcp",
        "--access-mode=restricted"
      ]
    }
  }
}
```

Needs uv (Python) on your computer.

### Devin Desktop

1. Add it to `~/.config/devin/mcp_config.json` (macOS and Linux) or `%APPDATA%\devin\mcp_config.json` (Windows):

`mcp_config.json`:

```json
{
  "mcpServers": {
    "postgres": {
      "command": "uvx",
      "args": [
        "postgres-mcp",
        "--access-mode=restricted"
      ]
    }
  }
}
```

2. Refresh the MCP server list in Cascade.

Devin Desktop is the new name for Windsurf.

### Codex

```bash
codex mcp add postgres -- uvx postgres-mcp --access-mode=restricted
```

Or edit `~/.codex/config.toml` directly:

`config.toml`:

```toml
[mcp_servers.postgres]
command = "uvx"
args = ["postgres-mcp", "--access-mode=restricted"]
```

Needs uv (Python) on your computer.

### Gemini CLI

```bash
gemini mcp add postgres uvx -- postgres-mcp --access-mode=restricted
```

This adds it to the current project. Add `-s user` to use it everywhere.

### Any client

Most clients that start local servers accept this shape:

```json
{
  "mcpServers": {
    "postgres": {
      "command": "uvx",
      "args": [
        "postgres-mcp",
        "--access-mode=restricted"
      ]
    }
  }
}
```

Zed puts servers under `context_servers` in its settings, with the same `command`, `args` and `env` fields.

Needs uv (Python) on your computer.

## Details

- Server version: 0.3.0
- Last checked: 2026-10-03
- Listed: 2026-10-03
- Updated: 2026-10-03

---
Source: https://mcp.tc/i/postgres (mcp.tc is an independent directory, not affiliated with this server's publisher). Corrections: https://mcp.tc/report
