Skip to main content
Glama

gamewarden

ci Go Reference License Release

An open-source gateway that lets a player's own AI agent act safely inside a game.

Players are starting to bring their own AI agents. A studio that lets them in needs limits the agent cannot talk its way past: caps, cooldowns, confirmations and an off switch. gamewarden puts those limits in one place, in front of your existing backend, with no change to your game code.

A game studio describes its game actions in a manifest. The gateway turns them into MCP tools, applies safety policy (tiers, rate limits, daily caps, cooldowns, kill switches, player confirmations), calls the studio's backend with a signed request, and records every attempt in an audit log. It works with any backend language, because the contract is a manifest plus a signed HTTP request, not a library. Games whose logic runs in the client can use a WebSocket relay instead.

gamewarden demo: a sale succeeds, then a daily cap and a cooldown stop the agent

What an agent cannot talk its way past

  • Every attempt counts. Rate limits run before argument checks, so an agent that keeps sending bad calls is throttled like any other.

  • Failures cost nothing. A backend call that fails releases its reserved cap and starts no cooldown.

  • The player approves risky actions. Tools marked confirm: true wait for the player.

  • The studio has an off switch. Kill switches per tool, per player or for the whole game, signed with an admin key.

  • The audit log keeps no arguments. It stores a hash, so a log leak is not a data leak.

Related MCP server: mcp-guardian

Two modes for players

  • Coach: read-only. State, prices, advice.

  • Operator: limited actions on the player's behalf, inside caps the studio controls.

A studio can start a pilot read only for everyone with --max-scope coach, then raise it to operator later.

Quickstart

You only need Docker with Compose v2. Nothing is installed on your machine.

git clone https://github.com/Moustafa-Elgammal/gamewarden && cd gamewarden
docker compose up --build        # gateway, Redis, Postgres and a fake city backend on 127.0.0.1:8080

# in another terminal: let a player "sell" some food through the gateway
curl -s -X POST -H 'X-Dev-Player: p1' \
  -d '{"arguments":{"resource":"food","quantity":50}}' \
  http://127.0.0.1:8080/v1/tools/sell_resource/call

docker compose down

You should see {"ok":true,"data":{"coins":600,"earned":100}}. Ask for more than the daily cap and you get {"ok":false,"code":"daily_amount_cap",...} instead. To watch it happen in about a minute, run scripts/demo.sh (how to record it: docs/DEMO.md).

An expected failure comes back as a result with a machine-readable code and a hint, for example invalid_arguments, rate_limited, daily_amount_cap, cooldown or switched_off. The agent can read it and correct itself. The demo runs with --dev-auth, which trusts a header and must stay on loopback. Real deployments use OAuth (see the docs).

The same stack also serves HTTPS on https://gamewarden.test and https://localhost (port 443; set GAMEWARDEN_HTTPS_PORT to use another host port). Point the domain at your machine with a 127.0.0.1 gamewarden.test line in /etc/hosts, or pick another name with GAMEWARDEN_TLS_DOMAIN. An nginx service (https, config in deploy/nginx/gateway.conf) terminates TLS with a self-signed certificate that the tls-cert service creates in the tls-certs volume, and creates again when the domain changes. Use curl -k, or export the certificate with docker compose cp https:/etc/nginx/certs/tls.crt ./gamewarden-dev.crt and trust it. A container, such as the MCP bridge, can mount the volume and set SSL_CERT_FILE=/certs/tls.crt. Step by step: docs/guides/local-https.md.

Run the tests: docker compose run --rm dev make test. To connect Claude Desktop, see docs/CLAUDE-DESKTOP.md.

Status and compatibility

Version 0.1 (before 1.0). The pipeline, MCP endpoint, OAuth 2.1, Redis and Postgres stores, confirmations, manifest upload and rollback, activity feed, relay, metrics, a Helm chart, optional OIDC sign-in at consent, the project site and twelve tutorials are built. The tutorial scripts run in CI, except the two Kubernetes ones: tutorial 11 (Docker Desktop) has been run against a real cluster, and tutorial 9 (kind) runs with make k8s-tutorial-check and has not been run yet. OIDC sign-in has been run against Dex and Keycloak. Not yet: a hosted offering, a hosted identity provider, and Unity player builds of the relay client (its sample runs in the Unity editor; see docs/ROADMAP.md).

Before 1.0, the manifest format, the signed request and some protocol details may still change. Every such change is recorded in docs/DECISIONS.md and the CHANGELOG. Pin a version if you build on it.

Features

  • A manifest, written in YAML (JSON also works), becomes MCP tools. Strict validation reports every problem at once.

  • Policy: rate limits counted before validation, daily caps with reserve and settle, cooldowns, tiers, kill switches. Policy outages fail closed.

  • Signed backend calls (HMAC-SHA256, timestamp, idempotency key). Go backends can import pkg/agentsig; other languages follow docs/PROTOCOL.md.

  • Player confirmations for sensitive tools, linked through an embedded OAuth 2.1 server.

  • Versioned manifests with upload, rollback and hot swap, no restart. Key rotation.

  • Activity feed for players and studios. Audit stores hashes of arguments, never the arguments.

  • Relay for client-authoritative games, across several gateway replicas.

  • Sign-in with your own identity provider at consent (OIDC, confidential or public client).

  • Metrics, health checks, an SSRF-safe connector, a Helm chart and a runbook.

  • Measured, not claimed: a 1 hour soak and an overhead benchmark you can repeat (results).

The full component list is in docs/FEATURES.md.

Design rules

  1. The agent plays by the same rules as a human. No side doors around game logic.

  2. Every attempt counts against rate limits, valid or not.

  3. Caps reserve first and settle after, so concurrent calls cannot exceed them.

  4. Policy outage means action tiers fail closed.

  5. Backend results are untrusted data, never instructions.

  6. The audit log stores hashes of arguments, not game data.

Docs

Contributing and security

Small, focused pull requests are easiest to review. Read CONTRIBUTING.md and AGENTS.md. Report vulnerabilities privately, see SECURITY.md.

This is an independent project. It contains no code, data or API details from any employer or real game. The example game is fictional.

License

Apache-2.0. See LICENSE and NOTICE. Contributions are accepted under Apache-2.0.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers