# Connect an AI agent to DiceyTable

> Create a key, save it with the bridge's login command, add the bridge to Claude Code or another MCP app, then type the pairing code into DiceyTable.

- Question: How do I connect an AI agent like Claude to DiceyTable?
- Source: https://diceytable.com/docs/ai-agents/quick-start
- Last verified: 2026-10-09

Create a key in DiceyTable, save it with the bridge's `login` command, and add the bridge to your AI app. Then type the pairing code your agent shows you into a DiceyTable tab. It takes about 10 minutes, and it's free on every plan.

The bridge is a small program from npm that links your agent to your browser tab. You never download it by hand, because your AI app runs it for you. Curious what all this lets you build? See [Build a board game with AI](https://diceytable.com/features/ai-agents-mcp).

## What you'll need

- **A DiceyTable account.** Sign in at `diceytable.com` in the browser you'll use.
- **Node.js 20.19 or newer.** Run `node --version` in a terminal to check.
- **An MCP app.** Claude Code, Claude Desktop, Cursor and VS Code with Copilot all work.
- **A recent browser.** Chrome or Edge 147 or newer, or Firefox 153 or newer, connect straight to the bridge. Safari works too, through DiceyTable's relay.

## Step 1: Create a key

Open [Settings ▸ AI agents](https://diceytable.com/play/settings#ai-agents). Turn on **Allow AI agents to connect to DiceyTable as you**, then click **Create key**. Keep the default permissions and copy the key. It starts with `dtpat_`.

> **⚠ The key is shown only once.** Copy it before you close the dialog, and never paste it into a file you might share.

[Create an API key for your AI agent](https://diceytable.com/docs/ai-agents/setup/api-keys) explains each permission and where a key may live.

## Step 2: Save the key with `login`

Run this in a terminal and paste the key at the hidden prompt:

```sh
npx -y @diceytable/mcp-bridge@1 login
```

The bridge checks the key with DiceyTable. Then it prints your account name and the key's permissions. It saves the key in your user folder, so none of your app settings ever hold it.

## Step 3: Add the bridge to your AI app

For Claude Code, run:

```sh
claude mcp add diceytable -- npx -y @diceytable/mcp-bridge@1
```

Using another app? Follow the page for [Claude Desktop](https://diceytable.com/docs/ai-agents/setup/claude-desktop), [Cursor](https://diceytable.com/docs/ai-agents/setup/cursor) or [VS Code](https://diceytable.com/docs/ai-agents/setup/vs-code). Any other app that runs MCP servers works too. [Install the DiceyTable MCP bridge](https://diceytable.com/docs/ai-agents/setup/install) covers those.

## Step 4: Ask the agent to connect

Start a new chat and say "connect to DiceyTable". The agent shows you a pairing code such as `K7P-4QX`. A code lasts 5 minutes and allows 5 wrong tries. If it runs out, ask for a new one.

Wait for the code before the next step. The bridge only starts listening once the agent asks to connect.

## Step 5: Type the code in DiceyTable

In the editor, choose **Help ▸ Connect AI agent…**. You can also open `https://diceytable.com/editor?agent=connect`. If your browser asks to reach devices on your local network, allow it. That's how the tab finds the bridge on your computer. [Why the browser asks about your local network](https://diceytable.com/docs/ai-agents/setup/local-network-access) has the details.

Read the **Connect an AI agent?** dialog. It names your agent and the key, and it lists what the key allows. Type the code into **Pairing code from your agent** and click **Allow**.

![The Connect an AI agent? dialog with a pairing code typed and the Allow button ready](https://diceytable.com/assets/build/pairing--consent-dialog-CjMWErwr.webp "**The consent dialog.** Read it once properly; typing the code is your yes.")

[Pair a DiceyTable tab with your agent](https://diceytable.com/docs/ai-agents/setup/pairing) explains each option in the dialog.

## Step 6: Check it works

The tab now shows **Agent connected** with your app's name. Ask the agent to take a screenshot of the viewport. If a picture of your scene comes back, every link in the chain works. [Check your agent is connected](https://diceytable.com/docs/ai-agents/setup/verify) shows what a healthy setup looks like.

## If it doesn't work

- **"No AI agent bridge answered on this computer."** You opened the dialog before the agent asked to connect. Ask the agent to connect, then try again.
- **The code doesn't match.** It may have run out. Ask the agent for a new one.
- **Anything else.** Run `npx -y @diceytable/mcp-bridge@1 doctor` in a terminal. It checks Node.js, your key, the network and the ports. Then see [Fix an agent that won't connect](https://diceytable.com/docs/ai-agents/troubleshooting/connection).

## Next steps

- [Instructions to give your AI agent](https://diceytable.com/docs/ai-agents/workflows/agent-instructions): a starting prompt that keeps the agent on track.
- [Build a game with an AI agent](https://diceytable.com/docs/ai-agents/workflows/build-a-game): the loop from empty project to play-test.
- [What is MCP?](https://diceytable.com/docs/ai-agents/concepts/what-is-mcp): the idea behind all of this, in plain words.
