MCP PostgreSQL Demo MCP Server

Postgres MCP server

Local serverstdioPython

What is the MCP PostgreSQL Demo MCP Server?

Postgres MCP server

What it actually does

A FastMCP server that enables LLMs to connect and interact with PostgreSQL databases. This project demonstrates how to use the Model Context Protocol (MCP) to allow Language Models to query and explore database schemas and tables.

  • Schema Exploration — Retrieve metadata about database schemas
  • Table Inspection — Get detailed information about table structures
  • Database Querying — Execute SQL queries against the database
  • YAML Formatting — Results are returned in YAML format for easy consumption by LLMs

Configuration

  • Python 3.12 or higher - PostgreSQL database - UV package manager (recommended)

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
query_databaseExecute SQL queries against the database (SELECT queries only)

How to install the MCP PostgreSQL Demo MCP Server

{
  "mcpServers": {
    "postgres-mcp-server": {
      "command": "/path/to/your/venv/bin/mcp",
      "args": ["run", "/path/to/your/postgres-mcp/src/main.py"],
      "env": {
        "APP_NAME": "mcp-demo",
        "DB_HOST": "localhost",
        "DB_PORT": "5432",
        "DB_USER": "postgres",
        "DB_PASSWORD": "postgres",
        "DB_NAME": "postgres"
      }
    }
  }
}

Configuration as documented by the project. Restart the client after saving.

Configuration

  • Python 3.12 or higher - PostgreSQL database - UV package manager (recommended)
VariableDescriptionRequired
APP_NAMEConfiguration value read at startup.Optional
DB_HOSTEndpoint or connection string the server talks to.Optional
DB_PORTConfiguration value read at startup.Optional
DB_USERConfiguration value read at startup.Optional
DB_PASSWORDConfiguration value read at startup.Optional
DB_NAMEConfiguration value read at startup.Optional

Example prompts to try

  • “Use MCP PostgreSQL Demo to query database.”

Frequently asked questions

Python 3.12 or higher, a PostgreSQL database, and UV package manager (recommended).