Postgres-MCP-Server
by srneha24
Overview
Provides secure read-only access to PostgreSQL databases for AI assistants and MCP clients to query schemas and execute SELECT queries.
Installation
python main.pyEnvironment Variables
- DB_HOST
- DB_PORT
- DB_NAME
- DB_USER
- DB_PASSWORD
Security Notes
The server has a critical SQL injection vulnerability in `get_database_schema`, `get_database_schema_with_indexes`, and `list_tables` functions. The `schema` parameter is directly interpolated into SQL queries using f-strings without sanitization, allowing an attacker to inject arbitrary SQL. Although the `query_database` tool blocks certain DML/DDL keywords, this protection does not apply to the `schema` parameter in the affected schema inspection functions. No 'eval' or hardcoded secrets were found.
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.