Skip to content

Add PostgreSQL DBA MCP server#31

Open
viveksingh112 wants to merge 2 commits into
aws-samples:mainfrom
viveksingh112:feature/postgresql-dba-mcp
Open

Add PostgreSQL DBA MCP server#31
viveksingh112 wants to merge 2 commits into
aws-samples:mainfrom
viveksingh112:feature/postgresql-dba-mcp

Conversation

@viveksingh112

Copy link
Copy Markdown

Summary Adds a query-allowlist MCP server for AWS DevOps Agent that provides safe, read-only diagnostic access to Amazon RDS and Aurora PostgreSQL instances. ## What it does - 10 tools, 39 predefined diagnostic queries across 11 categories - Covers: health check, parameter tuning, pre-upgrade validation, SQL tuning, vacuum analysis, index optimization, replication health - Lambda + FastMCP + pg8000 with Streamable HTTP transport - SAM template for one-command deployment (VPC + Secrets Manager + Lambda Web Adapter) - Tool-level instance/database allowlists for defense-in-depth - Production enforcement (wildcard allowlists blocked in prod stage) ## Security model - Query-allowlist approach — no dynamic SQL, only 39 predefined read-only queries - Credentials from AWS Secrets Manager (never exposed) - VPC deployment for database connectivity - Read-only database user with SELECT-only privileges ## Testing - Validated 30/30 queries across RDS PostgreSQL 15, RDS PostgreSQL 16, and Aurora PostgreSQL 16 - Registered and tested end-to-end with AWS DevOps Agent AgentSpace via SigV4 - All 10 tools verified working in DevOps Agent chat interface - Unit tests for allowlist integrity and SQL safety validation (13/13 passing) ## Structure mcp/postgresql-dba-mcp/ ├── README.md ├── LICENSE ├── template.yaml # SAM deployment template ├── src/ │ ├── server.py # FastMCP server with all tools and queries │ └── run.sh # Lambda Web Adapter entry point ├── layers/dependencies/ │ ├── requirements.txt # fastmcp, pg8000, boto3 │ └── Makefile # Layer build └── tests/ ├── test_allowlist.py # Unit tests └── e2e_test.py # End-to-end test framework

…fe, read-only diagnostic access to Amazon RDS and Aurora PostgreSQL instances via AWS DevOps Agent. - 10 tools, 39 predefined queries across 11 diagnostic categories - Covers health check, parameter tuning, pre-upgrade validation, SQL tuning - Lambda + FastMCP + pg8000 with Streamable HTTP transport - SAM template for one-command deployment (VPC + Secrets Manager) - Tool-level instance/database allowlists for defense-in-depth - Tested across RDS PG15, PG16, and Aurora PG16
…Consolidates 8 diagnostic features into a single SKILL.md per reviewer feedback. Includes decision trees, thresholds, patterns, and DBA safety rules for: health check, vacuum/bloat, parameter tuning, index optimization, pre-upgrade validation, SQL plan analysis, replication health, and connection/lock troubleshooting. Key guardrails baked in: - Never VACUUM FULL (use pg_repack) - Always CREATE INDEX CONCURRENTLY - Aurora vs RDS parameter differences - Never kill autovacuum workers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant