PostgreSQL MCP Server

MCP Server (STDIO) for PostgreSQL Database

Local serverstdioPython

What is the PostgreSQL MCP Server?

MCP Server (STDIO) for PostgreSQL Database

What you get

A Model Context Protocol (MCP) server implementation for PostgreSQL database exploration and querying.

This project provides a Model Context Protocol (MCP) server that connects to a PostgreSQL database and exposes various data discovery and querying capabilities as MCP tools. These tools allow you to explore database structure, query data, and get database statistics through a standardized interface.

  • Connect to any PostgreSQL database using a standard connection string
  • Execute custom SELECT queries with results returned in a structured format
  • List all tables in the connected database
  • Get detailed schema information for any table
  • Filter database records with simple equality conditions
  • Get database statistics including size, table count, and largest tables

Configuration and credentials

  • Python 3.7+ - Required Python packages (listed in requirements.txt): - mcp - pg8000 - sqlalchemy

More MCP options

Compare MCP servers by category, or browse hosted MCP servers if you prefer an endpoint over a local process.

Maintainer setup documentation.

Recorded tools

Check the linked publisher documentation and your connected client's tool list. Names and availability can vary with the server version and account permissions.

ToolWhat it does
execute_query
list_tables
get_table_schema
filter_instances
get_database_stats

How to install the PostgreSQL MCP Server

{
  "mcpServers": {
    "postgres": {
      "command": "python",
      "args": [
        "/ABOSLUTE/PATH/TO/postgres-mcp-server/server.py",
        "postgresql://user:password@host:port/database"
      ]
    }
  }
}

From the project documentation. Replace placeholders and example paths before connecting.

Configuration

  • Python 3.7+ - Required Python packages (listed in requirements.txt): - mcp - pg8000 - sqlalchemy

Example prompts to try

  • “Use PostgreSQL to execute query.”
  • “Use PostgreSQL to list tables.”
  • “Use PostgreSQL to get table schema.”

Frequently asked questions

Only SELECT queries are permitted to prevent database modifications. Connection credentials are provided via the command line and not stored.