Skip to main content
Glama

Enterprise PostgreSQL MCP Server

by kd444

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.txt

2. 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.py

Cursor 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 database
  • database_info: Get database connection information
  • sql_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.

-
security - not tested
F
license - not found
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Enables secure read-only interactions with PostgreSQL databases through natural language. Provides database inspection, table listing, and SQL query execution with built-in security validation.

  1. Features
    1. Quick Start
      1. 1. Setup Environment
      2. 2. Configure Database
      3. 3. Test the Server
    2. Cursor Integration
      1. Available Tools
        1. Security
          1. Development
            1. License

              MCP directory API

              We provide all the information about MCP servers via our MCP API.

              curl -X GET 'https://glama.ai/api/mcp/v1/servers/kd444/postgres-mcp'

              If you have feedback or need assistance with the MCP directory API, please join our Discord server