Postgres MCP Server logo

Postgres MCP Server

Connects AI agents to PostgreSQL through 278 tools, Code Mode, schema introspection, migrations, resources, and prompts.

Install Postgres MCP Server

Run the project’s own setup commands, in order.

Setup steps from the project

postgres-mcp-server installs with its own steps rather than a config we can generate, so these are copied as-is. Follow them in order and run the commands in a terminal. Source: github.com

  1. 1. Install
    docker pull writenotenow/postgres-mcp:latest
    
  2. 2. Install
    npm install -g @neverinfamous/postgres-mcp
    
  3. 3. Start the server
    postgres-mcp --transport stdio --postgres postgres://user:password@localhost:5432/database
    
  4. 4. Install
    git clone https://github.com/neverinfamous/postgres-mcp.git
    
  5. 5. Run
    cd postgres-mcp
    
  6. 6. Install
    npm install
    

Overview

The postgres-mcp-server MCP server connects AI agents to PostgreSQL through 278 specialized tools, 24 resources, and 21 prompts. It supports stdio, Streamable HTTP, and legacy SSE transports, with Code Mode for running multi-step operations inside a V8 isolate. Use it for database querying, schema and migration work, operational metrics, and extension-specific tasks when agents need structured PostgreSQL access. OAuth 2.1, tool filtering, connection pooling, audit logging, and deterministic database error handling are also available.

Use cases

  • Query PostgreSQL data from an AI agent
  • Inspect schemas and migration history
  • Run multi-step database operations in Code Mode
  • Review database audit logs and row-level diffs
  • Expose selected PostgreSQL extension capabilities

Key features

  • 278 PostgreSQL tools
  • V8-isolate Code Mode
  • Schema introspection and migration tracking
  • Streamable HTTP, SSE, and stdio transports
  • OAuth 2.1 and scoped access control
  • PostgreSQL extension support

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

13/13 checks healthy over the last 83d

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars12Stargazers on the source repository.
Last commit2mo agoMost recent push to the default branch.

How Postgres MCP Server works

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.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Postgres MCP Server

postgres-mcp-server is an MCP server that connects AI agents to PostgreSQL databases through 278 specialized tools, 24 resources, and 21 prompts. Its main capabilities include querying and mutating data, inspecting schemas, tracking migrations, reading operational metrics, and running multi-step operations with Code Mode.

Install it with Docker, npm, or from source. Docker uses the `writenotenow/postgres-mcp` image; npm installs `@neverinfamous/postgres-mcp` globally. Configure the PostgreSQL connection, then launch it over stdio or use the documented network transports.

Yes, postgres-mcp-server includes a Cursor MCP configuration example. Add the server to `~/.cursor/mcp.json`, provide the PostgreSQL environment variables, and run the Docker command or another supported launch command.

postgres-mcp-server supports PostgreSQL versions 12 through 18. The README reports testing with PostgreSQL 18.1 and lists Docker or Node.js 24 and newer as runtime prerequisites.

Use Code Mode for multi-step operations. It runs database work inside a V8 isolate and reduces repeated MCP tool exchanges; tool filtering and `limit` parameters can further control the amount of exposed or returned data.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewPostgres MCP Server AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/postgres-mcp-server?style=directory)](https://allmcps.com/mcp/postgres-mcp-server)
HTML Embed
<a href="https://allmcps.com/mcp/postgres-mcp-server"><img src="https://allmcps.com/api/badge/postgres-mcp-server?style=directory" alt="Postgres MCP Server on AllMCPs" /></a>