Quickstart
Run the whole demo in about five minutes. You need Docker with Compose v2.20 or newer and nothing else.
Nothing is installed on your machine, and every port binds to 127.0.0.1.
Before you start
- Docker with Compose v2.20 or newer (
docker compose version). - Free ports
8080(the gateway),9091(its health and metrics) and443(an HTTPS front with a self-signed certificate), all on127.0.0.1. If443is taken, start withGAMEWARDEN_HTTPS_PORT=8443 docker compose up --build -dinstead. The steps below use only8080. - About five minutes, plus the first-run image downloads.
- New to the words (MCP, tier, caps, scope)? Keep the glossary open.
The demo is a fictional city-builder. A fake city backend sits behind the gateway. The gateway
runs with --dev-auth, which takes the player from a header. That is for local trying only.
1. Start it
Section titled “1. Start it”git clone https://github.com/Moustafa-Elgammal/gamewarden && cd gamewardendocker compose up --build -dThis starts the gateway, Redis (limits and caps), Postgres (approvals and audit) and the fake backend. Check that it is up:
curl -s http://127.0.0.1:8080/healthz2. See the tools
Section titled “2. See the tools”curl -s -H 'X-Dev-Player: p1' http://127.0.0.1:8080/v1/tools{"tools":[ {"name":"build_structure","description":"Build a structure on a free tile of the 5x5 grid.","tier":"medium","params":{"kind":"string","x":"integer","y":"integer"}}, {"name":"collect_taxes","description":"Move pending taxes into the treasury. Cooldown applies.","tier":"safe"}, {"name":"get_city_state","description":"Overview of the city: coins, resources, population. Call this first.","tier":"read"}, {"name":"sell_resource","description":"Sell food, water or materials at the current sell price.","tier":"medium","params":{"quantity":"integer","resource":"string"}}]}These four tools come from examples/city/manifest.yaml. (The output above is wrapped for
reading.)
3. Call a tool
Section titled “3. Call a tool”If you already ran the README example on this stack, the city has less food than shown below.
Run docker compose down -v and start again to reset it.
curl -s -X POST -H 'X-Dev-Player: p1' -d '{}' \ http://127.0.0.1:8080/v1/tools/get_city_state/call{"ok":true,"data":{"coins":500,"resources":{"food":60,"materials":60,"water":60},"buildings":0}}Now sell some food:
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{"ok":true,"data":{"coins":600,"earned":100}}4. See a denial and read its code
Section titled “4. See a denial and read its code”A denial is a normal answer, not a crash. It has "ok":false, a machine-readable code and a
message the agent can act on.
Bad arguments. The manifest says quantity is at most 1000:
curl -s -X POST -H 'X-Dev-Player: p1' \ -d '{"arguments":{"resource":"food","quantity":5000}}' \ http://127.0.0.1:8080/v1/tools/sell_resource/call{"ok":false,"code":"invalid_arguments","message":"argument \"quantity\" must be at most 1000"}A daily cap. sell_resource allows 300 units a day, and 50 are already used:
curl -s -X POST -H 'X-Dev-Player: p1' \ -d '{"arguments":{"resource":"water","quantity":400}}' \ http://127.0.0.1:8080/v1/tools/sell_resource/call{"ok":false,"code":"daily_amount_cap","message":"sell_resource: 400 needed, 250 left today"}A cooldown. Call collect_taxes twice:
for i in 1 2; do curl -s -X POST -H 'X-Dev-Player: p1' -d '{}' \ http://127.0.0.1:8080/v1/tools/collect_taxes/call; echo; done{"ok":true,"data":{"coins":625,"collected":25}}{"ok":false,"code":"cooldown","message":"collect_taxes is available again in 60 seconds"}A rate limit. Reads are limited to 120 a minute per player. Make 125 quick calls as a new player and look at the last answer:
for i in $(seq 1 125); do curl -s -X POST -H 'X-Dev-Player: p9' -d '{}' http://127.0.0.1:8080/v1/tools/get_city_state/calldone | tail -n 1After 120 calls the rest are refused:
{"ok":false,"code":"rate_limited","message":"max 120 reads per minute. Wait and retry."}Other codes you may meet: unknown_tool, scope_insufficient, switched_off,
tier_disabled, daily_call_cap, backend_rejected (your backend said no),
backend_unavailable, confirmation_required.
5. Approve a risky action (confirm: true)
Section titled “5. Approve a risky action (confirm: true)”build_structure is marked confirm: true in the manifest, so the player must approve each call.
This is separate from the sensitive tier, which is never callable at all.
curl -s -X POST -H 'X-Dev-Player: p1' \ -d '{"arguments":{"kind":"farm","x":1,"y":1}}' \ http://127.0.0.1:8080/v1/tools/build_structure/call{"ok":false,"code":"confirmation_required","message":"build_structure needs the player's approval. Ask the player to approve confirmation 3959...e5bb3bd0effe5e3ff2 in the game, then repeat this exact call. It expires at 11:30 UTC.","data":{"confirmation_id":"3959...","expires_at":"2026-11-19T11:30:36Z"}}The agent tells the player. The player approves. In this demo the dev API does it (in a real deployment your game’s backend does it with a signed request). List the pending confirmations, keep the first id and approve it:
curl -s -H 'X-Dev-Player: p1' http://127.0.0.1:8080/v1/confirmationsid=$(curl -s -H 'X-Dev-Player: p1' http://127.0.0.1:8080/v1/confirmations \ | grep -o '"id":"[^"]*"' | head -1 | cut -d'"' -f4)curl -s -X POST -H 'X-Dev-Player: p1' \ "http://127.0.0.1:8080/v1/confirmations/$id/approve"{"confirmations":[{"id":"9e366bd9f1c0ef72fdd8ae6b7ddb0b62","tenant":"dev","player":"p1","tool":"build_structure","args_sha256":"ce5a5142...","state":"pending","created_at":"2026-11-30T16:55:27Z","expires_at":"2026-11-30T17:05:27Z"}]}{"ok":true,"result":"approved"}Repeat the exact same call and it goes through:
curl -s -X POST -H 'X-Dev-Player: p1' \ -d '{"arguments":{"kind":"farm","x":1,"y":1}}' \ http://127.0.0.1:8080/v1/tools/build_structure/call{"ok":true,"data":{"buildings":1,"coins":565}}The approval is used up. A second identical call asks for approval again.
6. Read the audit trail
Section titled “6. Read the audit trail”Every attempt is an audit event. In the demo they go to the gateway log:
docker compose logs --no-log-prefix gateway | grep agent_call | grep '"player":"p1"'{"time":"2026-11-30T16:55:27.264890006Z","level":"INFO","msg":"agent_call","tenant":"dev","player":"p1","tool":"sell_resource","tier":"medium","outcome":"ok","code":"","args_sha256":"6ac4cafb..."}{"time":"2026-11-30T16:55:27.359668423Z","level":"INFO","msg":"agent_call","tenant":"dev","player":"p1","tool":"sell_resource","tier":"medium","outcome":"denied","code":"invalid_arguments","args_sha256":"f82ba1c7..."}{"time":"2026-11-30T16:55:27.424952673Z","level":"INFO","msg":"agent_call","tenant":"dev","player":"p1","tool":"build_structure","tier":"medium","outcome":"denied","code":"confirmation_required","args_sha256":"ce5a5142..."}{"time":"2026-11-30T16:55:35.558664051Z","level":"INFO","msg":"agent_call","tenant":"dev","player":"p1","tool":"build_structure","tier":"medium","outcome":"ok","code":"","args_sha256":"ce5a5142..."}Your output has more lines (one per attempt in steps 3 to 5) and your own times. --no-log-prefix
drops the gateway-1 | prefix Compose adds to each line.
The log holds a hash of the arguments, never the arguments. The player and admin activity feeds
(/v1/studio/activity) are served when you run with OAuth instead of --dev-auth. See the
protocol.
7. Use your own manifest
Section titled “7. Use your own manifest”Write a manifest for your game. This one has two tools:
version: 1game: my-gametools: - name: get_player description: The player's profile and balance. tier: read http: {method: GET, url: /api/player}
- name: claim_daily_reward description: Claim today's login reward. Once per day. tier: safe caps: {per_day_calls: 1} http: {method: POST, url: /api/rewards/daily}Save it as my.yaml and check it. (A .json file works too: the gateway reads the format from the
file extension.) The command runs in a container. The first dev run builds the toolchain image,
which takes a few minutes, and starts Redis and Postgres beside it:
docker compose run --rm dev go run ./cmd/gwctl validate my.yamldocker compose run --rm dev go run ./cmd/gwctl tools my.yamlok: 2 toolsread get_playersafe claim_daily_rewardA mistake is reported with every problem at once:
manifest invalid: - tools[0] ("x"): name must match ^[a-z][a-z0-9_]{1,63}$ - tools[0] ("x"): http.url must be a path starting with /To run the gateway on it, put the file in a folder (mygame/manifest.yaml) and add an override
file next to docker-compose.yml, compose.mygame.yml, that points the gateway at your file and
your backend:
services: gateway: command: - --manifest=/etc/mygame/manifest.yaml - --backend-url=http://host.docker.internal:3000 # your backend - --backend-allow-private - --addr=0.0.0.0:8080 - --redis-addr=redis:6379 - --ops-addr=0.0.0.0:9091 - --dev-auth volumes: - ./mygame:/etc/mygame:ro extra_hosts: - "host.docker.internal:host-gateway"Start it under its own project name, so it gets its own database:
docker compose downdocker compose -p mygame -f docker-compose.yml -f compose.mygame.yml up --build -dcurl -s -H 'X-Dev-Player: p1' http://127.0.0.1:8080/v1/toolsOne thing catches everyone once: --manifest only seeds an empty manifest store. After the first
start the stored version wins, so editing the file and restarting changes nothing. On your
machine, reset with down -v. In production, upload new versions with the admin key.
Add your manifest to the gateway explains both, and the full
format is in the manifest reference.
8. Clean up
Section titled “8. Clean up”docker compose downdocker compose -p mygame down -v # if you started your own manifest in step 7Connect an agent, or read how a call flows.