clouddb-mcp
Provides read-only PostgreSQL diagnostics and safe query tooling: schema inspection, AST-validated SELECT queries with LIMIT enforcement, EXPLAIN/EXPLAIN ANALYZE, and health diagnostics for scans, dead tuples, and unused indexes.
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., "@clouddb-mcp inspect the schema and indexes for the orders table"
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.
clouddb-mcp
Local-first, guardrailed Model Context Protocol (MCP) server for read-only PostgreSQL diagnostics and AWS infrastructure auditing.
AI agents connected to databases and cloud APIs can generate destructive SQL (e.g., WITH d AS (DELETE ... RETURNING *) SELECT * FROM d), expensive queries, large data reads, and expose PII or secrets in LLM context windows.
clouddb-mcp applies SQL validation, read-only database transactions, query timeouts, row limits, and selected PII/secret redaction. These controls reduce risk but are not a replacement for least-privilege database/IAM permissions or a security review.
Architecture
flowchart LR
Agent["LLM / SRE Agent<br/>(Gemini 3.5 Flash-Lite / Claude / MCP Inspector)"]
MCP["clouddb-mcp Server<br/>(MCP Python SDK v2 — stdio / streamable-http)"]
subgraph Guardrails["Defense-in-Depth Guardrails"]
AST["sqlglot AST Validator<br/>- Blocks DDL/DML & CTE writes<br/>- Blocks DoS funcs & multi-stmt<br/>- Enforces LIMIT cap"]
Redactor["PII & Secret Redactor<br/>- Sensitive column masking<br/>- Regex: AKIA, JWT, sk_*, DSN, Email, Phone"]
Audit["Structured JSONL Audit Log<br/>logs/audit.jsonl + audit://recent/{limit}"]
end
subgraph Infra["$0 Local Infrastructure (Docker Compose)"]
PG["PostgreSQL 16<br/>SET TRANSACTION READ ONLY<br/>statement_timeout = 3000ms"]
Floci["Floci AWS Emulator (:4566)<br/>EC2, RDS, CloudWatch Logs, S3"]
end
Agent <-->|"JSON-RPC"| MCP
MCP --> AST --> PG
MCP --> Floci
PG --> Redactor --> MCP
Floci --> Redactor --> MCP
MCP --> AuditRelated MCP server: pgmoat
MCP Capabilities
Tools (8)
Tool | Target | Guardrail / Behavior |
| PostgreSQL | Lists tables, columns, data types, nullability, and indexes |
| PostgreSQL |
|
| PostgreSQL | Runs |
| PostgreSQL | Reports |
| AWS / Floci | Flags Security Groups exposing |
| AWS / Floci | Checks RDS status, public accessibility, storage encryption, and Multi-AZ |
| AWS / Floci | Fetches recent CloudWatch error logs and redacts leaked secrets/PII |
| AWS / Floci | Audits S3 buckets for default encryption, Block Public Access, public bucket policies, and ACL grants |
Resources & Prompts
Resource:
audit://recent/{limit}— Returns recent guardrail decisions, latency, and redaction counts (application/json).Prompt:
diagnose_slow_query(table_name)— Guided SRE workflow for diagnosing missing indexes without executing DDL.
Red-Team Security Evaluation
Every guardrail rule is verified by automated tests (tests/test_sql_guard.py, tests/test_pii_redactor.py, tests/test_mcp_e2e.py, tests/test_integration_live.py):
Attack / Risk Vector | Example Input / Payload | Result |
DDL / DML Mutation |
| Blocked by AST ( |
Sneaky Write CTE |
| Blocked by AST tree walk |
Multi-Statement Injection |
| Blocked (single-statement enforcement) |
DoS / File Read Functions |
| Blocked ( |
System Credential Tables |
| Blocked ( |
Unbounded Row Exfiltration |
| Rewritten to |
Leaked Secrets & PII |
| Masked with |
Legitimate String Literals |
| Allowed (no false positive on string literals) |
Zero-Cost Local Quickstart
Prerequisites
Python
>= 3.11&uvDocker & Docker Compose
Free Google AI Studio API key (
GEMINI_API_KEY) for the example agent (optional for runningpytest)
Safety: The Docker stack and seeded AWS findings are for local demonstration only. The AWS endpoint defaults to Floci, but changing it can direct audit calls to a real AWS account. Use appropriately restricted credentials and do not treat this project as production-ready without your own review.
1. Configure & Install
git clone https://github.com/Manishp16/clouddb-mcp.git
cd clouddb-mcp
cp .env.example .env
# Edit .env: add your GEMINI_API_KEY and set GEMINI_MODEL=gemini-3.5-flash-lite
uv sync --all-groups2. Start Local PostgreSQL 16 + Floci AWS
docker compose up -d
uv run python scripts/seed_floci.pyscripts/seed_postgres.sql creates customers (1,000 rows) and orders (50,000 rows without a customer_id index). scripts/seed_floci.py seeds an exposed Security Group (0.0.0.0/0 on ports 22 & 5432), an S3 bucket with public-access blocking disabled and a public-read bucket policy, and CloudWatch error logs containing intentionally synthetic examples of a leaked AWS key, DB URI, and email.
3. Run Security, Protocol & Integration Tests ($0 API Cost)
uv run ruff check src tests scripts examples
uv run pytest -v4. Run the Interactive SRE Agent
uv run python examples/gemini_agent.pySRE> Run an EC2 security audit and S3 audit, and summarize any CRITICAL exposure risks.
[tool] aws_ec2_security_audit({})
[tool] aws_s3_security_audit({})
-> Flags prod-db-exposed-sg (0.0.0.0/0 on ports 22 & 5432) and prod-ops-public-backups (PUBLIC_ACCESS_BLOCK_INCOMPLETE, PUBLIC_BUCKET_POLICY).
SRE> Check recent errors in /aws/eks/prod-api/app and tell me if any secrets were redacted.
[tool] aws_cloudwatch_recent_errors({'log_group': '/aws/eks/prod-api/app'})
-> Redacts 3 sensitive fields before LLM context: [REDACTED_EMAIL], [REDACTED_AWS_KEY], [REDACTED_DB_URI].
SRE> Check why querying orders by customer_id = 42 is slow using EXPLAIN ANALYZE, and recommend an exact index.
[tool] pg_inspect_schema({'schema_name': 'public'})
[tool] pg_explain_query({'analyze': True, 'sql': 'SELECT * FROM orders WHERE customer_id = 42;'})
-> Identifies Seq Scan on orders (49,950 rows filtered out, ~34ms) and recommends:
CREATE INDEX idx_orders_customer_id ON orders(customer_id);
SRE> Execute this SQL via pg_safe_query: WITH d AS (DELETE FROM orders RETURNING *) SELECT * FROM d
[tool] pg_safe_query({'sql': 'WITH d AS (DELETE FROM orders RETURNING *) SELECT * FROM d'})
-> Blocked by sqlglot AST guardrail (status: blocked_by_guardrail).5. (Optional) Inspect Visually with MCP Inspector
uv run mcp dev src/clouddb_mcp/server.pyAvailable Tools
8 toolsaws_cloudwatch_recent_errorsB
Fetch and secret-redact recent error events from a CloudWatch Log Group.
Inputs: log_group (required), limit, filter_pattern. Returns: object
aws_ec2_security_auditB
Audit EC2 instances and Security Groups for open 0.0.0.0/0 critical ports.
Inputs: no named parameters. Returns: object
aws_rds_healthC
Check RDS database instance status, encryption, Multi-AZ, and public exposure.
Inputs: db_identifier. Returns: object
aws_s3_security_auditA
List S3 buckets and verify whether default server-side encryption is configured.
Inputs: no named parameters. Returns: object
pg_explain_queryB
Run EXPLAIN (or EXPLAIN ANALYZE inside a read-only txn) on a validated SELECT query.
Inputs: sql (required), analyze. Returns: object
pg_health_diagnosticsB
Inspect PostgreSQL sequential scan heavy tables, dead tuples, and unused indexes.
Inputs: no named parameters. Returns: object
pg_inspect_schemaB
Inspect PostgreSQL tables, columns, data types, and indexes for a schema.
Inputs: schema_name. Returns: object
pg_safe_queryA
Execute a read-only, AST-validated PostgreSQL SELECT query with PII redaction.
Inputs: sql (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool targets a distinct resource+action: schema inspection, read-only querying, EXPLAIN plans, and health diagnostics are clearly separated within the PostgreSQL family, and the AWS tools map to distinct services (EC2, RDS, CloudWatch, S3). The pg_safe_query vs pg_explain_query boundary is clear from descriptions (execute vs explain a validated SELECT). No overlaps that would cause misselection.
Names follow a predictable provider_resource_action pattern (pg_* and aws_*) in consistent snake_case throughout. Minor deviations exist in the action vocabulary (inspect, safe_query, health_diagnostics, health), so it is not perfectly uniform but remains highly readable.
Eight tools are well-scoped for a cloud database auditing server, with four PostgreSQL tools and four AWS audit tools each earning their place. No redundant or filler tools.
The read-only auditing surface is coherent and covers schema inspection, querying, planning, and key AWS security checks. Minor gaps exist (no schema/database listing, no CloudWatch metrics beyond errors), but agents can work around them for the stated audit purpose.
Maintenance
Related MCP Connectors
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.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Governed SQL access to your databases: redaction, query review and an audit log.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables AI agents to query PostgreSQL databases securely with read-only defaults, PII masking, rate limiting, and human-approved, expiring mutation tokens.91Apache 2.0
- AlicenseNot gradedqualityBmaintenanceGives AI agents read-only access to Postgres with parser-checked queries, hidden tables and columns, row limits and timeouts, caller-bound Row-Level Security, and a tamper-evident audit log.MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to safely explore and query SQL databases through read-only, AST-checked SQL, database-enforced read-only transactions, timeouts, row caps, PII masking, and audit logging.MIT
- AlicenseNot gradedqualityCmaintenanceGives AI agents safe, read-only access to production Postgres, Sentry, and GitHub data, with SELECT-only SQL, PII redaction, and prompt-injection protections.1MIT