MCP PostgreSQL Demo MCP Server

Postgres MCP server

Local serverstdioPython

What is the MCP PostgreSQL Demo MCP server?

Postgres MCP server. Exposed over MCP by the mcp postgresql demo mcp server, that capability becomes something an assistant can invoke while it works, not something you go and do afterwards.

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

Adding it to your client

Setup follows the usual MCP pattern — install or clone the server, register it in your client's configuration file, restart the client. The configuration blocks on this page cover the common clients.

Its toolset

Everything the assistant can do here goes through one of these:

  • query_database — Execute SQL queries against the database (SELECT queries only)

Configuration

You will need 6 environment variables: APP_NAME, DB_HOST, DB_PORT, DB_USER, DB_PASSWORD, DB_NAME. Keep credentials in your client's env block or a secrets manager rather than in a file you might commit.

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

Caveats

  • It runs with your machine's permissions. That is convenient and also the reason to think about what you point it at before you approve a tool call.
  • MCP clients confirm each tool call by default. Leave that on until you have watched what the mcp postgresql demo mcp server does with a few real requests.

When to reach for it

Plenty of database access servers cover similar ground. The differences that matter in practice are scope of access and how much setup stands between you and a working tool call. MCP PostgreSQL Demo's toolset — query_database — is a fair guide to whether it matches your workflow. It is maintained by Tibiritabara; worth a glance at recent repository activity before you build anything load-bearing on it.

SyncDev reviews every entry in this directory against the project's own documentation before publishing, and revisits them as servers change.

Available tools

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).