mav-postgresql-mcp-server
Verified Safeby derricksiawor
Overview
Provides a Model Context Protocol (MCP) interface for programmatic access and management of PostgreSQL databases, including schema querying, data manipulation (optional), and database-specific features like JSONB and extensions.
Installation
node build/index.jsEnvironment Variables
- PG_HOST
- PG_PORT
- PG_USER
- PG_PASSWORD
- PG_DATABASE
- PG_SCHEMA
- PG_SSL_MODE
- PG_SSL_REJECT_UNAUTHORIZED
- PG_SSL_CA_PATH
- PG_SSL_CERT_PATH
- PG_SSL_KEY_PATH
- PG_SSL_MIN_VERSION
- ALLOW_WRITE_OPERATIONS
- CONNECTION_LIMIT
- QUERY_TIMEOUT
- MAX_RESULTS
- RATE_LIMIT_PER_MINUTE
- RATE_LIMIT_PER_HOUR
- RATE_LIMIT_CONCURRENT
- MCP_DEBUG
Security Notes
The server demonstrates strong security practices: - Comprehensive `validateQuery` function blocks dangerous SQL patterns (file system ops, permission changes, admin commands, external network ops, extension ops). - Crucially, all read-only queries are wrapped in `BEGIN TRANSACTION READ ONLY` to enforce read-only access at the database level, preventing accidental or malicious writes. - Identifiers (table, column, schema names) are validated and escaped using `safeIdentifier` to prevent SQL injection for these elements. - Sensitive system tables (e.g., `pg_authid`) are explicitly blocked. - Configurable rate limiting, query timeouts, and max results prevent resource exhaustion and data exfiltration. - Credentials are loaded from environment variables, avoiding hardcoded secrets. - Full SSL/TLS support with configurable modes and certificate paths is available. - Audit logging tracks all database operations, especially writes. The only minor point of improvement could be stronger blocking for 'sensitive patterns' rather than just warnings, depending on the operational context, but the overall approach is excellent.
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.
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.
postgres-mysql-mcp-server
A Model Context Protocol (MCP) server that enables AI assistants to query PostgreSQL and MySQL databases for schema introspection and data retrieval.
dx-mcp-server
Empowers AI applications to interact with and query a user-provided Postgres database via the Model Context Protocol (MCP).