# MCP server

Every machine tool, plus three tools that answer from the server's own record, over one MCP
endpoint per contour.

**In short:** Streamable HTTP at `https://<contour>.cmdop.ai/mcp/` with `Authorization: Bearer <agent-token>`.
Call `machines_list` first.

## Endpoint

| | |
|---|---|
| URL | `https://<contour>.cmdop.ai/mcp/`, the address the Connect panel shows |
| Transport | MCP streamable HTTP, answers as JSON; a server update does not drop a connected client |
| Sign-in | an agent token as `Authorization: Bearer`, or browser sign-in (OAuth) for clients that take only a URL |
| Who may connect | agents only: the owner token does not open the MCP server |

How to set up each client: [Connect an agent](https://docs.cmdop.ai/guides/connect.md).

## Tools

- Every [machine tool](https://docs.cmdop.ai/reference/tools.md), with one more argument, `machine`: the machine's name (as
  `machines_list` shows it) or id. It may be left out when only one machine is online.
- The screen tools appear only while a machine offers them.
- The three tools below, which only the MCP server has.

What a connected agent may call is set by the owner: its grant and each machine's ceiling. A
refused call returns [`denied`](https://docs.cmdop.ai/reference/errors/denied.md) and names the missing permission.

### `machines_list`

The owner's machines: name, id, whether each is online and since when (unix seconds), and its
activity (tasks and calls in the last 7 days). No arguments.

### `tasks_list`

Everything running now, by author: `tasks` started through CMDOP, and `outside`, the other
processes on each machine, attributed to an agent (`agent:claude-code`, `agent:codex`) or the user.

| Argument | Type | Required | Meaning |
|---|---|---|---|
| `machine` | `string` | no | Only this machine (name or id). Default: all machines. |

### `history_search`

Past tasks, tool calls and agent sessions, newest first. Calls are listed without their arguments.

| Argument | Type | Required | Meaning |
|---|---|---|---|
| `kind` | `("tasks" \| "sessions" \| "calls")[]` | no | What to return. Default: all three. |
| `machine` | `string` | no | Only this machine (name or id). |
| `author` | `string` | no | `owner`, `agent:` (every agent) or `agent:<name>`. |
| `task` | `integer` | no | Only this task: its row and the calls that started or named it. |
| `text` | `string` | no | Text in any case: a task's command, folder or error; a session's path or id; a call's tool name. |
| `since` | `integer` | no | At or after this time, unix seconds. |
| `until` | `integer` | no | Before this time, unix seconds. |
| `limit` | `integer` | no | At most this many of each kind (default 50, at most 200). |

## Errors

A refused or failed call is a tool error whose text is `<code>: <message>`, with a `details:` line
when there are details. Decide by the code: [error codes](https://docs.cmdop.ai/reference/errors.md).
