PostgreSQL MCP Server logo

PostgreSQL MCP Server

Connects MCP-compatible agents to PostgreSQL with database tools, Code Mode, introspection, migrations, filtering, and multiple transports.

Install PostgreSQL MCP Server

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

Setup steps from the project

PostgreSQL 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

PostgreSQL MCP Server MCP server connects MCP-compatible agents to PostgreSQL databases through database tools, resources, and prompts. It supports stdio, Streamable HTTP, and legacy SSE transports, with connection pooling, OAuth 2.1 authentication, and selectable tool groups. Code Mode runs multi-step operations inside a V8 isolate, while schema introspection, migration tracking, extension support, and structured error handling support database-focused workflows. Reach for it when an agent needs controlled access to PostgreSQL data, schemas, performance information, or administrative operations.

Use cases

  • Query PostgreSQL data through an MCP-compatible agent
  • Inspect schemas and track database migrations
  • Run multi-step database workflows in Code Mode
  • Filter exposed tools for a constrained deployment
  • Review database activity through audit resources

Key features

  • 278 specialized PostgreSQL tools
  • V8-isolate Code Mode
  • Schema introspection and migration tracking
  • Connection pooling and tool filtering
  • OAuth 2.1 and HTTP/SSE transports
  • Support for selected PostgreSQL extensions

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.
Directory activity1 viewsConfig copies, upvotes, and views on AllMCPs.

How PostgreSQL MCP Server works

What PostgreSQL MCP Server MCP server does

PostgreSQL MCP Server MCP server exposes PostgreSQL capabilities through the Model Context Protocol. It is intended for agents that need to work with a PostgreSQL 12–18 database while keeping database operations available through MCP rather than custom application code.

The toolset includes support for citext, ltree, pgcrypto, pg_cron, pg_stat_kcache, pgvector, PostGIS, and HypoPG. The project also provides audit logging, schema snapshots before mutations, semantic row-level diffing, and translated database errors intended to give agents clearer recovery information.

How it works

Agents can connect over stdio for local desktop usage or use HTTP/SSE transports for networked deployments. The server maintains a PostgreSQL connection pool and can restrict the exposed toolset with filtering, including distinct tool groups and a Code Mode configuration.

Code Mode executes multi-step database work inside a V8 isolate implemented with Node.js worker threads. Instead of sending every intermediate operation as a separate model tool call, an agent can perform a sequence within the isolated environment. Responses include token-estimate metadata, and the postgres://audit resource can be used to inspect session-level token consumption.

OAuth 2.1 and granular scopes are available for deployments that need authentication and tool-level access control.

Setup and configuration

PostgreSQL MCP Server MCP server requires PostgreSQL 12–18. Docker is the recommended runtime; Node.js 24 or later can also be used. The Docker setup passes POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DATABASE into the container. When PostgreSQL runs on the host machine, the example uses host.docker.internal as the Docker host value.

The npm package can be installed globally with @neverinfamous/postgres-mcp. A local source installation uses the repository, npm install, npm run build, and the compiled CLI. The CLI accepts a PostgreSQL connection URI, such as postgres://user:password@localhost:5432/database, and can be started with the stdio transport. Docker examples also show --tool-filter codemode and an audit-log path.

Tools and capabilities

Available functionality includes:

  • SQL and database operations exposed as specialized MCP tools.
  • Schema introspection and migration-history tracking.
  • Health, performance, and replication information through resources.
  • Built-in prompts for workflows such as query tuning and schema design.
  • Tool filtering to limit the server to selected groups.
  • Connection pooling and deterministic translation of database errors.
  • Extension-oriented APIs for vector, geospatial, scheduling, cryptographic, and other PostgreSQL features.

Limitations and notes

The number of exposed tools depends on the selected tool filter, so a deployment configured with a subset will not present the complete catalog. Docker users must account for container-to-host networking when the database is not running in the same container or network.

Verify the project’s release documentation when exact version-specific counts matter.

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 PostgreSQL MCP Server

PostgreSQL MCP Server is an MCP server that connects AI agents to PostgreSQL databases. Its main capabilities include specialized tools for queries and database operations, schema introspection, migration tracking, Code Mode for multi-step work, resources for database information, and prompts for workflows such as query tuning and schema design.

Install it with Docker, npm, or from source. Docker uses the published image and PostgreSQL environment variables; npm uses `npm install -g @neverinfamous/postgres-mcp`; source installation requires cloning the repository, installing dependencies, building, and starting the CLI with a PostgreSQL connection URI.

It supports PostgreSQL versions 12 through 18.

Yes, the README provides a Cursor MCP configuration example. The example runs the Docker image over stdio, passes PostgreSQL connection variables, and enables the `codemode` tool filter with an audit-log path.

Yes, tool filtering can restrict the server to selected tool groups.

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 PreviewPostgreSQL MCP Server AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/postgresql-mcp-server-3?style=directory)](https://allmcps.com/mcp/postgresql-mcp-server-3)
HTML Embed
<a href="https://allmcps.com/mcp/postgresql-mcp-server-3"><img src="https://allmcps.com/api/badge/postgresql-mcp-server-3?style=directory" alt="PostgreSQL MCP Server on AllMCPs" /></a>