Skip to content

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) and 443 (an HTTPS front with a self-signed certificate), all on 127.0.0.1. If 443 is taken, start with GAMEWARDEN_HTTPS_PORT=8443 docker compose up --build -d instead. The steps below use only 8080.
  • 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.

Terminal window
git clone https://github.com/Moustafa-Elgammal/gamewarden && cd gamewarden
docker compose up --build -d

This starts the gateway, Redis (limits and caps), Postgres (approvals and audit) and the fake backend. Check that it is up:

Terminal window
curl -s http://127.0.0.1:8080/healthz
Terminal window
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.)

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.

Terminal window
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:

Terminal window
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}}

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:

Terminal window
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:

Terminal window
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:

Terminal window
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:

Terminal window
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/call
done | tail -n 1

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

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.

Terminal window
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:

Terminal window
curl -s -H 'X-Dev-Player: p1' http://127.0.0.1:8080/v1/confirmations
id=$(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:

Terminal window
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.

Every attempt is an audit event. In the demo they go to the gateway log:

Terminal window
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.

Write a manifest for your game. This one has two tools:

version: 1
game: my-game
tools:
- 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:

Terminal window
docker compose run --rm dev go run ./cmd/gwctl validate my.yaml
docker compose run --rm dev go run ./cmd/gwctl tools my.yaml
ok: 2 tools
read get_player
safe claim_daily_reward

A 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:

Terminal window
docker compose down
docker compose -p mygame -f docker-compose.yml -f compose.mygame.yml up --build -d
curl -s -H 'X-Dev-Player: p1' http://127.0.0.1:8080/v1/tools

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

Terminal window
docker compose down
docker compose -p mygame down -v # if you started your own manifest in step 7

Connect an agent, or read how a call flows.