MCP Security Gateway: lock down any MCP server

    by Rubbaite T. Hassain

    1

    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

    Security scanned

    Works with the AI Agents you already use

    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.

    ToolDecisionReason
    read_text_filePinnedNeeded; limited to /workspace/src
    list_directoryPinnedNeeded; limited to /workspace/src
    write_file, edit_file, move_file, create_directoryHiddenYou asked for read-only access
    Any tool added in a future server updateHiddenNot 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_file and list_directory.
    • read_text_file with /workspace/.env is rejected with isError: true because the path is outside /workspace/src.
    • A path containing .. is always rejected.
    • mcpguard verify-audit audit/mcpguard.jsonl confirms the audit chain is intact.

    Next steps

    • When the server updates, run mcpguard scan-tools tools.json --lock mcpguard.lock.json to see new or changed tools before re-pinning.
    • To allow tests later, add /workspace/tests to path_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_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

    How to use

    1. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 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-filesystemNode.js

    Permissions

    Terminal / Shell
    Read Files
    Write Files
    Network Access

    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.

    Listed13 days ago

    What's inside

    Frequently Asked Questions

    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.

    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.

    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.

    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).

    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.

    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.

    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.

    Free