# postgres-mcp-server [Health: Active]

**Category:** 🗄️ Databases  
**Repository:** https://github.com/neverinfamous/postgres-mcp.git  
**GitHub Stars:** 12  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/postgres-mcp-server

## Description
Enterprise PostgreSQL MCP server with 63 tools, 10 resources, 10 prompts for AI-native operations

## Claude Desktop Quick Installation
No generated config for this server: it installs through its own setup steps.

The project's own setup steps (from https://github.com/neverinfamous/postgres-mcp.git), copied verbatim. Follow them in order; they are not an mcpServers config.

1. Install:

```sh
docker pull writenotenow/postgres-mcp:latest
```

2. Install:

```sh
npm install -g @neverinfamous/postgres-mcp
```

3. Start the server:

```sh
postgres-mcp --transport stdio --postgres postgres://user:password@localhost:5432/database
```

4. Install:

```sh
git clone https://github.com/neverinfamous/postgres-mcp.git
```

5. Run:

```sh
cd postgres-mcp
```

6. Install:

```sh
npm install
```

## Documentation

## What postgres-mcp-server does

The postgres-mcp-server MCP server exposes PostgreSQL operations to MCP-compatible clients. It connects to PostgreSQL 12 through 18 and provides 278 specialized tools, 24 resources, and 21 prompts. The available surface covers database queries and mutations, schema inspection, migration tracking, health and performance information, and workflows for query tuning and schema design.

The server also supports PostgreSQL extensions including citext, ltree, pgcrypto, pg_cron, pg_stat_kcache, pgvector, PostGIS, and HypoPG. Extension support is described as typed and validated. Use this server when an agent needs to inspect or change a PostgreSQL database rather than only generate SQL text.

## How it works

Agents can use ordinary MCP tool calls or Code Mode. Code Mode runs multi-step database operations in a V8 isolate implemented with Node.js worker threads, which can reduce repeated tool-call exchanges and associated context usage. Tool responses include token-estimation metadata, and an audit resource at `postgres://audit` can be used to review session-level token consumption.

The server can filter the exposed tools by group, helping deployments present only the database capabilities an agent needs. It includes connection pooling, schema introspection, migration-related operations, and translation of database exceptions into more actionable error responses. Audit logging can record activity as JSON Lines, while schema snapshots and semantic row-level diffs support review of mutations and restoration work.

Both stdio and network transports are supported.

## Setup and configuration

The postgres-mcp-server MCP server requires PostgreSQL 12–18. Docker is the recommended runtime; Node.js 24 or newer can also be used. The published Docker image is `writenotenow/postgres-mcp`, and the npm package is `@neverinfamous/postgres-mcp`.

For a Docker-based client configuration, provide the PostgreSQL connection settings through `POSTGRES_HOST`, `POSTGRES_PORT`, `POSTGRES_USER`, `POSTGRES_PASSWORD`, and `POSTGRES_DATABASE`. When the database runs on the host machine, the example uses `host.docker.internal` as the Docker-side host name. The command can also enable a tool filter such as `codemode` and specify an audit-log path.

An npm installation can launch the server with `postgres-mcp --transport stdio --postgres postgres://user:password@localhost:5432/database`. From source, install dependencies, build the project, and run `node dist/cli.js` with the same transport and connection options.

## Tools and capabilities

The postgres-mcp-server MCP server includes capabilities for:

- Querying and mutating PostgreSQL data through specialized tools.
- Inspecting schemas and evaluating the effects of schema changes.
- Tracking migration history and ordering foreign-key updates.
- Reading health, performance, and replication metrics through resources.
- Running built-in prompts for query tuning and schema design.
- Working with the listed PostgreSQL extensions.
- Executing compound operations through Code Mode.
- Filtering tools by capability group.
- Applying OAuth 2.1 authentication and scoped access controls.
- Recording audit data and reviewing semantic differences before restoration.

## Limitations and notes

The provided setup documentation requires a reachable PostgreSQL instance and does not describe an embedded database mode. Docker users must account for container-to-host networking when PostgreSQL runs outside the container. The README names Cursor and Claude Desktop configuration examples; other client support depends on their MCP transport and configuration capabilities. Tool counts and feature availability may change with releases, so deployments should check the project’s current tool reference and changelog.

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

