# Authentication

AI Game Developer signs you in with OAuth 2.1: the editor window, the desktop app and the Unity / Unreal / Godot CLIs use the device-code flow you approve in your browser, setup-mcp writes a project key for your AI client, and Personal Access Tokens stay available for CI and manual MCP clients.

_Last updated: 2026-11-04_

Docs · Authentication

AI Game Developer uses **OAuth 2.1** with the device-authorization flow everywhere — the editor window, the desktop app, and the Unity / Unreal / Godot CLIs. You approve a sign-in in your browser; credentials are stored on your machine and the session shows up under Connected devices. Personal Access Tokens stay available for CI and manual clients.

## OAuth device flow — the default

Default Browser-approved sign-in

Every entry point — the editor **window**, the **app**, and each **CLI** — signs in the same way: it opens your browser, you approve the device, and it stores the full credential set locally. Nothing to copy or paste.

1. Start the flow — **Authorize** in the editor window, **Sign in** in the app, or `login` in a CLI.
2. Approve the device code in the browser window that opens (same ai-game.dev account).
3. Credentials are stored on your machine; access tokens refresh automatically.
4. The session appears on your [Connected devices](https://ai-game.dev/app/connected-devices) page, where you can revoke it any time.

### Three ways it starts

- **Editor window** — choose **Cloud**, click **Authorize**, approve in the browser.
- **Game Dev App** — click **Sign in**; the app opens the same browser flow (see the [App guide](https://ai-game.dev/docs/app)).
- **CLI** — run `login` (e.g. `unity-mcp-cli login`); it opens the browser and stores credentials.

```bash
# Unity / Unreal / Godot — same OAuth device flow
unity-mcp-cli login
unreal-mcp-cli login
godot-cli login
```

## Endpoint: `/mcp` vs `/mcp/p/<pin>`

The hosted MCP endpoint is `https://ai-game.dev/mcp`. There are two ways your AI client can reach a running editor through it:

- `/mcp` — the base endpoint. The server routes to one of your connected editors by fallback (a single connected editor, your most-recently-used one, or a sticky selection). Simple, but ambiguous when several editors are open.
- `/mcp/p/<pin>` — a **pinned** URL. The pin is derived from a project’s identity, so requests are routed to that exact project’s editor. This is what `setup-mcp` writes by default, so the right editor is targeted even with multiple projects open.

`setup-mcp` writes the pinned URL into your client config automatically (pass` --no-pin` to fall back to the base `/mcp` URL). When you are signed in, it also writes a **project key** (`agd_pk_…`) as a bearer header, so the client connects at once. Pass `--oauth` for a URL-only config: the client then signs in through your browser on first connect.

```bash
# Writes a pinned /mcp/p/<pin> URL for your AI client (e.g. Claude Code)
unity-mcp-cli setup-mcp claude-code ./YourProject
godot-cli setup-mcp claude-code ./YourProject
unreal-mcp-cli setup-mcp claude-code --path ./YourProject
```

### Enroll

When you are handed an enrollment code, pass it to the engine CLI’s` install-plugin --enroll <code>` (or `--enroll-stdin` to keep it out of your shell history): it redeems the code for the plugin’s credential on this machine. Regular `login` and `setup-mcp` already handle the common case; enrollment is the “I was given a code” path.

## Personal Access Tokens — for CI and manual clients

Prefer a static token — for CI pipelines, scripts, or a manual MCP client that can’t do an interactive browser login? Mint a **Personal Access Token** from your [API keys](https://ai-game.dev/app/api-keys) page and send it as a bearer token. PATs are the manual alternative to OAuth, not the default path.

```json
{
  "mcpServers": {
    "ai-game-dev": {
      "url": "https://ai-game.dev/mcp",
      "headers": { "Authorization": "Bearer YOUR_PERSONAL_ACCESS_TOKEN" }
    }
  }
}
```

Full request anatomy and per-client snippets live on the [MCP endpoint page](https://ai-game.dev/mcp-endpoint-info).

[Quickstart →](https://ai-game.dev/docs/quickstart) [The App →](https://ai-game.dev/docs/app) [MCP endpoint →](https://ai-game.dev/mcp-endpoint-info)

---

Source (HTML): https://ai-game.dev/docs/auth
