# MCP commands

> Every function of the digital human is a named command. How to discover them, call them, and react to their outcomes.

Every function of the digital human — speaking, switching the character, changing the volume, transparency, language, chat — is an **MCP command** with a name such as `aimigo.audio.setVolume`. Your web page, the HTML UI in the apps and AI agents all use the same commands, and every command has a minimum role ([permissions](https://aimigo.live/docs/permissions.md)).

## Discover instead of memorising

An AI agent does not need a full list in its prompt. It needs two commands, and finds everything else with them:

| Command | Input | Returns |
|---|---|---|
| `aimigo.commands.list` | `{ category?, includeSchema? }` | every command **you** may use: `name`, `description`, `category`, `usage` (one line such as `aimigo.audio.setVolume { volume: number (required) }`), `minRole`, `keywords`; with `includeSchema: true` also the JSON schema of the input |
| `aimigo.skills.list` | `{}` | every skill you may use: `id`, `title`, `summary`, `keywords` |

Then:

| Command | Input | Returns |
|---|---|---|
| `aimigo.commands.search` | `{ query, limit? (10, max 50), category? }` | best matches with input schema; words in English or German (`"volume"`, `"Lautstärke"`, `"switch character"`) |
| `aimigo.commands.get` | `{ name }` | one command with its input schema |
| `aimigo.skills.get` | `{ id }` | the skill text (Markdown) that teaches one job, e.g. how to build the HTML UI |
| `aimigo.permissions.getCaller` | `{}` | your role and how many commands and skills you may use |

A command you may not use does not appear in lists and searches, and calling it answers `PermissionDenied`.

## Calling a command

### From a web page

```js
const dh = Aimigo.default;
await dh.ready;
const volume = await dh.call('aimigo.audio.getVolume', {});
await dh.call('aimigo.audio.setVolume', { volume: 0.6 });
const found  = await dh.call('aimigo.commands.search', { query: 'language' });
```

Calls from a web page always run with the role **User**.

### From the desktop app (local HTTP)

The Windows app (integration mode) listens on `127.0.0.1:7241`, only on the local machine:

| Endpoint | Purpose |
|---|---|
| `GET /mcp/health` | is the app running |
| `GET /mcp/tools/list` | all commands of the caller's role with schemas |
| `POST /mcp/tools/call` | body `{ "tool": "<name>", "input": { … } }` |

```bash
curl -s -X POST http://127.0.0.1:7241/mcp/tools/call -H "Content-Type: application/json" -d "{\"tool\":\"aimigo.commands.search\",\"input\":{\"query\":\"volume\"}}"
```

Browser pages may call this port only from the origins listed in the app's access policy; all other web sites get `403 OriginNotAllowed`, so a web page you visit cannot remote-control the app. A caller can lower its own role with the header `X-Aimigo-Role: user` (for example to test what an end user sees), never raise it.

### From the HTML UI inside the app

Elements of the HTML UI are bound to commands with attributes such as `data-mcp-tool="aimigo.audio.setVolume"` (see [HTML UI](https://aimigo.live/docs/html-ui.md)). Clicks run with the role **User**.

## Answers

Every call answers once. Over the local HTTP port:

```json
{ "success": true, "data": { "volume": 0.6 } }
{ "success": false, "error": { "code": "PermissionDenied", "message": "…" } }
```

From a web page the player passes the same answer on as a `result` message with `success`, `data`, `error` (text) and `errorCode` ([player protocol](https://aimigo.live/docs/player-protocol.md)); `dh.call` resolves with `data` or rejects with an `Error`.

## Long operations and events

Commands that start a transition (character, transparency, scene) answer at once:

```json
{ "operation": "started", "status": "loading", "completionEvent": "character" }
```

The real outcome follows as an **event** with that name:

```js
dh.on('event', e => {
  if (e.name === 'character') console.log(e.data.success ? 'character ready' : e.data.errorCode);
});
```

| Event | Raised by | Data |
|---|---|---|
| `character` | `aimigo.character.set`, `aimigo.transparency.set { characterId }` | `success`, `characterId`, `errorCode?`, `error?` |
| `transparency` | `aimigo.transparency.set` | `success`, `enabled`, `errorCode?`, `error?` |
| `settings` | setters of base functions (volume, mute, language, microphone, display mode, …) | `name`, `value` |

## Base functions of the app UI

Every function of the app's own interface is available as a command, so an HTML UI or an agent can do everything a user can do by clicking:

| Function | Commands |
|---|---|
| Volume, mute | `aimigo.audio.setVolume`, `aimigo.audio.getVolume`, `aimigo.audio.setMuted` |
| Fullscreen | `aimigo.ui.setFullscreen`, `aimigo.display.getMode` |
| Language | `aimigo.settings.getLanguages`, `aimigo.settings.setLanguage` |
| Microphone | `aimigo.settings.getMicrophones`, `aimigo.settings.setMicrophone`, `aimigo.chat.startRecording`, `aimigo.chat.stopRecording` |
| Chat | `aimigo.chat.sendMessage`, `aimigo.ui.setChatWindow` |
| Character, room, transparency | `aimigo.character.list/getCurrent/set`, `aimigo.scene.list/getCurrent/set`, `aimigo.transparency.set/getState` |
| Navigation | `aimigo.camera.setNavigationMode` (2D/3D) |
| Glass look of panels | `aimigo.ui.setGlass`, `aimigo.ui.getGlass` |
| All settings at once | `aimigo.settings.getAll` |

The complete, generated list with roles and inputs: [command reference](https://aimigo.live/docs/mcp-reference.md).

## Stability

Command names stay stable: changed behaviour gets a new command, and the old name keeps working. Read the input schema with `aimigo.commands.get` rather than hard-coding it in an agent.
