mcp-postgres
Verified Safeby avantifellows
Overview
Provides a read-only Model Context Protocol (MCP) server for AI tools (like Claude Code, Cursor) to query a PostgreSQL database directly.
Installation
avanti-mcp-postgresEnvironment Variables
- AF_DB_HOST
- AF_DB_PORT
- AF_DB_USER
- AF_DB_PASSWORD
- AF_DB_NAME
Security Notes
The server implements robust read-only enforcement through the `is_read_only` function, which explicitly checks for and blocks all common write/destructive SQL keywords (INSERT, UPDATE, DELETE, DROP, ALTER, TRUNCATE, CREATE, GRANT, REVOKE). This check is applied to all `query` calls and even to the `WHERE` clause in `count_rows`. Database credentials are loaded securely from environment variables, preventing hardcoding. Table and schema names in `sample_data` and `count_rows` are dynamically inserted with identifier quoting to mitigate SQL injection risk, though direct parameterization of identifiers isn't standard in `asyncpg`. No `eval` or similar dangerous dynamic code execution is present. Queries are logged locally.
Similar Servers
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.
postgresql-mcp
Provides PostgreSQL database integration tools for LLM-powered coding agents using the Model Context Protocol.
dx-mcp-server
Empowers AI applications to interact with and query a user-provided Postgres database via the Model Context Protocol (MCP).
mcp-servers
This server integrates Redash with Cursor IDE to enable AI-powered management and interaction with Redash queries, dashboards, and visualizations for data analysis and reporting.