PostgreSQL

Provides read-only access to PostgreSQL schemas and data through MCP tools for safe model inspection and queries.
  • javascript

0

GitHub Stars

javascript

Language

7 months ago

First Indexed

3 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "hsinyuyen-my-postgres-mcp": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "mcp/postgres",
        "postgresql://host.docker.internal:5432/mydb"
      ]
    }
  }
}

You expose a read-only Model Context Protocol server for PostgreSQL that lets language models inspect database schemas and run safe, read-only queries. This server is designed to help you explore your PostgreSQL data structures and perform lightweight reads without modifying the data.

How to use

You connect to the PostgreSQL MCP Server through either a local stdio process or a containerized Docker/NPX workflow. The server provides two capabilities: inspecting per-table schemas and executing read-only queries through a dedicated query tool. Use this to let models understand table structures and retrieve data without changing anything in the database.

Key usage patterns include: exploring table columns and data types to inform prompt design, and performing SELECT queries within a READ ONLY transaction to fetch small datasets for reasoning or validation. All query executions occur inside a read-only context to prevent any data modification.

How to install

# Docker option
docker build -t mcp/postgres -f src/postgres/Dockerfile . 
# NPX option
npx -y @modelcontextprotocol/server-postgres postgresql://localhost/mydb

Configuration and notes

There are two explicit MCP startup options you can use to run this server. Both are shown as code blocks in the usage section.

{
  "mcpServers": {
    "postgres": {
      "command": "docker",
      "args": [
        "run", 
        "-i", 
        "--rm", 
        "mcp/postgres", 
        "postgresql://host.docker.internal:5432/mydb"]
    }
  }
}
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://localhost/mydb"
      ]
    }
  }
}

Examples

Use the Docker option when you want to ship a self-contained container for your PostgreSQL MCP Server. Use the NPX option for a quick local run without building a container image. In both cases, replace the database URL with your target database and ensure network accessibility from your MCP client.

Security and limitations

Only read operations are allowed through the query tool. Ensure appropriate access controls so that the MCP client can connect to the PostgreSQL instance. Do not perform write or DDL statements through this server.

Available tools

query

Execute read-only SQL queries against the connected database within a READ ONLY transaction.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational