Works with the AI Agents you already use
mcpgate: auth gateway for self-hosted MCP servers
Lock down any self-hosted MCP server with per-client API keys, per-tool allowlists, rate limits and an audit log.
Free
mcpgate: auth gateway for self-hosted MCP servers
Example session with this skill installed
I've got the filesystem MCP server running in streamable HTTP mode at http://127.0.0.1:9000/mcp. Put mcpgate in front of it. My Claude Code should only be able to read stuff, never write/move/delete. Our CI bot should get every tool. Give me the config.yaml, the commands to run, and how to hook Claude Code up to it.
- Read your context and instructions
- Compiled the mcpgate
The gateway is set up and tested against your filesystem server: Claude Code gets the 9 read tools only, and the CI bot gets all 13. Before writing the allowlists I pulled the exact tool names from your server with scripts/discover_tools.py, because mcpgate matches tool names exactly and a guessed name (like read_file) would quietly block a tool.
client --Bearer key--> mcpgate 127.0.0.1:8080 --> filesystem MCP 127.0.0.1:9000/mcp
auth -> rate limit -> tool allowlist -> proxy
one JSON audit line per request -> ./mcpgate-audit.jsonl
What your server exposes (13 tools)
| Read-only (Claude Code gets these) | Write tools (CI bot only) |
|---|---|
read_text_file, read_media_file, read_multiple_files, list_directory, list_directory_with_sizes, directory_tree, search_files, get_file_info, list_allowed_directories | write_file, edit_file, create_directory, move_file |
Your server has no delete tool. Removing or renaming a file goes through move_file or an overwrite through write_file/edit_file, and Claude Code is blocked from all of them.
1. Install and mint keys
bash scripts/install.sh # checksum-verified release binary -> ~/.local/bin
mcpgate keygen --label claude-code # prints the key once + a config entry with its SHA-256 hash
mcpgate keygen --label ci-bot
Treat the printed keys like passwords: only their hashes go in config.yaml. Put the CI key in your CI secret store.
2. config.yaml
upstream:
url: "http://127.0.0.1:9000/mcp"
timeout: 30s
listen: "127.0.0.1:8080" # localhost only. Put TLS in front before exposing it to a network.
keys:
# Claude Code: read-only. Write/edit/move/create tools are denied AND hidden from tools/list.
- label: "claude-code"
hash: "<sha256 from mcpgate keygen>"
allow:
- read_text_file
- read_media_file
- read_multiple_files
- list_directory
- list_directory_with_sizes
- directory_tree
- search_files
- get_file_info
- list_allowed_directories
rate_limit: { rps: 5, burst: 20 } # a client's connect sequence can exhaust burst 5 -> 429
# CI bot: every tool, including any the upstream adds later.
- label: "ci-bot"
hash: "<sha256 from mcpgate keygen>"
allow: ["*"]
rate_limit: { rps: 10, burst: 30 }
audit:
output: "./mcpgate-audit.jsonl"
- CI bot gets
"*": that also covers tools the server adds later. To review each new tool first, list the 13 names instead. - Keep the file out of git: add
config.yamlto.gitignore.
3. Run it
mcpgate validate -c config.yaml # -> OK: 2 key(s), upstream http://127.0.0.1:9000/mcp
mcpgate serve -c config.yaml # -> mcpgate listening on 127.0.0.1:8080 -> http://127.0.0.1:9000/mcp
mcpgate doesn't hot-reload, so restart serve after every config change. Want a launchd plist, systemd unit or docker run --restart unless-stopped to keep it running? Tell me which.
4. Connect Claude Code
export MCPGATE_KEY='mcpg_...' # the claude-code key, e.g. in ~/.zshrc
claude mcp add --transport http files http://127.0.0.1:8080/mcp \
--header "Authorization: Bearer $MCPGATE_KEY"
For a shared project .mcp.json, reference the variable so each person uses their own key:
{ "mcpServers": { "files": { "type": "http", "url": "http://127.0.0.1:8080/mcp",
"headers": { "Authorization": "Bearer ${MCPGATE_KEY}" } } } }
If Claude Code is currently connected straight to :9000, remove that entry, or it can go around the gateway.
Test results
I ran your config on a scratch port against your upstream, then stopped it:
| Check | Result |
|---|---|
| No key | HTTP 401 unauthorized |
tools/list with the Claude Code key | 9 tools (all read-only) |
tools/list with the CI key | all 13 tools |
Claude Code calls list_allowed_directories | succeeds |
Claude Code calls write_file | {"code":-32001,"message":"tool not permitted: write_file"} |
Claude Code calls move_file | {"code":-32001,"message":"tool not permitted: move_file"} |
CI bot calls write_file | let through |
The audit log recorded each request under the right label:
{"label":"claude-code","method":"tools/call","tool":"write_file","decision":"deny:policy","status":200,...}
{"label":"ci-bot","method":"tools/call","tool":"write_file","decision":"allow","status":200,...}
To review later: python3 scripts/audit_summary.py mcpgate-audit.jsonl --label ci-bot --since 1d.
Limits worth knowing
Only tools are checked. Resources and prompts pass through for any valid key; the filesystem server's actions are all tools, so that doesn't matter here.
- Revoking a key: remove or replace its entry and restart. The old key keeps working until the restart.
Connects securely to your tools. The creator never sees your data.
About this skill
Self-hosted MCP servers usually ship with no auth: anyone who can reach the port can call every tool. This skill teaches your agent to put mcpgate in front of the server. mcpgate is a small open-source gateway (Go, Apache-2.0).
What your agent can do with it
- Set up a gateway in minutes. It installs a checksum-verified binary and reads the server's real tool names (allowlists are exact-match, so it never guesses), then writes a deny-by-default config with one key per client.
- Least-privilege allowlists. Give Claude Code read-only tools and give CI everything. Tools a key can't use are also hidden from that client's tool list.
- Connect your clients. It writes ready-made Claude Code and Cursor configs, with keys kept in env vars instead of committed files.
- Respond to a leaked key. It rotates the key and reports what the key did using the audit log: tool-level counts, denied attempts, off-hours activity.
- Debug errors. It maps
tool not permitted, 401, 429 and 502 to their exact cause and fix. - Know the limits. It tells you up front when mcpgate isn't the right fit (stdio servers, OAuth, per-argument rules) and what to do instead.
What's bundled
scripts/install.sh: downloads the release binary for your OS/arch and verifies its SHA-256.scripts/discover_tools.py: lists any MCP server's exact tool names with read-only/destructive hints.scripts/audit_summary.py: per-key activity, denials, and allowed-but-unused tools.- References: full config schema, client setup (Claude Code, Cursor, curl smoke test), and a troubleshooting table.
Requirements
- An MCP server that speaks Streamable HTTP or SSE. For stdio servers, the skill explains how to bridge them.
curland Python 3.8+ for the helper scripts. No pip packages.
Source: https://github.com/bouncei/mcpgate · Site: https://mcpgate.bouncei.dev
How to use
Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
Free forever
No account required to browse
Trust & safety
Security scanned
Verified clean today
- Free to download with an account
Requires