Skip to content
Temp edited this page Oct 4, 2025 · 3 revisions

PostgreSQL MCP Server - Complete Documentation

Version 1.1.0 - Enterprise-grade PostgreSQL operations with 63 tools, 10 resources, and 10 prompts

License: MIT Security Type Safety CodeQL


🚀 Quick Navigation

Getting Started

Tool Categories (63 Tools)

Advanced Topics


📊 Overview

The PostgreSQL MCP Server provides 63 specialized tools, 10 intelligent resources, and 10 guided prompts for comprehensive database operations:

MCP Tools (63)

Category Tools Key Features
Core Database 9 Schema management, SQL execution, health monitoring
JSON Operations 15 JSONB, validation, security scanning, diff/merge
Text Processing 6 Trigram similarity, full-text search, fuzzy matching
Statistical Analysis 8 Descriptive stats, correlation, time series
Performance 6 Query optimization, index tuning, workload analysis
Vector Search 8 Semantic search, embeddings, clustering
Geospatial 7 PostGIS, spatial queries, coordinate transformation
Backup & Recovery 4 Logical/physical backup, restore validation
Monitoring 5 Real-time metrics, alerting, capacity planning

MCP Resources (10) - NEW in v1.1.0!

Real-time database meta-awareness that AI can access automatically:

  • Database Schema - Instant access to all tables, columns, types
  • Database Capabilities - Available extensions, features, pg_stat_statements
  • Performance Metrics - Top queries, cache hit rates, slow queries
  • Database Health - Connection pool, indexes, vacuum status
  • Extension Status - pgvector, PostGIS, hypopg availability
  • Index Statistics - Usage, size, recommendations
  • Connection Pool - Active connections, utilization
  • Replication Status - Lag, health monitoring
  • Vacuum Status - Bloat, last vacuum/analyze times
  • Lock Information - Active locks, blocking queries

MCP Prompts (10) - NEW in v1.1.0!

Guided workflows for complex operations:

  • Optimize Query - Step-by-step query optimization
  • Index Tuning - Comprehensive index recommendations
  • Database Health Check - Full health assessment workflow
  • Setup pgvector - Complete vector search setup
  • Setup PostGIS - Complete geospatial setup
  • JSONB Best Practices - JSONB optimization guide
  • Performance Baseline - Establish performance baselines
  • Backup Strategy - Comprehensive backup planning
  • Extension Setup - Step-by-step extension installation
  • Query Analysis - Deep dive query analysis

🎯 Key Features

🔒 Security First

  • Zero Known Vulnerabilities - Comprehensive security audit passed
  • SQL Injection Prevention - Parameter binding with automatic sanitization
  • Dual Security Modes - Restricted (production) and unrestricted (development)
  • Enterprise-Grade Protection - Query validation, audit logging

⚡ Performance Excellence

  • Real-Time Analytics - pg_stat_statements integration
  • Hypothetical Index Testing - HypoPG for zero-risk optimization
  • DTA Algorithm - Microsoft SQL Server-inspired index tuning
  • Buffer Cache Analysis - 99%+ accuracy monitoring

🧠 AI-Native Operations

  • Schema Intelligence - Context-aware SQL generation
  • Query Optimization - Automated performance improvements
  • Predictive Analysis - Performance forecasting
  • Natural Language Interface - Human-friendly database interactions

🏢 Enterprise Ready

  • PostgreSQL 13-17 - Full version compatibility
  • Multi-Platform - Windows, Linux, macOS (amd64, arm64)
  • 100% Type Safe - Pyright strict mode (2,000+ issues resolved)
  • Zero Linter Errors - Clean codebase with comprehensive type checking
  • CI/CD Ready - Automated testing and security validation

🆕 Recent Updates

Version 1.1.0 Release - October 4, 2025 🎉

  • NEW: MCP Resources (10) - Real-time database meta-awareness
  • NEW: MCP Prompts (10) - Guided workflows for complex operations
  • Intelligent Assistant - Transforms from tool collection to database expert
  • Pyright Strict Mode - 2,000+ type issues resolved, 100% type-safe codebase
  • Zero Linter Errors - Clean codebase with comprehensive type checking
  • Zero Breaking Changes - All existing tools work unchanged

Version 1.0.0 Release - October 3, 2025 🎉

  • Production Ready: Enterprise-grade PostgreSQL MCP server
  • 63 Specialized Tools: Complete feature set across 9 categories
  • Zero Known Vulnerabilities: Comprehensive security audit passed
  • Type Safety: Pyright strict mode compliance
  • Multi-Platform Support: Windows, Linux, macOS (amd64, arm64)

Phase 5 Release - October 3, 2025

  • Backup & Recovery Suite: 4 new tools implemented
  • Monitoring & Alerting Suite: 5 new tools implemented
  • All 63 Tools Operational: Complete Phase 5 implementation
  • Code Quality: Ruff formatting and linting passing

Phase 4 Release - October 3, 2025

  • Vector/Semantic Search: 8 tools with pgvector integration
  • Geospatial Operations: 7 tools with PostGIS integration
  • Extension Support: pgvector v0.8.0 and PostGIS v3.5.0
  • Graceful Degradation: Informative errors for missing extensions

📚 Documentation Structure

This wiki is organized to help you find information quickly:

For Beginners

  1. Start with Quick Start
  2. Review Installation & Configuration
  3. Set up Extensions
  4. Configure your MCP Client

For Developers

  1. Explore Core Database Tools
  2. Learn JSON Operations
  3. Master Performance Intelligence
  4. Understand Security Best Practices

For Enterprise Users

  1. Review Backup & Recovery
  2. Set up Monitoring & Alerting
  3. Optimize with Performance Intelligence
  4. Implement Security Best Practices

🔗 External Resources


💡 Quick Examples

Execute Secure SQL

execute_sql(
    sql="SELECT * FROM users WHERE id = %s",
    params=[123]
)

Analyze Database Health

analyze_db_health(health_type="all")

Monitor Real-Time Performance

monitor_real_time(
    include_queries=True,
    include_locks=True,
    include_io=True
)

Optimize Vector Search

vector_similarity(
    table_name="documents",
    vector_column="embedding",
    query_vector=[0.1, 0.2, ...],
    distance_metric="cosine",
    limit=10
)

📈 Project Stats

  • Version 1.1.0 - AI-native intelligence release (October 4, 2025)
  • 63 MCP Tools across 9 categories
  • 10 MCP Resources for database meta-awareness
  • 10 MCP Prompts for guided workflows
  • 7,500+ lines of implementation code
  • 14 modules with specialized functionality
  • 100% Type Safe - Pyright strict mode (2,000+ issues resolved)
  • Zero Linter Errors - Clean codebase with comprehensive type checking
  • Zero Vulnerabilities - Comprehensive security audit passed

🤝 Community & Support


Version 1.1.0 - Last Updated: October 4, 2025

Clone this wiki locally