# AI Assistants (MCP)

New in 2.0.10. KOJA Cloth Tool runs a local **MCP server** ([Model Context Protocol](https://modelcontextprotocol.io)), so Claude and other AI assistants can work in the app for you. Ask for something in plain words, such as "add these ten .ydd files as male jbib and build the pack for FiveM", and the assistant does it in the open app. It can:

- open projects;
- add and edit items and textures;
- run the checks and their fixes;
- build packs;
- take a screenshot of the window to see what you see.

The assistant reaches the app the same way your clicks do. Every change shows in the window straight away and can be undone with **Ctrl+Z**, like your own.

:::hint{type="info" title="Free and Premium"}
On the free plan, an assistant can use every free feature: projects, items, textures, checks, building and so on. It cannot use the paid ones, such as the Texture Creator, Model Studio, Texture Optimization or the Ped Library. It also cannot run scripts in the app's page. These follow the same rules as the buttons in the window. See [Free and Premium](#free-and-premium).
:::

## Turning it on

Open **Settings** → **Integrations** → **AI assistants (MCP)**.

- The **AI assistants** switch is on by default. Switch it off and no assistant can connect.
- The line under it says whether the server is running and at which address, for example `http://127.0.0.1:47830/mcp`.
- **Regenerate token** issues a new access token. Every assistant set up with the old token has to be set up again.

:::hint{type="success" title="Only on this PC"}
The server only answers on this computer (`127.0.0.1`), and only to a client that sends its access token. Nothing on your network or the internet can reach it, and a web page in your browser cannot reach it either.
:::

## Connecting an assistant

Under **Connect an assistant**, pick the one you use and press **Copy**. The copied text already contains your address and token. Press **Show** to see the token, and **Hide** to hide it again.

::::tabs
:::tab{title="Claude Code"}
Run the copied line in a terminal. It looks like this:

```bash
claude mcp add --transport http koja-cloth-tool http://127.0.0.1:47830/mcp --header "Authorization: Bearer <token>"
```

Add `--scope user` after `add` to use the tool from every folder, not only the current one. Check it with `claude mcp list`. It should show `koja-cloth-tool` as connected while the app is open.
:::
:::tab{title="Claude Desktop"}
Add the copied entry to `claude_desktop_config.json`, then restart Claude Desktop:

```json title="claude_desktop_config.json"
{
  "mcpServers": {
    "koja-cloth-tool": {
      "command": "C:\\path\\to\\KojaClothTool.exe",
      "args": ["--mcp"]
    }
  }
}
```

The copied entry has the real path to your `KojaClothTool.exe`. This entry needs no token. Claude Desktop starts the tool by itself if it is closed.
:::
:::tab{title="Other MCP clients"}
Any client that speaks **Streamable HTTP** can connect with the address and this header:

```
http://127.0.0.1:47830/mcp
Authorization: Bearer <token>
```

A client that only starts programs (stdio) can use `KojaClothTool.exe --mcp`, as Claude Desktop does.
:::
::::

The port is usually `47830`. If something else on your PC already uses it, the app takes the next free one, up to `47849`, and keeps using it after a restart. Settings shows the address in use.

## What the assistant can use

The server gives the assistant twelve tools. You never call them yourself, but they explain what an assistant can and cannot do.

| Tool | What it does |
| --- | --- |
| `app_status` | The app version, the open project and its counts. Assistants start here. |
| `rpc_methods` | Lists every action the app can do (about 450), with what each one needs. |
| `rpc_call` | Runs any of those actions. This is how an assistant does "everything the window can do". |
| `project_open`, `project_current` | Opens a project, or says which one is open. |
| `items_list`, `item_get` | Reads the project's items. |
| `validate` | Runs the pre-build checks. |
| `build_start` | Starts a build. |
| `events` | Follows what the app reports, such as build progress and new findings. |
| `screenshot` | A picture of the main window. |
| `ui_eval` | Runs a script in the app's page to read or operate it. Premium. |

Actions that open a Windows file dialog wait for a person to click it. Ask the assistant to pass file paths instead, for example "import F:\clothes\jacket.ydd".

## Free and Premium

The MCP server itself is free. It follows the same plan as the window:

- **Free plan**: every free feature works. Paid features are refused with a message naming the feature, the same message the window shows. `ui_eval` is refused too, because a script in the page could press any button.
- **Premium**: everything works, including `ui_eval`.

Build limits apply to assistants too. A build an assistant starts on the free plan counts towards your 8 free builds, like one you start yourself.

## Good to know

- **Keep the app open.** The HTTP connection only works while KOJA Cloth Tool is running. The `--mcp` connection starts the app if it is closed.
- **Watch your project.** The assistant works on the project that is open in the window. Save before you let it make large changes. You can undo each change, and [Team Collaboration](/cloth-tool/about-the-tool/team-collaboration) version history can restore a whole project.

## If it does not connect

| What you see | What to do |
| --- | --- |
| Settings says **Off. AI assistants cannot connect.** | Turn the **AI assistants** switch on. |
| `401` or "Missing or wrong bearer token" in the assistant | The token is wrong or old. Copy the setup line again from Settings. |
| The assistant cannot reach the address | Check that the app is open, and that the port in the setup matches the one in Settings. |
| "…is a premium feature" | That action is paid. See [Free and Premium](#free-and-premium). |

## Related pages

- [Settings](/cloth-tool/about-the-tool/settings)
- [Building](/cloth-tool/about-the-tool/building)
- [Validation](/cloth-tool/about-the-tool/validation)
- [Live Link](/cloth-tool/about-the-tool/live-link)
