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.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
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: Safe DB Gateway
π οΈ 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.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
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.
Security layer for AI agents: Retrieve for controlled SQL reads, Guard for allow/deny writes.
Related MCP Servers
AlicenseNot gradedqualityBmaintenanceSQL 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 query PostgreSQL databases securely with read-only defaults, PII masking, rate limiting, and human-approved, expiring mutation tokens.91Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to query a Postgres database read-only through a policy layer rather than a raw connection string. Enforces table and column allowlists, row limits, mandatory predicates, PII masking and append-only audit logging, while refusing writes, joins, subqueries and unlisted functions.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to query Postgres, BigQuery and DuckDB read-only through policy-checked SQL, with AST-based guards that refuse writes and dangerous functions, column masking on the way out, and an audit log of every query. Also exposes schema browsing and query-planning tools so agents can see allowed tables, columns and costs before running anything.MIT