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: PostgreSQL MCP Server
🛠️ 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.
Query your Postgres from ChatGPT or Claude without exposing the database or handing over credentials. Run npx boltschema connect next to your database and it dials out over HTTPS — no inbound firewall rule, no open port, works with localhost and VPC-private databases. Read-only is enforced by a SQL guard, a Postgres READ ONLY transaction, and a scoped role generated for you.
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
- FlicenseAqualityDmaintenanceEnables AI agents to inspect and query PostgreSQL databases safely, with features like listing tables, retrieving schemas, and running read-only SQL queries.3-
- FlicenseNot gradedqualityFmaintenanceProvides a secure, schema-aware PostgreSQL database agent for LLMs, enabling natural language queries and validated SQL execution with strong security guardrails.18 npm5-

Midplaneofficial
AlicenseNot gradedqualityAmaintenanceSQL guardrails for AI agents, sitting between the agent and Postgres to enforce policies, block destructive queries, and audit all access.4MIT