Skip to content

Add PostgreSQL MCP Server (postgresql-mcp) #3146

@JaviMaligno

Description

@JaviMaligno

📋 MCP Server Submission

Server Information

Name: MCP Server for PostgreSQL
Package: postgresql-mcp
Current Version: 0.2.0
Author: Javier Aguilar
Repository: https://github.com/JaviMaligno/postgres_mcp
PyPI Package: https://pypi.org/project/postgresql-mcp/

🎯 Value Proposition

This server enables AI assistants to interact with PostgreSQL databases safely and efficiently. It provides tools for querying, schema exploration, and performance analysis with a security-first design.

🔐 Key Features

  • 14 Tools: Comprehensive database operations
  • Query Execution: Run SELECT queries with results limiting
  • Schema Exploration: List schemas, tables, views, functions
  • Table Analysis: Describe structure, indexes, constraints
  • Performance Stats: Table statistics and EXPLAIN plans
  • Column Search: Find columns across all tables
  • Security First: SQL injection prevention, read-only by default
  • Write Operations: Optional INSERT/UPDATE/DELETE (disabled by default)

🛡️ Security Features

  • Read-Only Default: Write operations require explicit opt-in
  • SQL Validation: Blocks dangerous operations and injection attempts
  • Identifier Sanitization: Safe handling of schema/table names
  • Credential Protection: Passwords stored as SecretStr
  • Query Limits: Configurable MAX_ROWS to prevent DoS

🚀 Installation

# Install via pipx (recommended)
pipx install postgresql-mcp

# Or via pip
pip install postgresql-mcp

Claude Desktop Configuration

{
  "mcpServers": {
    "postgres": {
      "command": "postgresql-mcp",
      "env": {
        "POSTGRES_HOST": "localhost",
        "POSTGRES_PORT": "5432",
        "POSTGRES_USER": "your-user",
        "POSTGRES_PASSWORD": "your-password",
        "POSTGRES_DB": "your-database"
      }
    }
  }
}

🛠️ Available Tools

Tool Description
query Execute read-only SQL queries
execute Execute write operations (when enabled)
explain_query Get EXPLAIN plan for queries
list_schemas List database schemas
list_tables List tables in a schema
describe_table Get table structure
table_stats Get table statistics
list_indexes List table indexes
list_constraints List table constraints
list_views List views in schema
describe_view Get view definition
list_functions List functions/procedures
get_database_info Get database info
search_columns Search columns by name

📊 Quality Metrics

  • Test Coverage: Comprehensive test suite
  • Documentation: Full README with examples
  • Type Safety: Pydantic models throughout
  • Security: Multiple security layers
  • Maintenance: Active development

🛠️ Technical Details

  • Language: Python 3.10+
  • Framework: FastMCP
  • Database Driver: psycopg2
  • Transport: STDIO
  • Dependencies: psycopg2-binary, pydantic, pydantic-settings

🔗 Links & Resources

🎯 Target Audience

  • Database administrators seeking AI-assisted query building
  • Developers needing to explore unfamiliar database schemas
  • Teams wanting natural language database interactions
  • Anyone working with PostgreSQL databases

Submission Date: December 20, 2025

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions