Skip to content

v0.4.0: Proxy mode for real MCP servers, OAuth 2.1, and verified clients

Latest

Choose a tag to compare

@danieloza danieloza released this 18 Nov 22:31
· 20 commits to main since this release
ed4deb2

The gateway can now sit in front of real MCP servers and stop a poisoned one. It also accepts OAuth 2.1 access tokens, and it has been run against real MCP clients.

Proxy mode in the console: an upstream server synced, three agent calls, a rug pull blocked, and the diff with its hidden text decoded

⚠️ Breaking change

With MSG_ENVIRONMENT=production, the gateway no longer starts unless MSG_AUTH_MODE=oauth. Static mode accepts only the demo keys, which the README publishes.

Before you upgrade a production deployment, point it at your authorization server:

MSG_AUTH_MODE=oauth
MSG_OAUTH_RESOURCE=https://gateway.example.com/mcp
MSG_OAUTH_ISSUER=https://idp.example.com/realms/gateway
MSG_OAUTH_JWKS_URL=https://idp.example.com/realms/gateway/protocol/openid-connect/certs
MSG_OAUTH_SUBJECTS=<token sub>=usr_ops,<token sub>=usr_security

Local runs are unchanged. The guard looks only at MSG_ENVIRONMENT, so set it on shared or staging deployments too.

What's new

Proxy mode (docs/PROXY.md)

  • Upstream servers. The gateway forwards calls to upstream MCP servers over Streamable HTTP. Each call first passes the full control path.
  • Pinning. Each upstream tool is pinned when an admin reviews it.
  • Rug pulls. The gateway checks a tool's definition against its pin on every call, and again just before forwarding. A changed definition blocks the call and quarantines the tool.
  • Output. Output that reads like instructions to the agent is withheld, and operators see the call as output withheld.
  • The example server. The repository includes a deliberately malicious server to try this on.

OAuth 2.1 resource server (docs/OAUTH.md)

  • Discovery. RFC 9728 metadata, with a 401 challenge that points to it.
  • Token checks. Signatures are checked against the authorization server's JWKS, using asymmetric algorithms only. The audience must name the gateway (RFC 8707).
  • Users. Each token subject maps explicitly to a gateway user.
  • No passthrough. The token is never passed on.
  • Tested against a local Keycloak realm.

Verified clients. MCP Python SDK 2.3.0 and Claude Code 2.1.248 both connected, and the SDK got every gateway decision.

Try it

python -m pip install -e .
python examples/poisoned_server.py &
MSG_UPSTREAMS=examples/upstreams.json python -m uvicorn mcp_security_gateway.main:app --port 8000
  1. Open http://127.0.0.1:8000/dashboard and enter msg-security-demo.
  2. In Tool trust, select Sync upstream.
  3. Run curl -X POST http://127.0.0.1:8100/rugpull.
  4. Sync again.

Verification

  • Tests: 123 tests and pip-audit. CI is green on the merged commit.
  • Mutations: CI checks that tests catch each removed guard: 11 of 11 for proxy mode, 9 of 9 for OAuth.
  • End to end: an e2e job in CI runs the poisoned server and the gateway over real HTTP, with the MCP SDK as the agent.
  • Docker: CI builds the image and scans it with Trivy. It finds no HIGH or CRITICAL issue that has a fix. CI then starts the image with Redis and smoke-tests /health and an MCP call.
  • "Try it": the steps above were run on a fresh clone. The animation above was recorded from the running gateway.

Known limitations

This is production-shaped, not production-ready:

  • Storage: SQLite.
  • OAuth: tried only against a local Keycloak realm.
  • Upstreams:
    • Streamable HTTP only;
    • no upstream credentials;
    • no egress policy.
  • Injection checks: they are patterns, not a proof.
  • Clients: Cursor and VS Code were not run.
  • Base image: Debian packages carry 47 HIGH findings that have no fix yet. Three are in SQLite.

CHANGELOG · Pull requests: