---
title: "AI Agents (MCP)"
description: "Let AI agents such as Claude Code, Codex, Gemini CLI or a local model annotate in LumiScan Annotation Web through the Model Context Protocol: switching it on, access tokens, project settings, client configurations, tools and how the boxes of agents are marked"
product: "LumiScan Annotation Web"
component: "lumiscan-annotation-web"
version: "2.7.0"
display_version: "2.7.0.0"
latest_version: true
language: "en"
url: "https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/ai-agents.html"
---

# AI Agents (MCP) – LumiScan Annotation Web

From version 2.7 AI agents work in annotation projects through the Model Context Protocol (MCP): Claude Code, Claude Desktop, OpenAI Codex, Gemini CLI, VS Code with GitHub Copilot, LM Studio, Cursor, Open WebUI and other MCP clients, with a model in the cloud or a local one. An agent signs in with a user’s personal access token and acts as that user:

- it never has more rights than the user, and only the scopes of its token,
- it works only in projects that allow AI agents,
- every box it saves is marked as an AI box until a person corrects it.

Typical uses: an agent pre-annotates a folder and a person checks its boxes; an agent compares the annotators of a folder or looks for images with a missing label; a project admin asks an agent how far a project is.

[Video](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/_images/videos/ai-agents.mp4)

> [!IMPORTANT]
> An agent whose model runs in the cloud sends what it reads to that service: file names, boxes and, if the project allows it, the image content. Where images or annotations must not leave the company, use a local model, or set **Agents may see** to **Only names, sizes and boxes, no pixels** (see [Allowing a project](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/ai-agents.html#project-settings)).

## Switching it on

AI agents are off by default. Add a section `mcp` to the [configuration](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/configuration.html) and restart the server:

```json
  "mcp": {"enabled": true},
```

The server then answers at `<public_url>/mcp` (Streamable HTTP transport, JSON-RPC 2.0). Further keys, all optional:

| Key in `mcp` | Meaning |
| --- | --- |
| `enabled` | `/mcp` is switched on. Default `false`: the address does not exist. |
| `access_tokens` | Users may create access tokens. Default `true`. |
| `allowed_origins` | Browser origins allowed besides the server’s own address (`Origin` header), for example `["https://chat.example.com"]`. Requests from other origins are refused. |
| `rate_limit_per_minute` | Tool calls per token and minute. Default 120. |
| `max_image_px` | Longest side of the images sent to agents, in pixels. Default 2048. |
| `upload_max_mb_per_call` | Largest piece of an image upload in one tool call, in MB. Default 16. For the uploads of a later version. |
| `token_default_days`, `token_max_days` | Validity of new tokens in days: suggested 90, at most 365. |

On the single-PC installation `/mcp` only answers on the PC itself (127.0.0.1); agents need an access token there too.

## Access tokens {#access-tokens}

![User menu with the item AI agents (MCP)](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/_images/screens/ai-user-menu.png)

Every user creates the tokens for their agents under their name → **AI agents (MCP)** → **New token**:

|   |   |
| --- | --- |
| Name | For example "Claude Code on my laptop". The name is also the agent’s name: its own annotator version is `<your name>~<agent name>`. Tokens with the same name act as the same agent. |
| Scopes | What the agent may do, see the table below. **read** and **annotate** are ticked. |
| Valid for | Days, suggested 90, at most 365 (`token_default_days`, `token_max_days`). |
| Projects | None ticked: all of your projects. Otherwise only the ticked ones. |

![Dialog New access token: name, scopes, validity in days and projects](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/_images/screens/ai-new-token.png)

**Create token** shows the token (`lsa_pat_…`) once, with a button to copy it and ready configurations for the AI clients ([Connecting an AI client](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/ai-agents.html#connecting)). Copy it right away: the server keeps only a hash of it and cannot show it again. Whoever has the token can work in your projects as you, within its scopes.

![The new access token, shown once, with a copy button and the configuration for Claude Code](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/_images/screens/ai-token-created.png)

| Scope | Allows |
| --- | --- |
| read | Projects, folders, images, boxes, history, revision notes, progress |
| annotate | Saving boxes, box suggestions, done marks, adding labels, revision notes, rating images with the network |
| review | Agreement statistics, comparing annotators, preview of the training export |
| admin | Reserved for tools for projects and members in a later version |

A tool needs its scope in the token **and** the user’s role in the project: saving boxes, for example, needs **annotate** and the annotator role.

The list in **AI agents (MCP)** shows your tokens with their scopes, validity and when and by which client they were last used. **Revoke** ends a token at once. The tokens of a user are also revoked when the user is disabled or deleted, or when an admin resets the user’s password. With `"access_tokens": false` nobody can create new tokens.

![Dialog AI agents (MCP): the access tokens with scopes, validity and last use, button New token](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/_images/screens/ai-tokens.png)

## Allowing a project {#project-settings}

In the [project settings](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/project-settings.html), section **AI agents** (shown when AI agents are switched on), project admins decide what agents may do in the project:

![Project settings, section AI agents](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/_images/screens/ai-settings.png)

|   |   |
| --- | --- |
| Allow AI agents in this project | Off by default. Without it agents cannot work in the project. |
| Agents may see | **Image content (pixels, crops)**, or **Only names, sizes and boxes, no pixels**: then `get_image` is refused and no image content reaches the agent. |
| Agents save boxes | **As their own annotator version** (`<user>~<agent>`, see [Agents as annotators](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/ai-agents.html#annotators)), **Directly into the reference** (only in projects with one annotation per image) or **Only as suggestions a person accepts**. The last one is the default but not available yet in version 2.7: agents' saves are refused. Choose one of the other two to let agents save boxes. |
| An agent’s version counts towards the annotators per image | See [Agents as annotators](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/ai-agents.html#annotators). |
| Agents may upload images | Reserved for a later version. |

## Connecting an AI client {#connecting}

An AI client needs the server address `<public_url>/mcp` and the header `Authorization: Bearer <token>`. After **Create token** the dialog shows the configuration for each client with your address and token filled in, for example:

- **Claude Code:**
  ```shell
  claude mcp add --transport http lumiscan-annotation https://annotation.example.com/mcp --header "Authorization: Bearer lsa_pat_..."
  ```
- **Codex:** In `~/.codex/config.toml`, with the token in the environment variable `LUMISCAN_ANNOTATION_TOKEN`:
  ```toml
  [mcp_servers.lumiscan_annotation]
  url = "https://annotation.example.com/mcp"
  bearer_token_env_var = "LUMISCAN_ANNOTATION_TOKEN"
  ```
- **Gemini CLI, VS Code (GitHub Copilot), LM Studio, Cursor:** A JSON entry `lumiscan-annotation` with the address and the header, in the form the client expects; the dialog shows each one.
- **Open WebUI:** **Admin settings → External tools → +**: type MCP (Streamable HTTP), the address, authentication **Bearer** with the token.

Then talk to the agent, for example: "List my annotation projects", or "Annotate the images of folder 2026-11-20 in project line-5 that have no boxes yet: take the box suggestions, check each box in the image and save".

## What agents can do

An agent sees only the tools of its token’s scopes. Every tool call goes through the same checks as the web app: roles, edit locks, the check for changes saved meanwhile, several annotators per image. The annotation files it writes are the same as those of the web app.

| Tool | Scope | What it does |
| --- | --- | --- |
| `list_projects` | read | The projects the user takes part in, with the user’s roles and whether AI agents are allowed there |
| `get_project` | read | Labels, region of interest, several annotators per image, box suggestion and AI agent settings |
| `list_folders` | read | The folders of a project |
| `list_images` | read | The images of a folder with their state (annotated, boxes, labels, done, open notes, AI boxes), with filters |
| `get_progress` | read | How far a project is, per folder and in total |
| `get_annotations` | read | The boxes of an image: the reference or, with several annotators, the agent’s own version |
| `get_image` | read | The image scaled to `max_image_px`, optionally a region of it and with the boxes drawn in (not with **Only names, sizes and boxes**) |
| `get_history` | read | The saved versions of an image’s boxes |
| `list_notes` | read | The revision notes of an image, or the open notes of the project |
| `get_uncertainty_status` | read | How far the network’s rating of a folder is |
| `fit_box` | read | The smallest oriented box around a set of points, in the box convention of the project |
| `save_annotations` | annotate | Save the boxes of an image, as the project’s **Agents save boxes** setting says |
| `suggest_boxes` | annotate | [Box suggestions](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/box-suggestions.html) for an image from the project’s networks |
| `mark_done` | annotate | Mark an image as done, or remove the mark |
| `add_label` | annotate | Add a label to the project’s list |
| `add_note` | annotate | Leave a [revision note](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/revision-notes.html) on an image, optionally at a point |
| `reply_note` | annotate | Reply to a revision note or mark it done |
| `start_uncertainty_scan` | annotate | Let the network rate a folder’s images, so the most uncertain ones come first |
| `get_statistics` | review | Agreement between the annotators of a folder or project |
| `compare_annotators` | review | All annotators' boxes of one image, matched, with the differences |
| `preview_training_export` | review | What an [export for LumiScan Training](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/export-for-lumiscan-training.html) would contain |

Boxes are given as centre, width, height and angle in radians, clockwise, the same convention as the [annotation files](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/annotation-files.html) (see [Box Orientation](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/box-orientation.html)).

## AI boxes {#box-origin}

The server marks every box an agent saves, in the box’s metadata:

```json
"origin": {"type": "ai", "agent": "Claude Code on my laptop", "client": "claude-code", "user": "anna", "at": 1795620000000}
```

When a person later moves, resizes, turns or relabels the box, the type becomes `ai-corrected`, with `correctedBy` and `correctedAt`. The server sets these marks on every save, so a client can neither forge nor lose them; they go into the CSV and JSON files and into the COCO export.

In the web app:

- the viewer labels such boxes **AI**, and **AI ✎** once a person has corrected them,
- the image list shows an AI badge on images with AI boxes; hovering over it says how many there are and how many a person has corrected,
- [Show](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/finding-and-sorting-images.html) offers **With boxes from AI agents** and **AI boxes corrected by a person**,
- the [history](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/history-and-undo.html) names the user, the agent and its client.

![Image list with AI badges; the open image has boxes from an AI agent, one of them corrected by a person](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/_images/screens/ai-boxes.jpg)

## Agents as annotators {#annotators}

With **Agents save boxes: As their own annotator version** an agent saves its own version, kept as `<user>~<agent>` like the versions of the people ([Several Annotators per Image](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/several-annotators-per-image.html)). Several agents of one user, and a person and their agents, therefore never overwrite each other. A service account for agents is simply a user of its own.

- With **An agent’s version counts towards the annotators per image**, an agent’s version counts like a person’s (at most one agent per image), so for example one person and one agent can reach the consensus of a project with two annotators per image.
- Without it, the agent’s version is an extra vote: the comparison shows it, but the image still needs the set number of people.

**Directly into the reference** is refused in projects with several annotators per image.

## Security and limits

- Tokens are stored only as a hash and shown only once. They work only for `/mcp`, not for the [REST API](https://docs.hdvisionsystems.com/en/lumiscan-annotation-web/rest-api.html).
- Five invalid tokens from one address block that address for 15 minutes.
- `rate_limit_per_minute` limits the tool calls per token.
- Browser requests from foreign origins are refused unless listed in `allowed_origins`.
- Sessions end after 24 hours without use. The server speaks the MCP protocol versions 2025-11-25, 2025-06-18 and 2025-03-26.
- The log names the MCP client of every tool call; the save history names the user and the agent.
