PostgreSQL MCP AllAccess

Production-ready PostgreSQL MCP server with global connection pooling, PgBouncer integration, and automatic password rotation for AWS RDS
  • python

0

GitHub Stars

python

Language

7 months ago

First Indexed

3 months ago

Catalog Refreshed

Documentation & install

Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.

Installation

Add the following to your MCP client configuration file.

Configuration

View docs

You run a production-ready PostgreSQL MCP server that provides global connection pooling, PgBouncer integration, and automatic password rotation for AWS RDS. It scales across many Claude sessions while keeping PostgreSQL connections limited and efficiently reused.

How to use

Connect clients to the MCP server to execute SQL queries, manage schemas, and analyze performance. The server routes queries through a lightweight pool (max 15 connections by default) and uses PgBouncer to enforce that limit. If you deploy with AWS Secrets Manager, credentials rotate automatically without downtime, keeping connections stable. You can start from two deployment paths: AWS Secrets Manager or simple credentials via a local environment.

How to install

Prerequisites: make sure you have Python 3 installed for the AWS deployment path and Docker with docker-compose installed for the local path.

# AWS Secrets Manager path (deployment script, then start via client)
export AWS_ACCESS_KEY_ID=your_key
export AWS_SECRET_ACCESS_KEY=your_secret
export AWS_REGION=us-west-2

# Deploy (fetches DB credentials from AWS)
python3 deploy_with_aws_secrets.py

# After deployment, start Claude Code to connect at the URL shown by the deploy script

# Optional: set custom AWS secret names and redeploy
export AWS_SECRET_NAME=your/secret/name
export AWS_PASSWORD_SECRET_NAME=rds!your-password-id
python3 deploy_with_aws_secrets.py

# Local path without AWS

# 1. Copy environment template and fill in credentials
cd /path/to/postgres_mcp_allaccess
cp .env.example .env
# Edit .env and fill in the REQUIRED fields (first 5 lines)

# 2. Deploy (docker-compose reads .env automatically)
docker-compose up -d

# 3. Start Claude Code to connect at the URL shown by the deployment

Configuration and operation

Key features include global connection pooling with a maximum pool size you configure, automatic password rotation driven by AWS Secrets Manager, and efficient transaction-level pooling. PgBouncer enforces the connection limit to PostgreSQL, while extra requests queue and execute when connections free up. The system requires no manual session management; it handles pooling and rotation automatically.

# PgBouncer pool configuration (example)
# This file is located at pgbouncer/pgbouncer.ini

# max connections to PostgreSQL
default_pool_size = 15
min_pool_size = 2
pool_mode = transaction

Health, logs, and maintenance

# Health check endpoint
curl http://localhost:3000/health
# Expected: OK - Pool: 2/15 connections

# View logs
docker-compose logs -f

# Stop server
docker-compose down

# Change connection limits
# Edit pgbouncer/pgbouncer.ini and redeploy

Automatic password rotation

When AWS rotates your password, the MCP detects the auth failure on the next query, fetches the new password from AWS Secrets Manager, updates the MCP pool and PgBouncer, and retries the query with zero downtime. This requires deploying with AWS Secrets Manager and having AWS secret names configured.

Security and best practices

Never commit sensitive data. Keep .env files, log files, and internal config out of version control. It is safe to commit AWS secret names and database hostnames as they are not sensitive by themselves.

Troubleshooting

If Claude Code cannot connect after deployment, restart Claude Code to establish the connection. If you see a "Pool not initialized" error, make at least one query to initialize the pool. For container startup issues, inspect logs with docker-compose logs and adjust ports or credentials as needed. If you need to refresh credentials manually, restart the deployment stack.

Notes and tips

  • The system supports two deployment paths: AWS Secrets Manager based deployment and a simple docker-compose deployment using local credentials. Choose the path that fits your environment.

Examples and quick references

# AWS path (deploy and connect)
export AWS_ACCESS_KEY_ID=your_key
export AWS_SECRET_ACCESS_KEY=your_secret
export AWS_REGION=us-west-2
python3 deploy_with_aws_secrets.py
# URL will be shown; connect at http://localhost:3000/sse

# Local path (no AWS)
cd /path/to/postgres_mcp_allaccess
cp .env.example .env
# Edit .env with required values
docker-compose up -d

Additional notes

Configuration details include environment variables controlling pool size and timeout, and PgBouncer settings for max connections and pool mode. The system is designed for production use with health checks, logging, and monitoring built in.

Available tools

list_tables

List tables in a schema.

execute_query

Run any SQL query.

describe_table

See table structure.

execute_file

Run SQL from a file.

list_schemas

List all schemas.

search_tables

Find tables by name pattern.

get_database_context

Overview of database structure.

explain_query

Get query execution plan.

analyze_query

Performance analysis.

suggest_indexes

Index recommendations.

get_session_info

Current session status.

get_query_history

View query history.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational
PostgreSQL MCP AllAccess MCP Server - yty-build/postgres_mcp_allaccess | VeilStrat