MCP Postgres Guard
Provides security-first query auditing and validation for PostgreSQL databases, intercepting destructive commands, preventing unbounded DELETE/UPDATE operations, detecting stacked queries and SQL injection probes, and enforcing read-only policies before agent-generated SQL reaches the database.
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., "@MCP Postgres Guardvalidate this SQL: SELECT * FROM orders LIMIT 10"
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.
MCP Postgres Guard 🐘🛡️
A security-first Model Context Protocol (MCP) server for PostgreSQL: query auditing, destructive command interception, and SQL injection prevention for autonomous AI agents.
Developed by Tarek Mohamed (@seotarek)
📌 Why MCP Postgres Guard?
Allowing AI agents (Claude, Cursor, LangChain agents) direct SQL access creates severe operational risks: accidental table dropping, unbounded deletions, or SQL injection. MCP Postgres Guard intercepts and audits all agent-generated SQL queries before they reach your database:
[ AI Agent / Claude / Cursor ]
│
▼
┌──────────────────────────────────────────────┐
│ MCP Postgres Guard Server │
│ • Destructive Query Blocker (DROP/TRUNCATE) │
│ • Unbounded DELETE/UPDATE Prevention │
│ • Stacked Query & RCE Probe Detection │
└──────────────────────┬───────────────────────┘
│ (Only If Verified Safe)
▼
[ Production Database ]Related MCP server: Midplane
🛠️ MCP Tools
pg_validate_query: Validates whether a SQL statement is safe to execute for an autonomous agent.pg_check_read_only: Enforces a strict read-only policy (SELECT / EXPLAIN only).
🚀 Claude Desktop Configuration
Add to your claude_desktop_config.json:
{
"mcpServers": {
"postgres-guard": {
"command": "python",
"args": ["-m", "mcp_postgres_guard.server"],
"cwd": "/path/to/mcp-postgres-guard"
}
}
}📜 License
Licensed under the MIT License.
This server cannot be deployed
Maintenance
Related MCP Connectors
Deterministic safety, correctness & cost gate that vets Postgres SQL before your AI agent runs it.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Guard AI agents' PostgreSQL/MySQL access via MCP: SQL audit, auth, masking, write approval
13
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables 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.37 npmApache 2.0

Midplaneofficial
AlicenseNot gradedqualityAmaintenanceSQL guardrails for AI agents, sitting between the agent and Postgres to enforce policies, block destructive queries, and audit all access.5MIT- AlicenseAqualityBmaintenanceEnables AI agents to analyze, optimize, and safely interact with PostgreSQL databases, including health checks, index recommendations, query planning, and SQL execution with read-only and production protection modes.15MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to query Postgres databases read-only over the Model Context Protocol through three narrow tools, validating every statement as a single SELECT with an enforced row limit before it reaches the database. Guards against destructive statements, banned functions, system catalogs, and runaway queries via AST parsing plus a SELECT-only Postgres role.MIT