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

mcpgate: auth gateway for self-hosted MCP servers is a free AI agent skill on Agensi by Joshua Inyang, in Security. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Joshua Inyang](https://www.agensi.io/creators/joshua-inyang)
- Category: [Security](https://www.agensi.io/skills/security)
- Uses: 2
- Version: 1.0
- Last updated: 2026-10-20
- Security: scan passed (2026-10-20); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/mcpgate-auth-gateway-for-self-hosted-mcp-servers
- Tags: security, devops, ai-agents, go, authentication, mcp, audit-log, rate-limiting

## 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.
- `curl` and Python 3.8+ for the helper scripts. No pip packages.

Source: https://github.com/bouncei/mcpgate · Site: https://mcpgate.bouncei.dev

## Requires

- mcpgate v0.1.1+
- HTTP or SSE MCP server
- Python 3.8+
- curl

## Known limitations

Requires SSE/HTTP upstream. No direct stdio support. No argument-level filtering. No hot-reloading; requires restart to apply config changes. Resource/prompt access is not policed.

## 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 mcpgate: auth gateway for self-hosted MCP servers 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 mcpgate improve the security of my existing MCP servers?

Standard MCP setups are "all-or-nothing," but this skill creates a hard network boundary that allows you to issue specific API keys to different users or agents, ensuring they only see and execute the tools you’ve authorized.

### Which MCP clients and server types are compatible with this gateway?

It works with any MCP server that uses Streamable HTTP or Server-Sent Events (SSE) and is compatible with major MCP-enabled clients like Claude Code and Cursor.

### What exactly is included in the mcpgate package?

The skill (SKILL.md) plus three helper scripts: install.sh downloads the checksum-verified mcpgate release binary from GitHub, discover_tools.py lists an MCP server's exact tool names, and audit_summary.py summarizes the audit log. It also includes reference docs for the config schema, client setup (Claude Code, Cursor) and troubleshooting. The gateway itself is open source (Apache-2.0) at github.com/bouncei/mcpgate.

### How difficult is the initial setup and configuration process?

Installation involves a three-step process: discovering your upstream tools via the provided script, generating hashed API keys using the built-in keygen, and launching the service with a simple YAML configuration.

### Can I restrict specific parameters within a tool, or is access granted to the entire tool?

Currently, allowlists are enforced at the tool-name level; while you can restrict access to entire tools, the gateway does not yet support filtering based on specific tool arguments or parameters.

### Does this skill help monitor or limit usage for high-cost tools?

The gateway includes built-in rate limiting and JSONL audit logging, which allows you to set RPS caps to prevent agent loops and track every execution for performance debugging.

---

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.
