PGAutoPilot
Provides tools to query, aggregate, insert, update, delete, and manage PostgreSQL databases using natural language, with schema-aware generation and safety controls.
Click on "Install 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., "@PGAutoPilotShow me customers that spent more than $500."
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.
PGAutoPilot is a production-ready PostgreSQL MCP server that lets any AI assistant safely interact with PostgreSQL using natural language. It combines schema-aware query generation, enterprise safety controls, and a minimal-configuration setup into a single executable.
Model-agnostic PostgreSQL-optimized Safe writes Read-only mode
Minimal config Single executable Docker Cloud databases
Connection pool Production-ready SSL Schema inspectionContents
Related MCP server: Postgres Scout MCP
Requirements
Requirement | Details |
Node.js | 18+ |
PostgreSQL | 12+ (local, remote, Docker, or cloud) |
MCP client | Any MCP-compatible assistant or editor |
Optional | Docker, |
Supported MCP Clients
Client | Status |
Claude Desktop | ✅ |
Cursor | ✅ |
VS Code + Copilot | ✅ |
Gemini CLI | ✅ |
Windsurf | ✅ |
Zed | ✅ |
JetBrains | ✅ |
Continue | ✅ |
Cline | ✅ |
Roo Code | ✅ |
Neovim | ✅ |
Who is this for?
Audience | PGAutoPilot answers |
Developers | Instantly query databases in plain English from your editor |
Staff Eng | Verifiable architecture, safety by default, deterministic paths |
DBAs | Read-only mode, blocked tables, redacted secrets, audit-ready |
Security | Encrypted data, no SQL injection, no credential exposure |
Maintainers | Minimal codebase, strict TypeScript, modular safety layer |
Design Principles
Safety before convenience.
Natural language before SQL.
No vendor lock-in.
Minimal dependencies.
Deterministic behavior.
Schema-aware generation.
Fail closed, not open.
Minimal configuration.
Protocol-first architecture.Demo
You: "Show me customers that spent more than $500."
-> db_aggregate(table="orders", by="customer_id", _sum="total",
orderBy={"_sum/total": "desc"}, take=5)
<- 23 customers found
Assistant: "23 customers have spent more than $500. The top spender is..."Quick Start
1. Install
npm install -g pgautopilotNo npm? Use the one-line installer.
2. Point it at your database
Create a .env file anywhere on your machine:
DATABASE_URL=postgresql://user:password@localhost:5432/yourdbPGAutoPilot finds .env automatically from the current directory.
Connection string examples:
Where | URL |
Localhost |
|
Remote server |
|
Docker (port-mapped) |
|
Neon |
|
Supabase |
|
AWS RDS |
|
Render |
|
3. Connect your AI assistant
{ "mcpServers": { "postgres": { "command": "pgautopilot" } } }Identical config for VS Code, Cursor, Windsurf, Claude Desktop, Zed, JetBrains, Neovim.
4. Start asking questions
"Show me all tables." "How many users signed up this month?" "Find orders over $500 grouped by customer." "Add a new product called 'Widget Pro' at $29.99."
Install without npm
You need only Node.js 18+ and a browser or Git.
One-line installer:
Platform | Command |
Linux/mac |
|
Windows |
|
Clones into ~/.pgautopilot (Linux/macOS) or %LOCALAPPDATA%\pgautopilot (Windows) and adds pgautopilot to your PATH. Run the same command again to update.
Download & run:
node pgautopilot.bundle.cjsClone & run:
git clone https://github.com/cyberreinxy/pgautopilot.git
cd pgautopilot
node dist/pgautopilot.bundle.cjsUninstall:
Platform | Command |
Linux/mac |
|
Windows |
|
Removes the launcher, deletes the installation directory, and cleans up PATH entries. Idempotent — safe to run even when PGAutoPilot isn't installed.
Why PGAutoPilot
Existing database MCP servers usually expose raw SQL directly, offer little protection against destructive operations, or require extensive manual configuration. PGAutoPilot takes a different approach:
Schema-aware — introspects your live database and validates every identifier before it touches SQL
Production-first — every write path is guarded by multiple configurable safety layers
AI-friendly — tools are designed for natural-language workflows, not SQL terminals
Model-agnostic — works identically with Claude, GPT-4o, Gemini, DeepSeek, Copilot, and open-source models
Safety by default — sensitive columns are redacted, bulk operations warn, and deletes require confirmation
Features
Category | Features |
Querying | Search, filter, aggregate, paginate, raw SELECT |
Writing | Insert, update, delete, upsert |
Safety | Read-only mode, secret redaction, schema validation |
Infrastructure | Docker, SSL, connection pooling, backups |
AI | MCP protocol, natural language, schema-aware generation |
Compatibility | Every major editor, all PostgreSQL 12+, all Node 18+ |
Architecture
AI Assistant
(Claude / Cursor / GPT / Gemini)
|
v
MCP Protocol
|
v
+----------------------------------+
| PGAutoPilot |
| |
| Schema Discovery |
| Identifier Validation |
| Safety Policy Engine <----+ |
| SQL Builder | |
| Connection Pool | |
| Tool Handlers (14 tools) | |
+---------------------------------+ |
| |
v |
PostgreSQL Everything passes through safetyHow a request flows
Natural language
-> MCP tool request
-> Parameter validation (Zod)
-> Live schema lookup
-> Identifier validation
-> Safety policy evaluation
-> Parameterized SQL generation
-> Query execution (time-limited)
-> Response formatting
-> AI assistant presents resultEvery step is deterministic. No hidden state. No side effects.
Safety
Threat model
PGAutoPilot runs on your machine and connects to your database over the PostgreSQL wire protocol. The AI assistant communicates only through the MCP protocol, and every request passes through the safety layer before reaching PostgreSQL. The DATABASE_URL credential is the sole authentication boundary.
Safety features
Threat | Protection |
SQL injection | Parameterized queries (never string interpolation) |
Accidental delete-all |
|
Full table update | Warning on >10 rows affected |
Secret exposure | Automatic redaction on read + strip on write |
Unknown table/column | Live schema validation before query build |
Slow queries | Configurable statement timeout (default 10s) |
Connection exhaustion | Configurable pool limit (default 5) |
Arbitrary SQL |
|
Dangerous Postgres fns | Blocked: |
Bulk data loss | Dry-run support on every write tool |
Operational guarantees
Never logs
DATABASE_URL(only the hostname appears in the startup banner)Never exposes redacted fields (passwords, tokens, keys return
***REDACTED***)Never executes multiple SQL statements in one call
Never allows
UPDATEwithout identifier validation (table + column checked against live schema)Never allows
DELETE ALLwithout explicitconfirmAll: trueNever runs raw
INSERT,UPDATE, orDELETESQL (use the structured tools)Never bypasses schema validation
Never opens more connections than
PGPOOL_MAX
Production recommendations
Enable
--readonlyfor read replicas and analytics environmentsBlock sensitive tables with
BLOCKED_TABLESConfigure
PGSSLMODE=requirefor cloud databasesUse a dedicated database user with minimal required permissions
Add custom sensitive columns via
SENSITIVE_COLUMNSSet
PG_STATEMENT_TIMEOUT_MSto match your SLARun in
--mode=productionto suppress per-request logging
Read-only mode
pgautopilot --readonlyBlocks every write operation. Ideal for read replicas, analytics databases, and any read-only environment.
Blocked tables
BLOCKED_TABLES=users,refresh_tokens pgautopilotRefuses all writes to specific tables, independent of --readonly.
Sensitive columns
Columns matching password, token, secret, api_key, private_key, ssn, credit_card, cvv (and variants) are automatically redacted on read and stripped on write. Extend with SENSITIVE_COLUMNS.
Security
Responsible disclosure — if you discover a security vulnerability, report it privately via GitHub Security Advisories. Please avoid opening a public issue until the vulnerability has been addressed.
Threat model — see Threat model above; the database URL is your credential boundary.
Cryptographic verification — every release is SHA-256 checksummed and GPG-signed.
Dependency policy — zero runtime dependencies in the bundled build.
Logging policy — connection strings are never logged; per-request logging is disabled in production mode (
--mode=production).Authentication — handled entirely by the
DATABASE_URLcredential. PGAutoPilot does not manage users or tokens.Production recommendation — use a dedicated read-only database user with minimal permissions.
Tools
Read tools
Tool | Use when... | Returns |
| "What's in this database?" | All tables, row counts, relationships |
| "What columns does each table have?" | Full column/type/constraint map |
| "Is the connection working?" | Pool usage, uptime, latency |
| "Tell me about the orders table" | Columns, indexes, row estimates, size |
| "Show recent orders", "Find inactive users" | Filtered, sorted, paginated rows |
| "Get user with ID 42" | Single matching row |
| "How many users signed up this week?" | Row count (all or filtered) |
| "Total sales by category", "Average order value" | Grouped aggregates (count, sum, avg, min, max) |
| "I need a custom SELECT" | Raw query results (SELECT-only, limited to 5000 rows) |
Write tools
Tool | Use when... | Safety |
| "Add a new user" | Dry-run supported, schema-validated |
| "Create or update this product" | Dry-run supported, conflict-safe |
| "Update all shipped orders" | Warns on >10 rows, dry-run supported |
| "Delete old logs" | Warns on >10 rows, |
Maintenance tools
Tool | Use when... | Output |
| "Back up the database" | Full SQL dump via |
Examples
Find recent orders for a customer:
Prompt: "Show me the last 10 orders for customer 42"
Tool: db_find_many(table="orders", where={"customer_id": 42},
select=["id","total","status","created_at"],
orderBy={"created_at":"desc"}, take=10)
SQL: SELECT id, total, status, created_at FROM orders
WHERE customer_id = $1 ORDER BY created_at DESC LIMIT 10
Result: 10 rows returnedCount products by category:
Prompt: "How many products in each category?"
Tool: db_aggregate(table="products", by="category", _count="*",
take=5, orderBy={"_count": "desc"})
SQL: SELECT category, COUNT(*) FROM products
GROUP BY category ORDER BY COUNT(*) DESC LIMIT 5
Result: Electronics: 142, Clothing: 89, Books: 54, ...Add a new user (dry run first):
Prompt: "Add Jane Doe with email jane@example.com"
Tool: db_create(table="users", data={"email":"jane@example.com","name":"Jane Doe"},
dryRun=true) -- verifies first, no write
SQL: INSERT INTO users (email, name) VALUES ($1, $2) RETURNING *
Result: Dry run: valid. Proceed? [yes] -> Row inserted with id 105Update order status:
Prompt: "Mark order 1503 as shipped"
Tool: db_update_many(table="orders", where={"id":1503},
data={"status":"shipped"})
SQL: UPDATE orders SET status = $1 WHERE id = $2 RETURNING *
Result: 1 row updatedDelete old records:
Prompt: "Delete logs from before 2025"
Tool: db_delete_many(table="logs",
where={"created_at":{"lt":"2025-01-01"}}, dryRun=true)
SQL: DELETE FROM logs WHERE created_at < $1 RETURNING *
Result: 1,204 rows would be deleted. Confirm? [yes/no]Cloud Databases
Add PGSSLMODE for cloud providers (Neon, Supabase, RDS, Render):
DATABASE_URL=postgresql://user:pass@ep-xxx.us-east-2.aws.neon.tech/neondb
PGSSLMODE=requireOptions: disable, prefer, require, verify-full. Auto-detected for most providers.
Docker
Run PGAutoPilot alongside a fresh PostgreSQL instance, or point it at a database you already have:
docker compose up --build # PostgreSQL 16 + MCP server together
docker run -e DATABASE_URL=... pgautopilot # Connect to an existing DBConfiguration
Variable | Default | What it does |
| (required) | PostgreSQL connection string |
| auto | SSL mode: |
|
| Maximum simultaneous database connections |
|
| How long to wait when connecting (ms) |
|
| How long idle connections stay open (ms) |
|
| Max time for a single query (ms) |
|
| Where |
| - | Docker container name for |
| - | Tables to block writes on (comma-separated) |
| - | Extra columns to redact (comma-separated) |
|
| Set to |
CLI flags
pgautopilot --readonly
pgautopilot --mode=production
pgautopilot --readonly --mode=productionPerformance
PGAutoPilot adds minimal overhead over a direct PostgreSQL connection — query latency depends primarily on your database and network. The bundled single-file executable has zero runtime dependencies, and connection pool size and statement timeouts are both configurable. Full performance benchmarks will be published once the project reaches a stable release.
Compatibility
Platform | Support |
Windows | Yes (native) |
macOS | Yes (native) |
Linux | Yes (native) |
Docker | Yes |
WSL | Yes |
ARM64 | Yes |
x64 | Yes |
Node 18 | Yes |
Node 20 | Yes |
Node 22 | Yes |
Software Signing
Method | How to verify |
SHA-256 hashes |
|
GPG signature |
|
Install scripts verify checksums.txt automatically after cloning. On mismatch, installation aborts. Bypass with --skip-verify (not recommended).
FAQ
Do I need to restart after changing my database schema? No. PGAutoPilot validates identifiers against the live schema on every request. Schema changes are reflected immediately without a restart.
Can PGAutoPilot modify my database automatically? Only through explicit tool calls. Every write requires a deliberate AI action, and dry-run before write is the default workflow.
Does it work with Supabase?
Yes. Use the Supabase connection string and set PGSSLMODE=require.
Does it require npm? No. Install via npm, the one-line installer, or the single-file bundle.
Does it support SSL?
Yes — auto-detected or configured via PGSSLMODE.
Can I disable writes entirely?
Yes. pgautopilot --readonly blocks every write operation.
Can I expose it publicly? No. PGAutoPilot is designed for local/private network use. There is no authentication layer or HTTP server.
Is it safe for production? Yes — every write path is guarded. See the Safety and Security sections for details.
Troubleshooting
Error | Likely cause | How to verify | Fix |
|
|
| Create |
| PostgreSQL not running or wrong URL |
| Check host/port, Docker port mapping |
| Cloud DB requires SSL | Check provider docs | Set |
| Typo or wrong schema | Run | Use exact names from schema |
| Using | N/A | Use |
|
|
| Install |
Development
Repository layout
src/
index.ts Entry point, MCP server initialization
config.ts Environment variable loading and validation
db.ts PostgreSQL connection pool management
schema.ts Live schema introspection via information_schema
sqlBuilder.ts Parameterized, safe SQL query builder
safety.ts Redaction engine, write access control, warnings
toolDefinitions.ts Zod schemas for all 14 tools
toolHandlers.ts Tool implementations, one handler per toolCommands
Command | What it does |
| Start with hot-reload (development) |
| Compile TypeScript and bundle into a single executable |
| Run the compiled version |
| Full TypeScript type checking |
| TypeScript type-check + ESLint |
| Auto-format source files with Prettier |
Roadmap
Authentication plugins (API key, JWT)
Streaming query results
Schema migration tools
Prometheus metrics / OpenTelemetry
Multi-database support (read replicas, shards)
Query explain and optimization suggestions
Contributing
Strict TypeScript — no
anytypesEvery write path must pass through the safety layer
Add tests for new features
Keep dependencies minimal
Fork, branch, commit, open a PR.
License
MIT © 2026 Cyber Reinxy
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- FlicenseAqualityDmaintenanceEnables AI assistants to interact with PostgreSQL databases using natural language queries, providing secure read-only access to database schemas and SQL translation capabilities.Last updated627
- Alicense-qualityFmaintenanceEnables AI assistants to safely explore, analyze, and maintain PostgreSQL databases with read-only mode by default, SQL injection prevention, query performance analysis, and optional write operations.Last updated98Apache 2.0
- Alicense-quality-maintenanceProvides AI assistants with safe, controlled access to PostgreSQL databases with read-only defaults, granular permissions, query safety features, and schema introspection capabilities.Last updated1
- Flicense-qualityDmaintenanceEnables AI assistants to interact with PostgreSQL databases through natural language queries, schema inspection, and safe SQL execution.Last updated281
Related MCP Connectors
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
The grounded data layer for any LLM: governed SQL, metrics, lineage and catalog over your data.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/cyberreinxy/pgautopilot'
If you have feedback or need assistance with the MCP directory API, please join our Discord server