Skip to content

Tutorial 12: Connect Claude Desktop to a game (for players)

Verified against gamewarden v0.1.0 (see the changelog). About 10 minutes. The script 12-connect-claude-desktop-as-a-player.sh plays Claude’s part against a local gateway and checks every page and message this tutorial describes. CI runs that script.

This tutorial is for players. Your game runs a gamewarden gateway, and you want Claude to look at your game and, if you allow it, play a little for you. You will add the game as a connector in Claude Desktop, link it to your game account with a code, and choose how much Claude may do.

Studios: you can copy this page into your own help pages. Replace gateway.example.com with your gateway’s address and the menu names with your game’s. What your gateway needs before players can do this is at the end.

  • Claude Desktop (or claude.ai in a browser: the steps are the same). On the Free plan you can add one custom connector, paid plans can add more.
  • An account in the game, and the game open on a device where you are logged in.
  • The game’s connector address. The game publishes it in its help pages. In this tutorial it is:
https://gateway.example.com/mcp

You do not install anything. The connector is a web address, and Claude connects to it from Anthropic’s servers.

Claude never gets your game password. Instead:

  1. You add the game’s address to Claude as a connector.
  2. Claude opens a “Link an AI agent” page from the game in your browser.
  3. The game gives you a short link code (like ABCD-EFGH). You type it on that page. The code tells the gateway which player you are.
  4. You choose Coach (look and advise) or Operator (also act for you).
  5. Claude can now use the game’s tools, inside the limits the game sets. You can take that access back at any time from the game.

In Claude Desktop:

  1. Open Settings, then Connectors. (On some versions it is Customize, then Connectors.)
  2. Click Add custom connector.
  3. Name: anything you will recognize, for example Tiny City.
  4. Remote MCP server URL: https://gateway.example.com/mcp. Type it exactly, including /mcp.
  5. Leave Advanced settings empty. The gateway registers Claude by itself, so you need no client ID or secret.
  6. Click Add.

The connector shows up in the list, not connected yet.

Click Connect next to the new connector. Your browser opens a page from the game:

Link an AI agent
Claude wants to act in the game for you. It will be sent back to claude.ai.
What may it do?
(•) Coach: read only: look at your game and give advice
( ) Operator: also take actions for you, within the game's limits
Link code from the game [ XXXX-XXXX ]
[ Allow ] [ Deny ]

Check the address bar shows the game’s address (gateway.example.com here) and that the page says it will send you back to claude.ai. If either looks wrong, click Deny.

Some games show only Coach. That game allows read-only agents only.

Keep the page open and switch to the game. Where the code lives depends on the game. Look for something like Settings, then Linked AI agents, then Link a new agent. The game shows a code such as A682-25LS.

  • The code works once and only for 5 minutes. Get it now, not before step 2.
  • Never share the code with anyone. Whoever types it links their agent to your account.

Some games instead show a Sign in with your game account button on the linking page. Use that and skip the code: you sign in with the game’s own login.

On the linking page:

  1. Choose Coach or Operator. If you are unsure, start with Coach. You can change it later (step 7).
  2. Type the code. Upper or lower case both work.
  3. Click Allow.

The browser goes back to Claude, and the connector shows as connected. If the page says That link code did not work. Ask the game for a new one., the code was mistyped, already used or older than 5 minutes. Get a new one and try again.

Start a new chat. Check the connector is switched on in the chat’s tools menu, then ask something about your game:

Look at my city and tell me what I should do next.

Claude calls the game’s tools and answers. The first time it uses a tool, Claude may ask you to allow it. You choose “allow once” or “always allow” for each tool in Claude, on top of what the game allows.

What Claude can do depends on what you chose:

You chose Claude can
Coach look at your game state, prices and advice. It does not even see the action tools
Operator also take actions, such as selling or building, inside the game’s limits

The game sets limits for agents, and Claude has to live with them like any player. When it hits one, the game tells Claude why, and Claude tells you. For example:

  • Too many requests: Claude waits a little and tries again.
  • Daily cap: for example “300 units a day, 0 left today”. It resets the next day.
  • Cooldown: some actions can only run every few minutes.

Big actions, such as spending a lot of coins, may need your approval every time. Claude asks, the game holds the action, and you see it in the game:

  1. Claude says the action is waiting for your approval.
  2. Open the game. Approve or deny the pending action where the game shows it.
  3. Tell Claude you approved it. Claude runs it again and this time it goes through.

If you deny, Claude is told not to try the same action again.

To switch between Coach and Operator, link again:

  1. In Claude, Disconnect the connector, then Connect again.
  2. Get a new code from the game and choose the other option.
  3. In the game’s linked agents list, revoke the old link (step 8), so only the new one is left.

You can take Claude’s access away at any time, from the game:

  • Open the game’s Linked AI agents list (the name depends on the game).
  • Revoke the link for Claude. It stops working on Claude’s very next request.
  • Many games also have a Log out all agents button.

Removing the connector in Claude stops Claude from using it, but the link in the game stays until you revoke it there. Do both if you are done with it.

What you see What it means What to do
“That link code did not work. Ask the game for a new one.” the code is wrong, used or older than 5 minutes get a new code and retry
“Too many attempts. Wait a minute and try again.” too many wrong codes in a row wait a minute
Claude says it could not connect to the server wrong address, or the game’s gateway is down check the address, including https:// and /mcp
The connector was connected but now asks to connect again the link was revoked in the game, or it expired click Connect and link again with a new code
Claude says a tool does not exist you linked as Coach, and the tool is an action link again as Operator (step 7)
Claude says an action is waiting for approval the game wants your OK for big actions approve it in the game, then tell Claude
Claude says a daily cap or cooldown was reached the game’s limits wait, or play that part yourself

Players can only follow this page if your gateway is set up for it. Claude connects to the gateway from Anthropic’s servers on the public internet, not from the player’s computer.

  • HTTPS on the default port. Publish the gateway behind TLS at an address such as https://gateway.example.com/mcp. Claude does not connect to a URL that names another port, so https://...:8080/mcp and any http:// address will not work.
  • --public-url is that HTTPS address, without /mcp. Tokens are bound to it.
  • No --dev-auth. Dev auth trusts a header any client can set. On a public address anyone could act as any player.
  • Reachable from the internet, including Anthropic’s address ranges. A firewall that only admits your own players’ networks blocks Claude.
  • Registration limits. Every Claude user’s connector registers itself through Anthropic’s servers, so many players arrive from a few addresses. --register-per-hour (default 10 per address) is too low for that. Raise it to fit your player count, and keep --max-clients as the overall bound.
  • A place in your game for link codes, approvals and the linked agents list. Your backend mints link codes, approves confirmations and lists and revokes grants with signed calls. Tutorials 4 and 5 build each of them.
  • Your own address and menu names on this page. Publish the connector address and the menu path to your link code in your help pages.

Tutorial 6 is the full checklist for a public gateway, and the runbook covers running it.

  • A player adds the game as a custom connector in Claude with one address, and links it with a short code from the game. Claude never sees the game password.
  • Coach lets Claude look and advise. Operator lets it act, inside the game’s limits.
  • Big actions can wait for the player’s approval in the game.
  • The player revokes Claude’s access from the game, and it stops on the next request.

Players: that is all. Studios: best practices for designing tools an agent uses well, and connect an agent for the technical flow behind this page.