Skip to content
vsem-azamatPublic

About

A gateway for MCP servers: one endpoint per server, per-client tokens, tool allowlists and secret redaction

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

mcp-gate

CI Latest release Go version License: Apache 2.0 Stars

A self-hosted gate between your AI agents and your MCP servers.


mcp-gate sits between your AI agents and your MCP servers. Each server gets its own URL, each agent gets its own token, and passwords or API keys in a server's answer are hidden before the agent sees them. It is one Go binary, built on the official MCP Go SDK.


Your AI agents (Claude Code, Codex, Cursor) each have their own token. mcp-gate checks who is calling and whether the tool is allowed, blocks the call if not, and passes it to the right MCP server. On the way back it hides secrets in answers and in downloaded files and logs who did what. The animation follows one call: read_file returns the line password: hunter2, the agent gets password: [REDACTED #k3j5] instead, the password waits in the secret vault, and the owner reads it back with their own key.

Why I wrote it

I run about a dozen MCP servers for my own agents. I wanted secrets hidden from the model, a way to read a hidden value myself, a name on every token so the log shows who called what, OAuth that works with real providers, and new protocol versions soon after they come out. The open-source gateways I tried each had some of this, none had all of it. I patched one of them for a while, but my pull requests there waited a long time for review. So I wrote my own.

Key features

  • A URL per server
    Local (stdio) and remote (Streamable HTTP or legacy SSE) servers are served at /<server>/mcp. The gate starts local servers, checks that they respond and restarts them when they crash. While a server restarts, agents can still list its tools.

  • Or one URL for all of them
    Optional. With aggregate: {} in the config, /mcp serves the tools of many servers at once, named <server>__<tool>, so a client needs one entry. Each token sees only the servers that accept it, plus the public ones.

  • A token per agent
    Each token has a name, and the log line for every call says which token made it. A token can work for all servers or for one, and a server can be open without a token.

  • Allow and deny lists
    Choose which tools, prompts and resources each server shows to agents, and narrow them further for one token, so that each agent sees only its own tools.

  • Hidden secrets
    API keys, private keys, Authorization headers, .env lines and passwords in URLs become [REDACTED:<kind>] in answers, error messages and server logs. If the gate cannot check an answer, the agent gets an error instead. Files a tool downloads are checked too.

  • Secret vault
    Optional. Hidden values stay in memory for a day, and only your own key reads them back. Agent tokens cannot.

  • OAuth for remote servers
    mcp-gate auth login signs in once in any browser. The gate stores the grant and refreshes it.

  • Easy to run and to move to
    Health endpoints, a /_status page, JSON logs that never contain arguments or answers, and systemd units. With the socket unit, a restart or an upgrade refuses no connection and fails no call, and agents keep their sessions. import converts a TBXark/mcp-proxy config, and compare shows what differs between two gateways.

How it compares

mcp-gate mcp-proxy Docker ContextForge agentgateway
A URL per server ✅ ✅ ❌ ➖ ✅
A named token per agent ✅ ❌ ❌ ✅ ✅
Filters for tools, prompts, resources ✅ ➖ ➖ ✅ ✅
Hides secrets in answers ✅ ❌ ➖ ➖ ➖
Secret vault for the owner ✅ ❌ ❌ ❌ ❌
OAuth to remote servers ✅ ✅ ✅ ✅ ➖
One binary, no database ✅ ✅ ❌ ❌ ✅
All tools behind one URL ✅ ❌ ✅ ✅ ✅
Different tools for different agents ✅ ❌ ❌ ✅ ✅
Web UI ❌ ❌ ➖ ✅ ✅
SSO and roles ❌ ❌ ❌ ✅ ✅
Legacy SSE transport ➖ 🔜 ✅ ❔ ✅ ✅

🔜 planned, links to the issue. ➖ partly: tools only; mcp-gate reaches servers over legacy SSE but serves clients only streamable HTTP; Docker blocks the whole call instead of hiding the secret; ContextForge and agentgateway hide secrets through plugins; agentgateway's OAuth is token exchange. ❔ not documented. Checked against each project's docs in October 2026, corrections welcome.

mcp-gate suits a handful of MCP servers on one machine. If you need what the lower rows list, look at ContextForge, agentgateway, MetaMCP or MCPJungle.

Footprint

10 small stdio servers and 1 HTTP server behind each gateway; 4 agents, each with a session to all 11 servers, make 1000 tools/call in total. Median of 3 runs, Linux x86-64, October 2026.

mcp-gate mcp-proxy Docker ContextForge agentgateway
Gateway, idle 22 MB 18 MB 43 MB 371 MB 37 MB
Gateway, peak under load 25 MB 21 MB 48 MB 387 MB 47 MB
Gateway plus servers, after load 79 MB 81 MB 875 MB 1862 MB 112 MB
Server processes kept 10 10 40 containers 10 + 10 bridges 50

PSS, except RSS for mcp-gate: it is not dumpable, so its PSS needs root, and RSS is an upper bound (mcp-proxy by RSS: 20 MB idle, 22 MB peak). Totals count the gateway, its server processes, containers with their docker helpers, and bridges, but not the shared HTTP server. The test servers are tiny Go programs of about 4 MB each; real servers often take tens of megabytes, so the totals grow with what you run. Docker and agentgateway start a copy of each server for every agent session; agentgateway also kept the 10 from the session that listed the tools. ContextForge ran on SQLite with one worker and needs a bridge per stdio server. Versions: mcp-gate 0.1.3, mcp-proxy 1.1.0, Docker mcp-gateway 0.44.2, ContextForge 1.1.0, agentgateway 1.6.0.

Getting started

Download an archive for Linux or macOS (amd64 or arm64) from Releases and check it against checksums.txt. You can also build from source with Go 1.27 or newer:

go install github.com/vsem-azamat/mcp-gate/cmd/mcp-gate@latest

Create gate.yaml:

version: 1
listen:
  addr: 127.0.0.1:9090
auth:
  tokens:
    laptop: "${GATE_TOKEN_LAPTOP}"   # the name shows up in the audit log
servers:
  files:
    stdio:
      command: npx
      args: [-y, "@modelcontextprotocol/server-filesystem", /srv/shared]
    tools: {deny: [write_file, move_file]}
  docs:
    http:
      url: https://docs.example.com/mcp
      oauth: {}                      # run `mcp-gate auth login gate.yaml docs` once

Check the config, then run the gate:

export GATE_TOKEN_LAPTOP=$(openssl rand -hex 32)
mcp-gate check -connect gate.yaml
mcp-gate serve gate.yaml

Point a client at a server's endpoint:

{
  "mcpServers": {
    "files": {
      "type": "http",
      "url": "http://127.0.0.1:9090/files/mcp",
      "headers": {"Authorization": "Bearer <GATE_TOKEN_LAPTOP>"}
    }
  }
}

The configuration reference lists every key. To run the gate as a service, see systemd.

Commands

Command What it does
serve Run the gateway
check Validate a config; with -connect, also start every server once and report what it serves
auth login, status and logout for OAuth servers
compare Diff the tools, prompts and resources of two endpoints or snapshots
import Convert an mcp-proxy config.json

Documentation

Configuration Every key, its default and its meaning
Commands How to use each subcommand
Operations systemd units, running behind a reverse proxy, switching from mcp-proxy
Architecture How serving, downstreams, redaction, escrow and OAuth are built
Specifications The exact behaviour, as requirements and scenarios
Development Setup, checks, tests and releases

Status

Version 0.1. I use it every day with about a dozen servers. The config has a version number (version: 1), and an unknown key is an error. systemctl reload applies a changed config without a restart. Missing something? Open an issue.

Contributing

Issues, fixes and features are welcome. I answer issues and review pull requests as soon as I can, usually within a day or two. Start with CONTRIBUTING; AGENTS.md has the working rules, and security issues go through private reporting.

Contributors

Contributors
mcp-gate is released under the Apache 2.0 license.

About

A gateway for MCP servers: one endpoint per server, per-client tokens, tool allowlists and secret redaction

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages