Back to Home
sequenzia icon

pg-mcp-server

Verified Safe

by sequenzia

Overview

Enables LLMs to interact with PostgreSQL databases for progressive schema discovery and read-only query execution.

Installation

Run Command
uv run pg-mcp-server

Environment 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

Stats

Interest Score0
Security Score9
Cost ClassMedium
Avg Tokens1500
Stars0
Forks0
Last Update2026-01-19

Tags

PostgreSQLLLMDatabaseMCPPythonSQLSchema DiscoveryQuery Execution