Back to Home
hisinha-rakesh icon

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

Run Command
python mcp_server_enterprise.py

Environment 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

Stats

Interest Score0
Security Score4
Cost ClassMedium
Avg Tokens300
Stars0
Forks0
Last Update2025-12-14

Tags

PostgreSQLFastAPILLMNatural Language ProcessingDatabase Management