postgresql-mcp-server
by hisinha-rakesh
Overview
Manage and interact with a PostgreSQL database using natural language queries, enabling full DDL, DML, TCL, and backup/restore operations via an AI assistant.
Installation
python mcp_server_enterprise.pyEnvironment Variables
- DATABASE_URL
- AZURE_API_KEY
- AZURE_ENDPOINT
- DEPLOYMENT_NAME
- DEFAULT_BACKUP_DIR
Security Notes
The application is a proof-of-concept for executing LLM-generated SQL, which is inherently dangerous. While the 'enterprise' server attempts to use structured tool calls with parameters for DML operations (reducing direct SQL injection risk), DDL operations still involve the LLM generating raw SQL which is then executed. The server also uses `subprocess.run` for `pg_dump`/`pg_restore` which, if arguments are not perfectly sanitized, could be vulnerable to command injection (though efforts are made to pass arguments safely). The project README explicitly highlights these critical security risks and strongly advises against production use without significant safeguards like human-in-the-loop validation, least privilege database users, and sandboxing.
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.
redd-archiver
Archiving and providing AI-optimized access to Reddit-like platform data via a PostgreSQL-backed system and a RESTful API.
MCP-PostgreSQL-Ops
The MCP server provides professional operations, monitoring, and management capabilities for PostgreSQL databases using natural language queries.
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.