# crystaldba/postgres-mcp [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/crystaldba/postgres-mcp  
**GitHub Stars:** 3430  
**Views:** 5  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/crystaldba-postgres-mcp

## Description
All-in-one MCP server for Postgres development and operations, with tools for performance analysis, tuning, and health checks

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `uvx` (confidence: high):

```json
"mcpServers": {
  "postgres-mcp": {
    "command": "uvx",
    "args": ["postgres-mcp"],
    "env": {
      "DATABASE_URI": ""
    }
  }
}
```

**Requires environment variables:** `DATABASE_URI` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What crystaldba/postgres-mcp does

The crystaldba/postgres-mcp MCP server gives AI agents access to PostgreSQL development and operations workflows. It is intended for work that spans application coding, testing, deployment, and ongoing database maintenance.

Its capabilities cover several areas:

- Database health analysis, including index health, connection usage, buffer cache, vacuum status, sequence limits, and replication lag.
- Index tuning across potential index choices for a workload.
- Query-plan inspection through EXPLAIN plans and testing the possible effect of hypothetical indexes.
- Schema-aware SQL generation based on information about the connected database.
- SQL execution with configurable access controls.

These features make it suitable for investigating slow queries, reviewing database conditions, and helping an agent work with an existing PostgreSQL schema.

## How it works

The crystaldba/postgres-mcp MCP server connects to a PostgreSQL database using a connection URI supplied through `DATABASE_URI`. An MCP client starts the process locally through the standard input/output transport, or connects to a server using Server-Sent Events (SSE). SSE can allow multiple MCP clients to use one running server, including clients connecting to a remote host.

Access behavior is selected with an access-mode option. Unrestricted mode permits read and write operations that can change data or schema, making it appropriate for development environments. Restricted mode uses read-only transactions and applies resource limits; the documented limit is execution time, making this mode suited to production use.

## Setup and configuration

The crystaldba/postgres-mcp MCP server can run from Docker or Python. Docker is recommended in the project documentation because it includes the required dependencies and may avoid Python environment-specific problems. Python installations can use `pipx` or `uv`, and require Python 3.12 or newer.

For a local client configuration, provide the PostgreSQL connection URI as `DATABASE_URI` and select either `--access-mode=unrestricted` or `--access-mode=restricted`. Docker, `uvx`, `pipx`, and `uv` examples are provided by the project. The Docker setup also remaps a database hostname of `localhost` for connections from the container.

To use SSE, start the process with `--transport=sse`; the documented Docker example publishes port 8000. The project gives configuration guidance for Claude Desktop and notes that similar settings can be adapted for other MCP clients.

## Tools and capabilities

The server exposes database-oriented MCP capabilities rather than general-purpose application tools. Health checks examine operational signals such as connections, caching, vacuum activity, sequences, replication lag, and indexes. Performance workflows combine query-plan review with index experimentation, while schema intelligence supplies database context for generated SQL.

SQL execution is governed by the selected access mode. This is important when connecting an agent to a production database: restricted mode limits the agent to read-only transactions, while unrestricted mode allows changes to data and schema.

## Limitations and notes

A usable PostgreSQL connection and valid access credentials are required. The documented prerequisites are either Docker or Python 3.12 or later. The project verifies credentials using tools such as `psql` or a graphical PostgreSQL client before setup.

The README provides direct configuration instructions for Claude Desktop and adaptation guidance for other clients. It specifically mentions Cursor, Windsurf, Goose, and Qodo Gen, although only clients represented in the directory’s compatibility list are included here. The choice between stdio and SSE depends on whether the server is used locally by one client or shared by multiple clients.

_Full upstream README: https://allmcps.com/mcp/crystaldba-postgres-mcp/readme_

