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.
Free
MCP Security Gateway: lock down any MCP server
Example session with this skill installed
Secure my filesystem MCP server before I let Claude Code use it. It starts with npx -y @modelcontextprotocol/server-filesystem /workspace. The agent should only read files under /workspace/src and must never write or delete anything.
- Read your context and instructions
- Compiled the mcp security gateway
Summary
Your filesystem server now runs behind mcpguard. Only two read-only tools are visible, both limited to /workspace/src. Every write tool is hidden, and each call is recorded in a tamper-evident audit log.
1. Tool review
mcpguard scan-tools tools.json found no poisoned descriptions in this server. You approved a read-only subset; everything else stays hidden by the deny-by-default policy.
| Tool | Decision | Reason |
|---|---|---|
read_text_file | Pinned | Needed; limited to /workspace/src |
list_directory | Pinned | Needed; limited to /workspace/src |
write_file, edit_file, move_file, create_directory | Hidden | You asked for read-only access |
| Any tool added in a future server update | Hidden | Not pinned; needs review first |
python scripts/select_tools.py tools.json --keep read_text_file,list_directory --out tools.approved.json
mcpguard lock tools.approved.json --server filesystem --out mcpguard.lock.json
2. Policy: mcpguard.policy.toml
[gateway]
server_name = "filesystem"
default_action = "deny"
block_unpinned_tools = true
block_poisoned_tools = true
block_secrets_in_args = true
redact_secrets_in_results = true
redact_pii_in_results = true
[[tool]]
name = "read_text_file"
rate_per_minute = 60
max_result_chars = 20000
[tool.args.path]
path_prefixes = ["/workspace/src"]
max_length = 512
[[tool]]
name = "list_directory"
rate_per_minute = 60
[tool.args.path]
path_prefixes = ["/workspace/src"]
max_length = 512
3. Claude Code config: .mcp.json (backup saved as .mcp.json.bak)
{
"mcpServers": {
"filesystem": {
"command": "mcpguard",
"args": [
"proxy",
"--policy", "/home/me/project/mcpguard.policy.toml",
"--lock", "/home/me/project/mcpguard.lock.json",
"--audit", "/home/me/project/audit/mcpguard.jsonl",
"--", "npx", "-y", "@modelcontextprotocol/server-filesystem", "/workspace"
]
}
}
}
4. Verification
- After restarting Claude Code, the server lists only
read_text_fileandlist_directory. read_text_filewith/workspace/.envis rejected withisError: truebecause the path is outside/workspace/src.- A path containing
..is always rejected. mcpguard verify-audit audit/mcpguard.jsonlconfirms the audit chain is intact.
Next steps
- When the server updates, run
mcpguard scan-tools tools.json --lock mcpguard.lock.jsonto see new or changed tools before re-pinning. - To allow tests later, add
/workspace/teststopath_prefixes. Do not widen it to/workspace, because that would expose.env. - Keep the server itself least-privileged: pattern checks reduce prompt-injection risk but cannot remove it.
Connects securely to your tools. The creator never sees your data.
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_approvaland 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
- Install mcpguard (Python 3.11+, no other dependencies).
- Capture the server's tools with the bundled script.
- Review findings with you; suspicious tools are left out.
- Pin only the tools you approve.
- Write a least-privilege policy from the bundled template.
- Point Claude Code or Cursor at the gateway (shows you the config diff first, keeps a backup).
- 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.
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
Free to use
No account required to browse
Trust & safety
Security scan
Security scan passed 13 days ago
- Free with an Agensi account
- Software
Python 3.11+pip@modelcontextprotocol/server-filesystem
Node.js
Permissions
Terminal: installs mcpguard with pip and runs its commands. Read/Write files: reads the MCP server's tool list and writes the policy, lockfile and your host config (after showing you the diff, with a backup). Network: pip downloads mcpguard from GitHub.
What's inside
Frequently Asked Questions
New in Security
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Security.