Skip to content
Chris & Mike edited this page Mar 9, 2026 · 23 revisions

PostgreSQL MCP Server Wiki

Status: Production/Stable

GitHub GitHub Release Docker Pulls License: MIT Status


🤖 Can't find what you're looking for? Try our AI-Powered Wiki Search - Ask questions in natural language and get instant answers with source attribution.


🔍 Overview

The PostgreSQL MCP Server enables AI assistants (AntiGravity, Claude, Cursor, etc.) to interact with PostgreSQL databases through the Model Context Protocol. It features schema introspection and migration tracking, deterministic error handling, connection pooling, dual HTTP transport (Streamable HTTP + legacy SSE), OAuth 2.1 authentication, Code Mode for token efficiency, flexible tool filtering, and support for 8 PostgreSQL extensions.

232 specialized tools · 20 resources · 19 AI-powered prompts


📋 Wiki Navigation

🚀 Getting Started

  • Quick-Start - Installation, configuration, and first queries
  • HTTP-Transport - Streamable HTTP and legacy SSE endpoints for remote access
  • Tool-Filtering - Stay within AI IDE tool limits with 16 presets
  • Code-Mode - 70-90% token reduction for multi-step operations
  • Tool-Reference - Complete reference of all 232 tools by group

🔌 PostgreSQL Extensions

🤖 AI Integration

🔐 Enterprise Features


⭐ Key Capabilities

Category Count Highlights
Tools 232 Full SQL, JSONB, transactions, performance analysis
Resources 20 Real-time database state snapshots
Prompts 19 Guided workflows for complex DBA tasks
Extensions 8 pgvector, PostGIS, pg_cron, pg_partman, and more
Introspection 6 Cascade simulation, DDL ordering, schema snapshots
Migration 6 Schema migration tracking and deployment
Error Model Structured {success, error} on every tool

Tool Groups (22)

Group Tools Description
core 21 Read/write queries, tables, indexes
transactions 8 BEGIN, COMMIT, ROLLBACK, savepoints
jsonb 20 JSONB manipulation and queries
text 14 Full-text search, fuzzy matching
performance 25 EXPLAIN, query analysis, optimization, anomaly detection
admin 11 VACUUM, ANALYZE, REINDEX
monitoring 12 Database sizes, connections, status
backup 10 pg_dump, COPY, restore
schema 13 Schemas, views, sequences, functions
introspection 7 Dependency graphs, cascade simulation
migration 7 Schema migration tracking
partitioning 7 Native partition management
stats 9 Statistical analysis
vector 17 pgvector (AI/ML similarity search)
postgis 16 PostGIS (geospatial)
cron 9 pg_cron (job scheduling)
partman 11 pg_partman (auto-partitioning)
kcache 8 pg_stat_kcache (OS-level stats)
citext 7 citext (case-insensitive text)
ltree 9 ltree (hierarchical data)
pgcrypto 10 pgcrypto (encryption, UUIDs)
codemode 1 Code Mode (sandboxed execution)

🎛️ Quick Start: Tool Filtering

AI IDEs have tool limits. Use presets to stay within bounds:

# Recommended starting point (60 tools)
--tool-filter starter

# AI/ML workloads with pgvector (51 tools)
--tool-filter ai-vector

# Geospatial workloads (44 tools)
--tool-filter geo

# Maximum token savings: Code Mode only (1 tool)
--tool-filter codemode

See Tool-Filtering for all 16 presets and customization options.


🛠️ Development

After cloning the repository:

npm install                        # Install dependencies
npm run lint && npm run typecheck  # Run checks
npm run bench                      # Run performance benchmarks
npm test                           # Run full test suite (3000+ tests)

Benchmarks

The project includes a performance benchmark suite (10 files, 93+ scenarios) powered by Vitest Bench. Benchmarks cover schema parsing, handler dispatch, identifier sanitization, auth middleware, connection pooling, Code Mode, logging, introspection/migration parsing, and more.

npm run bench            # Standard output
npm run bench:verbose    # Detailed table output

📚 Additional Resources

Clone this wiki locally