Works with the AI Agents you already use
postgres mcp hardened
by R. Szal
A Rust-based MCP server providing secure, read-only PostgreSQL access with statement validation and data redaction.
$7
postgres mcp hardened
Example session with this skill installed
Connect my Claude Desktop to a local Postgres database named 'analytics' using the hardened MCP server. I want to make sure it can't see the 'users' table.
- Read your context and instructions
- Compiled the postgres mcp hardened
I have configured the connection string and restricted access to ensure the 'users' table remains hidden from the agent. The following configuration uses the stdio transport for Claude Desktop and implements an allowlist that excludes the sensitive table.
Hardened Postgres MCP Configuration
{
"mcpServers": {
"postgres-hardened": {
"command": "npx",
"args": [
"-y",
"postgres-mcp-hardened",
"--stdio"
],
"env": {
"DATABASE_URL": "postgres://mcp_reader:YOUR_SAFE_PASSWORD@localhost:5432/analytics",
"MCP_ALLOW_TABLES": "public.orders,public.products,public.inventory",
"MCP_REDACT_COLUMNS": "email,password,ssn",
"MCP_STATEMENT_TIMEOUT": "30s"
}
}
}
}
Next steps
- Run the
postgres-mcp-hardened --print-setup-sql --role mcp_readercommand to generate the necessary read-only role permissions for your database. - Add the JSON block above to your
claude_desktop_config.jsonfile. - Restart Claude Desktop and run the
security_posturetool to verify the allowlist is active.
Connects securely to your tools. The creator never sees your data.
About this skill
You need to give an AI agent access to your PostgreSQL database, but letting an LLM run arbitrary SQL is a massive security risk. This skill provides a hardened Model Context Protocol (MCP) server that enforces read-only access at the server level, preventing agents from executing destructive commands even if they attempt to bypass database-level restrictions.
What it does
- Enforced Read-Only Queries: Runs a validator that rejects non-read-only statements like
DROP,DELETE, orUPDATEbefore they reach the database. - Schema Discovery: Provides tools for agents to explore schemas, tables, and column structures safely without guessing names.
- Data Redaction: Intercepts and masks sensitive columns like passwords or SSNs at the server level.
- Performance Auditing: Exposes query execution plans, index analysis, and health metrics to help agents diagnose slow performance.
- Access Control: Implements allowlists for specific schemas and tables to limit the agent's blast radius.
How it works
- Setup Role: Generate a dedicated read-only PostgreSQL role using the
--print-setup-sqlflag to ensure minimum required privileges. - Configure Transport: Choose between
stdiofor local use in Claude Desktop/Cursor or HTTP for remote agent access. - Environment Lockdown: Define
DATABASE_URL,MCP_ALLOW_SCHEMAS, andMCP_REDACT_COLUMNSto set the operational boundaries. - Validation: Test the server against the adversarial corpus using
--validateto confirm it rejects unauthorized writes.
Frameworks & tools
Built in Rust for a small 7.7 MB idle footprint. Integrates with any MCP-compliant client including Claude Desktop, Cursor, and Claude Code. Supports PostgreSQL, Supabase, Neon, and AWS RDS.
Why this beats prompting it yourself
Standard agents can be tricked into running destructive SQL through prompt injection or accidental hallucinations. This skill moves the security logic into a compiled Rust binary that validates every statement against a fuzzed parser, making it impossible for an agent to "argue" its way into a write operation.
Use cases
- Granting Claude or Cursor access to production schemas for safe data analysis and reporting.
- Allowing an agent to diagnose database performance issues by inspecting execution plans and slow queries.
- Providing a secure interface for AI-driven technical support bots to look up customer records without risking data integrity.
- Auditing existing database deployments for security posture and unused indexes.
Known limitations
Refuses all write operations by design, even for migrations or seeding. Large query planners can increase memory usage, so setting a container memory limit is recommended.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 1 month ago
- Software
- Postgres Hardened MCP
Node.jsENOENT
Permissions
What's inside
Frequently Asked Questions
New in LLM Ops
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for LLM Ops.