Postgres icon

Postgres

Provides a safe, read-only interface for querying PostgreSQL databases following the Model Context Protocol.

About

pg-mcp is a PostgreSQL Model Context Protocol (MCP) server implemented in Go, designed to offer a secure, read-only interface for PostgreSQL databases. It enables safe execution of `SELECT` or `WITH` queries, preventing any destructive write operations like `INSERT`, `UPDATE`, `DELETE`, or `DROP`. The server also provides MCP tools for listing and describing tables, and supports both stdio and HTTP transport modes for flexible integration into various systems, from CLI agents to standalone services. It comes ready for Docker deployment, simplifying setup.

Key Features

  • Safe execution of `SELECT` and `WITH` queries only
  • Automatic blocking of destructive SQL operations (`INSERT`, `UPDATE`, `DELETE`, `DROP`, etc.)
  • Schema discovery when queries fail
  • Flexible transport modes: stdio for CLI/agent integration and HTTP for service exposure
  • Docker-ready with pre-built images for arm64 and amd64 architectures
  • 0 GitHub stars

Use Cases

  • Integrating PostgreSQL database access into CLI tools or external agents requiring secure, read-only interaction.
  • Exposing PostgreSQL data as a controlled HTTP API for reporting, analysis, or front-end applications.
  • Providing a safe sandbox for data exploration without risk of accidental modifications.