# MCP Security Gateway: lock down any MCP server

> Put any MCP server behind a deny-by-default gateway: review tools for poisoning, pin approved ones, restrict arguments, redact secrets and keep a tamper-evident audit log.

MCP Security Gateway: lock down any MCP server is a free AI agent skill on Agensi by Rubbaite T. Hassain, in Security. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Rubbaite T. Hassain](https://www.agensi.io/creators/rubbaite)
- Category: [Security](https://www.agensi.io/skills/security)
- Version: 1.0
- Last updated: 2026-11-22
- Security: scan passed (2026-11-22); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/mcp-security-gateway-lock-down-any-mcp-server
- Tags: security, ai-agents, llm-ops, mcp-server, python, claude-code, prompt-injection, mcp-security

## About this skill

Your agent's MCP tools can be poisoned, changed after you approved them, or tricked by injected text into leaking data. A system prompt cannot stop that. This skill makes your agent put the server behind **mcpguard**, an open-source (MIT) gateway that enforces the rules at the transport layer.

### What it does
- **Deny by default:** only tools you list in the policy are visible or callable.
- **Tool review:** scans tool descriptions for hidden model directives, sensitive-path references, tool shadowing and invisible Unicode.
- **Rug-pull protection:** pins each approved tool with a SHA-256 of its name, description and schema; a tool that changes later stays hidden until re-reviewed.
- **Argument rules:** path prefixes (`..` always rejected), https domain allow-lists, regex patterns, length limits, fixed choices, rate limits.
- **Human approval:** tools that send, delete, pay or deploy are marked `requires_approval` and blocked in proxy mode.
- **Data protection:** blocks secrets in arguments; redacts secrets and personal data in results.
- **Audit:** tamper-evident hash-chained log, verifiable with one command.

### How it works
1. Install mcpguard (Python 3.11+, no other dependencies).
2. Capture the server's tools with the bundled script.
3. Review findings with you; suspicious tools are left out.
4. Pin only the tools you approve.
5. Write a least-privilege policy from the bundled template.
6. Point Claude Code or Cursor at the gateway (shows you the config diff first, keeps a backup).
7. Verify: blocked call test plus audit-chain check.

### What's included
SKILL.md, two helper scripts (capture tool list, select approved tools), a policy template and a full policy-key reference.

### Known limitations
- stdio servers only (not HTTP/SSE).
- Pattern-based detection reduces risk; it cannot make prompt injection impossible. Keep the server itself least-privileged.
- The audit log stores argument hashes, not values.

Source: https://github.com/md-rubbaite/mcp-security-gateway

## Requires

- Python 3.11+
- pip
- @modelcontextprotocol/server-filesystem
- Node.js

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the MCP Security Gateway: lock down any MCP server skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### How does MCP Security Gateway protect my system from agent mistakes?

Your agent connects to the gateway instead of the MCP server. The gateway hides every tool you have not approved and pinned, checks each call's arguments against your policy (paths, domains, patterns, lengths), blocks secrets in arguments, redacts secrets and personal data in results, and logs every call.

### Which agents and MCP servers does it work with?

Any agent that supports SKILL.md (Claude Code, Cursor, Copilot, Codex CLI and others) and any MCP client that launches servers over stdio. It needs Python 3.11+. HTTP/SSE servers are not supported yet.

### Can it detect an MCP server that changes a tool after I approved it?

Yes. The lockfile stores a SHA-256 of each approved tool's name, description and schema. If the server later changes a tool, the gateway hides that tool until you review and re-pin it.

### What is included?

SKILL.md with the full step-by-step workflow, two helper scripts (capture a server's tool list; write the approved subset for pinning), a policy template and a reference of every policy key. The skill installs mcpguard itself from its public GitHub release (MIT licence).

### Do I need to be a security expert?

No. The agent runs the steps and explains each finding in plain words. You make two decisions: which tools to approve and which paths or domains to allow. It shows you the config change before writing it and keeps a backup.

### Why not just add security rules to my system prompt?

Text in a tool description or tool result can override prompt instructions. The gateway enforces rules outside the model, so a hidden tool cannot be called and a blocked argument is rejected whatever the model was told.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
