Enterprise PostgreSQL MCP Server
Provides tools for PostgreSQL database interactions including listing tables, retrieving database information, and executing read-only SQL queries with security-first validation
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Enterprise PostgreSQL MCP Serverlist all tables in the production database"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Enterprise PostgreSQL MCP Server v2
A production-ready Model Context Protocol (MCP) server for PostgreSQL database interactions.
Features
✅ Working MCP Server: Simple and reliable PostgreSQL MCP implementation
✅ Read-only by Default: Security-first approach with query validation
✅ Multiple Tools: Database listing, table inspection, and SQL queries
✅ Cursor Integration: Ready for Cursor IDE integration
✅ FastMCP Support: Both simple and FastMCP implementations included
Quick Start
1. Setup Environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt2. Configure Database
Set your PostgreSQL connection string:
export PG_DSN="postgresql://postgres:@localhost:5432/your_database"3. Test the Server
# Test simple MCP server
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' | python enterprise_mcp_server.py
# Test list_tables tool
echo '{"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "list_tables", "arguments": {}}}' | python enterprise_mcp_server.pyCursor Integration
Add to your Cursor MCP configuration (~/.cursor/mcp.json):
{
"mcpServers": {
"enterprise-postgres": {
"command": "/path/to/venv/bin/python",
"args": ["/path/to/enterprise_mcp_server.py"],
"env": {
"PG_DSN": "postgresql://postgres:@localhost:5432/your_database"
}
}
}
}Available Tools
list_tables: List all tables in the databasedatabase_info: Get database connection informationsql_query: Execute read-only SQL queries (SELECT, WITH, EXPLAIN, SHOW)
Security
Read-only queries only (INSERT, UPDATE, DELETE blocked)
Query validation and sanitization
Connection string masking in responses
Transaction-based execution with rollback
Development
Built with:
Python 3.13+
asyncpg for PostgreSQL connectivity
FastMCP for enhanced MCP features
JSON-RPC 2.0 protocol compliance
License
MIT License - see LICENSE file for details.
Related MCP Connectors
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Deterministic safety, correctness & cost gate that vets Postgres SQL before your AI agent runs it.
Generate, fix, explain and run read-only SQL on PostgreSQL, MySQL and SQL Server