# MCP server

> Give a coding agent the IRT docs and read access to your project's builds, rooms, logs and usage with irt mcp, an MCP server for Claude Code and other MCP clients.

`irt mcp` runs an [MCP](https://modelcontextprotocol.io) server on stdio
for coding agents. It gives an agent two things:

- **The IRT docs**, searchable and readable a section at a time, so it
  looks up the API instead of guessing at it. The docs are bundled with
  the CLI, so they match the SDK version you installed and need no
  network.
- **Your project**: its status, builds, rooms, room state, recent logs,
  usage and bans, read with your CLI login. Tools that change anything
  are off unless you start the server with `--allow-writes`.

It's part of `@irtio/cli`, so there's nothing else to install. For the
integration rules as a Claude Code skill, see
[`irt skill install`](/docs/tools/cli#irt-skill-install---dir-path---force);
the two work together.

## Setup

Log in once, so the server can read your projects:

```sh
npx @irtio/cli login
```

### Claude Code

From the project directory, the one with `irt.config.ts`:

```sh
claude mcp add irt -- npx -y @irtio/cli mcp
```

Add `--scope project` to write the server to the project's `.mcp.json`
and share it with everyone who works on the project. Claude Code starts
the server in the project directory, so the project tools act on the
project named in `irt.config.ts`.

### Other MCP clients

Clients that take a JSON config, such as Cursor or Claude Desktop, need
an entry like this one:

```json
{
  "mcpServers": {
    "irt": {
      "command": "npx",
      "args": ["-y", "@irtio/cli", "mcp", "--project", "space-race"]
    }
  }
}
```

`--project` names the project the tools act on by default. Without it
the server uses `irt.config.ts` in the directory the client starts it in,
which isn't always your project. An agent can also name a project in each
call.

### Credentials

The server uses the CLI's saved login from `irt login`, read on every
call, so logging in again takes effect without a restart. To use a token
instead, such as a project API key, set `IRT_TOKEN` in the server's
environment:

```sh
claude mcp add irt -e IRT_TOKEN=irt_key_... -- npx -y @irtio/cli mcp
```

An API key acts on its one project, so `list_projects` and `whoami` need
a personal login. The docs tools need no login at all.

## Tools

Every result is at most 32,000 characters, about 8,000 tokens. A docs
page longer than that ends with the section to read next, and a large
room state or log is cut with a note saying how to narrow it.

### Docs

| Tool | What it does |
|---|---|
| `list_docs` | Every docs page by section, with its id and description |
| `search_docs` | The sections that best match some keywords, each with a snippet and the `read_doc` arguments to read it |
| `read_doc` | A page as Markdown, or one section by its heading. Takes a page id such as `guides/agents`, a `/docs/...` link or a docs URL |

### Project, read-only

Each takes an optional `project` slug, which defaults to the server's
project.

| Tool | What it does |
|---|---|
| `whoami` | The user, account and credit balance the login acts as |
| `list_projects` | The account's projects |
| `project_status` | The project's region, settings, client config, live build, and active rooms and players |
| `list_builds` | Builds, newest first, with which is live and each one's `stateVersion` |
| `list_rooms` | Active rooms, or with `status: "all"` hibernated ones too, a page at a time |
| `get_room` | One room's status, build, size, join code and players. Doesn't wake it |
| `get_room_state` | A room's `room.state`. Wakes a hibernated room, which bills room-hours until it hibernates again |
| `tail_logs` | The newest room host output, optionally for one room and since a time such as `15m` |
| `usage` | Room-hours, traffic and cost by day |
| `list_bans` | The bans in force |

### Writes, with `--allow-writes`

| Tool | What it does |
|---|---|
| `create_room` | Creates a room, optionally public, with a join code, size, retention or meta |
| `delete_room` | Deletes a room and its room state for good |
| `send_room_message` | Sends a server message to a room and returns its reply; wakes it |
| `make_build_live` | Makes a build live, which rolls back when the build is older |
| `ban_player` | Bans a player from every room, for a while or for good |
| `unban_player` | Lifts a ban |

## Allowing writes

Without `--allow-writes` the server doesn't list the write tools at all,
and tells the agent to ask you for them. With it, an agent with your
login can delete rooms, roll back the live build and ban players, so
allow writes only when you want the agent to do that, and prefer a
project you use for testing:

```sh
claude mcp add irt-staging -- npx -y @irtio/cli mcp --project space-race-staging --allow-writes
```

The server tells the agent to confirm with you before deleting rooms,
making a build live or banning a player. `delete_room`,
`send_room_message`, `make_build_live` and `ban_player` are marked
destructive, so clients that ask before such calls ask you. Deploying
isn't a tool: the agent runs `irt deploy` like any other command, with
your client's usual approval.
