pg-mcp-server
Verified Safeby sequenzia
Overview
Enables LLMs to interact with PostgreSQL databases for progressive schema discovery and read-only query execution.
Installation
uv run pg-mcp-serverEnvironment Variables
- PG_HOST
- PG_PORT
- PG_DATABASE
- PG_USER
- PG_PASSWORD
- PG_POOL_SIZE
- PG_STATEMENT_TIMEOUT
- PG_DEFAULT_SCHEMA
- MCP_TRANSPORT
- MCP_HOST
- MCP_PORT
- MCP_LOG_LEVEL
- MCP_LOG_FORMAT
Security Notes
The server implements robust security measures for database interaction, including: - Explicitly read-only design with comprehensive blocking of write/DDL/transaction keywords (INSERT, UPDATE, DELETE, DROP, CREATE, ALTER, etc.). - Enforcement of parameterized queries ($1, $2, etc.) to prevent SQL injection. - Database passwords loaded from environment variables/dotenv and handled as Pydantic `SecretStr`. - Configurable statement timeouts to prevent runaway queries. The primary area not covered (per MVP non-goals) is explicit authentication/authorization for the MCP server itself, which is a common consideration for networked services.
Similar Servers
mcp-server-neon
The Neon MCP Server allows users to interact with and manage their Neon Postgres databases using natural language commands, acting as a bridge between AI agents/LLMs and the Neon API and database operations.
MCP-PostgreSQL-Ops
The MCP server provides professional operations, monitoring, and management capabilities for PostgreSQL databases using natural language queries.
DBchat
Transforms a database into an intelligent conversational partner, enabling natural language queries, instant answers, and data visualizations via MCP clients.
enhanced-postgres-mcp-server
This server acts as a Model Context Protocol interface for PostgreSQL, enabling LLMs to query data, modify records, and manage database schema objects with read and write capabilities.