mcp-postgres-server
Verified Safeby carlosealves2
Overview
MCP server for read-only PostgreSQL database access, enabling AI assistants to securely query databases.
Installation
bunx @carlos.e.alves3/mcp-postgres-serverEnvironment Variables
- POSTGRES_HOST
- POSTGRES_DATABASE
- POSTGRES_USER
- POSTGRES_PASSWORD
- POSTGRES_PORT
- POSTGRES_MAX_CONNECTIONS
- POSTGRES_INSECURE
- SSH_TUNNEL_ENABLED
- SSH_HOST
- SSH_PORT
- SSH_USERNAME
- SSH_PASSWORD
- SSH_PRIVATE_KEY_PATH
- SSH_PRIVATE_KEY
- SSH_PASSPHRASE
- SSH_LOCAL_PORT
- LOG_LEVEL
- LOG_FORMAT
Security Notes
The server implements robust read-only query validation, blocking common SQL injection keywords (e.g., INSERT, UPDATE, DROP) and patterns (e.g., INTO OUTFILE, LOAD DATA). Queries are normalized by removing comments and excessive whitespace, and are limited by length (10,000 characters) and execution timeout (30 seconds). Internal tools (list_tables, describe_table) utilize parameterized queries. An optional 'insecure mode' allows write operations for development, but it's off by default and logs clear warnings when enabled. SSH tunneling is supported for secure remote connections, with various authentication methods. All credentials are sourced from environment variables, preventing hardcoding. A high score due to explicit and well-tested security measures, but not 10 as no system is perfectly impenetrable.
Similar Servers
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.
dx-mcp-server
Empowers AI applications to interact with and query a user-provided Postgres database via the Model Context Protocol (MCP).
metabase-ai-assistant
The Metabase AI Assistant integrates an AI agent with Metabase to enable AI-powered data exploration, SQL generation, dashboard creation, and Metabase instance management through an MCP client.
mcp-postgres
Provides a read-only Model Context Protocol (MCP) server for AI tools (like Claude Code, Cursor) to query a PostgreSQL database directly.