# MCP Tools Reference: Add MCP Servers to Your CLI Agent Use this reference to add MCP servers to Octomind, an MCP client, and to inspect the tools available to your CLI agent session. It covers built-in controls, tap capabilities, external MCP servers, and project-local tools. ## Get Started Start a session, then inspect its actual tool surface: ```bash octomind run ``` ```text /mcp list /mcp full ``` `/mcp full` shows the schemas advertised by your enabled servers. JSON examples below are arguments for the named MCP tool, not slash commands; where several objects are shown, make one tool call per object. ## Architecture Octomind ships three builtin MCP servers (`core`, `orchestration`, `runtime`), plus an auto-discovered `local` server for project scripts: | Server | Type | Description | |--------|------|-------------| | `core` | builtin | Session-memory retrieval (`recall` when attention or governance is enabled, `context` in authorized tap children) and `code` (scripts that call external tools; see [below](#calling-external-tools-from-scripts-code-tool)) | | `orchestration` | builtin | Delegation (`tap`), scheduled messages/tool calls (`schedule`), and event streams (`monitor`) | | `runtime` | builtin | Harness reconfiguration: register MCP servers, load skills, capability | | `local` | builtin | Project-local shebang-script tools auto-discovered from `/.agents/tools/`. See [Local Tools](17-local-tools.md). | Filesystem tools come from external servers such as `octofs`; they are not implemented by Octomind. Use your installed capability manifests or an explicit server configuration to enable them. Planning is done by a plugin (Besydr, when it is installed and enabled) rather than by an MCP tool. Octomind keeps the plan state the plugin writes and shows it with `/plan`. See [Besydr plugin](14-supervisor.md). Additional servers can be added via `[[mcp.servers]]` config as `http` or `stdio` types. ## Configure External MCP Servers ### Adding HTTP Servers Replace the endpoint with your server URL and set `CUSTOM_API_TOKEN` to its issued token before starting Octomind. Add `auto_bind` or reference the server from your role so it becomes visible. ```toml [[mcp.servers]] name = "custom_api" type = "http" url = "https://api.example.com/mcp" headers = { Authorization = "Bearer {{ENV:CUSTOM_API_TOKEN}}" } # optional timeout_seconds = 30 tools = [] ``` `headers` is sent on every request. Values may use `{{ENV:KEY}}` placeholders; a server whose placeholders reference unset or empty env vars cannot connect and is logged as a startup error. When an `Authorization` header is configured it is used as-is and OAuth discovery is disabled for that server; without one, Octomind runs MCP Authorization Discovery (RFC 9728) and attempts OAuth authentication when the server requires it. Set the token issued by your server in the environment before launch: ```bash export CUSTOM_API_TOKEN='token-issued-by-your-server' octomind run ``` ### Adding Stdio Servers This example requires your Python MCP module `my_mcp_server` to be installed. `env` passes values to the child, and `cwd` sets its working directory. Replace these deployment-specific values with your server settings. ```toml [[mcp.servers]] name = "custom_tools" type = "stdio" command = "python" args = ["-m", "my_mcp_server"] env = { API_TOKEN = "{{ENV:CUSTOM_API_TOKEN}}" } cwd = "." timeout_seconds = 30 tools = [] ``` For tool calls, `timeout_seconds` is an idle deadline rather than a total runtime limit: every MCP progress notification resets it. Calls are still bounded by an absolute cap of 20 times this value. While you answer a server's question for the call (see [Server Questions](#server-questions-elicitation)), both deadlines hold: the idle deadline restarts when the question closes and the absolute cap moves out by the time it stayed open. After a timeout, completion and side effects may be unknown, so inspect state before retrying; prefer a narrower operation, a background/monitor workflow, or an MCP task for inherently long-running work. ### Server Questions (Elicitation) An MCP server can ask you for input in the middle of a tool call: confirm a refund, pick an environment, fill in a missing detail, or open a sign-in page. This is MCP elicitation. Octomind answers it wherever a person is present: | Where the session runs | How you answer | |---|---| | Interactive CLI (`octomind run`) | A prompt in the terminal: one line per field, with type checks, then `Send? [Y/n]`. Ctrl+C cancels. URL questions show the full URL and its domain and open it only after you confirm. | | WebSocket client (`octomind server`) | The client receives an `elicitation` frame and answers it, when it bound with the `elicitation_v1` capability ([WebSocket server](../integration/01-websocket-server.md)). | | ACP client (`octomind acp`) | Forwarded as ACP `elicitation/create` when the client advertised `clientCapabilities.elicitation` ([ACP protocol](../integration/02-acp-protocol.md)). | The question is **declined** without asking anyone when nobody can answer: piped and `--format` runs, subagents and background tasks, clients that did not opt in, and calls Octomind cannot attribute to one session (see below). Your answer — accept with the values, decline, or cancel — goes back to the server unchanged. An open question ends as `cancel` when its tool call ends, when the session closes, or when the WebSocket client answering it disconnects without another taking over. Servers on MCP 2026-07-28 return their question as part of the tool call's result, so it always reaches the right session. Older servers push it while the call runs: over HTTP it carries the call it belongs to, but over stdio it does not, so when tool calls from more than one session are waiting on the same stdio server (a daemon serving several clients), the question is declined rather than guessed. Octomind offers older servers protocol 2025-11-25, the first with URL questions. ### Auto-Bind to Roles Use exact role tags. This example activates the server for either listed role: ```toml [[mcp.servers]] name = "my_server" type = "http" url = "http://localhost:3000/mcp" timeout_seconds = 30 tools = [] auto_bind = ["developer", "assistant"] ``` ### Tool Filtering Use names advertised by your server; `search` and `get_record` below are example server-specific names. ```toml # Only expose specific tools [[mcp.servers]] name = "local_api" type = "http" url = "http://localhost:3000/mcp" timeout_seconds = 30 tools = ["search", "get_record"] # Alternative wildcard filter: tools = ["get_*"] ``` ### Override Files (mcp-*.toml) Files named `mcp-*.toml` have special load order behavior — they are loaded **after** all other `*.toml` files, regardless of alphabetical order. This ensures they can reliably override same-named servers. **Use Case: Persisting Dynamic Servers** When you use `mcp(action="persist", name="my_server")`, Octomind writes: - File: `/mcp-my_server.toml` - Content: Full server config; enabled servers get `auto_bind = [""]`, disabled servers clear it On next startup, this file is loaded after all other config files, so it: 1. Overwrites any existing server named `my_server` (last wins for same-name entries) 2. Auto-binds to the role that persisted it if the server was enabled when persisted **Example persisted override file:** ```toml [[mcp.servers]] name = "my_server" type = "http" url = "http://localhost:3000/mcp" timeout_seconds = 30 tools = [] auto_bind = ["developer"] ``` This server will automatically be available for the `developer` tap agent on next startup. ## Core Server Tools ### Planning by a plugin There is no model-callable `plan` MCP tool. Focused tasks execute directly. The plan comes from a plugin such as Besydr, which changes the plan octomind keeps for the session. Use this session command to inspect the current checklist: ```text /plan ``` ### `recall` — Retrieve Archived Compression Blocks `recall` is advertised only when compression attention or its governance layer is enabled. It accepts `ids`, an array of one or two session handles such as `block17` (or legacy `b:` IDs) cited by compressed `` units, verifies them against the current session's sidecar registry, and returns their role labels and original text (with surrounding whitespace trimmed). Unknown IDs and sessions without an archive return errors; larger recalls require another call. Copy an actual ID from your summary into this payload: ```json {"ids": ["block17"]} ``` The ID shown illustrates the format; it must be replaced with a block ID cited in your own session. ## Orchestration Server Tools ### `context` — Search the Conversation Behind a Delegation Same-workspace `tap run` agents can search earlier user decisions, assistant discussion, and selected evidence from their authorized ancestors. Pass `query` and optionally `scope` (`ancestors`, `parent`, or `root`) and `limit` (defaults to 5, with a maximum of 12). Results include a source label, ancestor depth, reference, and exact excerpt. Check the lexical and semantic coverage flags before treating an empty result as conclusive. Each ancestor is fixed at its dispatch boundary. Resuming an existing run keeps the same boundaries. Use `tap send` to send new instructions to a running agent. Use `recall` with a compression block ID to retrieve exact archived material from the current session. If the parent cancels and removes a turn, ancestor search excludes it, including from existing grants. ### `tap` tool: Run Agents from Taps Delegate work to an agent installed via a tap (e.g. `developer`). Each agent brings its own system prompt, model preferences, and MCP tool kit. Use `tap` to hand off a focused task, monitor what's running, and stop a run. The runtime matches the prompt to an agent. The caller can also name one with `role`. An agent that declares the `orchestration` capability can also start copies of itself: `role` set to its own name, or no `role` when it reaches no other agent. Each copy is a fresh session of the same agent, with no memory of the caller's conversation. Several writable copies can run at once for independent parts, each on its own files. A copy cannot start further copies; its `run` returns an error telling it to do its part itself. **Parameters:** | Parameter | Type / requirement | Meaning | |-----------|--------------------|---------| | `action` | string, required | `run`, `create`, `persist`, `unpersist`, `list`, `stop`, `send`, `capability`, `workflow` | | `prompt` | string | Task for `run` (the runtime matches it to an agent), user message for `send`, or capability intent for `capability`. Required for those actions. | | `role` | string | Agent to start for a new `run` without matching: an agent name (`developer`), among the agents the caller may reach. Optional. Ignored when resuming with `session`. For `persist` and `unpersist`: the tag `create` returned. | | `readonly` | boolean | With `run`, `true` starts the child in a read-only session: only tools whose MCP `readOnlyHint` annotation is true are offered and can run, so the child has no shell and cannot delegate. Optional, default `false`. A run keeps the mode it started with: `true` together with `session` on a run that was started writable is an error. | | `session` | string | Run id (e.g. `tap-developer-run3`). Required for `stop` and `send`. For `run`, supply this to resume an existing run instead of starting a new one. | | `workdir` | string | Working directory the role operates in. Optional — defaults to the parent session's current cwd. | | `name` | string | Lowercase slug naming the role for `create`; workflow name for `workflow`. | | `description`, `system` | strings | Required for `create`: a one-line description and the system prompt. | | `model`, `tools` | string, array of strings | Optional model and tool names for `create`. Omitted `tools` means no tools. Each name must be a tool the creator can call now; tools of the orchestration, runtime and local servers, and `code`, `search_tools`, `context`, cannot be granted. | | `input` | string | Input text for `workflow` (required with `name`). | | Action | Description | |--------|-------------| | `create` | Define a private specialist for the current session and return its tag, `:`. A base tap role creates in its own namespace; a local config role creates in the `personal` namespace. Variants, copies, and read-only runs cannot create, save or delete roles. Creating the same name again in the session replaces the definition. | | `persist` | Save a role created in this session to the personal tap, with no approval prompt (same as `mcp persist`). Pass the tag `create` returned as `role`. Saving again overwrites the earlier save. Later sessions find the saved role: `run` can match it and `role` can name it. Refused when another tap provides that tag, when the tag is an alias, or when a file you placed in the personal tap by hand has that name. | | `unpersist` | Delete a role saved with `persist` from the personal tap. Pass its tag as `role`. Only roles in the caller's own namespace can be deleted; files placed there by hand are left alone. | | `run` | Match `prompt` to an agent and launch it in the background (or resume a run via `session`, which reuses the original role without matching). With `role`, start that agent without matching. Returns `{id, role, title, workdir, message}` immediately and injects the reply later. If no agent matches, it starts nothing and returns an error that lists the closest ones. See [Agent matching](#agent-matching). Resuming a run that is still executing a prior turn is rejected with a busy error; use `send` to queue a follow-up while it runs. | | `send` | Queue a user prompt for a running agent owned by this session. Returns immediately; the child processes prompts in order on subsequent turns, keeping its conversation and current work. Requires non-empty `session` and `prompt`. Finished runs must be resumed with `run`; workflows do not accept prompts. A full queue or a run closing its input returns an error. | | `list` | Show every run in this session: id, role, workdir, status (`running` / `done` / `failed` / `cancelled`), start time. | | `stop` | Cancel a running role by id. Sends a watch-channel signal; the run aborts at its next checkpoint. | | `capability` | Run the prompt through the same skill/capability auto-activation path used for user messages. | | `workflow` | Run an installed tap workflow (`name` + `input`) as a background run; the final step's output is injected later. Without `name`, list installed workflows. `stop` with the returned id cancels it. | ```jsonl {"action": "run", "prompt": "Review src/main.rs and report concrete bugs."} {"action": "run", "prompt": "Audit this auth module", "role": "developer"} {"action": "list"} {"action": "send", "session": "tap-developer-run3", "prompt": "Also check cancellation before you finish."} {"action": "stop", "session": "tap-developer-run3"} {"action": "run", "session": "tap-developer-run3", "prompt": "Check the error handling too."} ``` Replace the sample session IDs with IDs returned by `run` or `list`. #### Agent matching The candidates are the agents the caller may reach. A base agent with the `orchestration` capability reaches the variants of its own namespace. Its `# Uses:` header adds agents: a comma-separated list of ``, `:` or `*` for every other agent, variants included. The header is read only on a base agent; a variant reaches only copies of itself. An agent with the header declares the `orchestration` capability; in the community tap `assistant` and `writer` carry it. A caller that is not a tap agent, such as a role from your local config, reaches every installed agent. Candidates are ranked by cosine similarity between the prompt and each agent's title and description, which needs the local embedding model. The best one gets the task when it clears a score threshold and a margin over the second best. When nothing matches, `run` starts nothing and returns an error that lists the five best-ranked candidates by name, title and description. The caller can send the task again with `role` set to one of those names: that agent starts without matching. `role` reaches only the same candidates. A `role` outside the caller's reach is refused with an error that lists the names it can pass instead. A caller that reaches no agent gets `No agent matches this task. Do it with the tools you have, or report that it is outside what you can do.` **Lifecycle.** Tap-runs live for the duration of the parent session. When the parent session exits, all in-flight runs are cancelled. The on-disk role manifest is unaffected. **Non-interactive.** Tap-runs run in non-interactive mode, so `{{INPUT:KEY}}` / `{{ENV:KEY}}` placeholders that would normally prompt stdin instead return a structured error. Resolve interactive placeholders and provide required environment variables before delegation: ```bash octomind run developer ``` The other orchestration tools are [`schedule`](#schedule-tool-scheduled-messages-and-tool-calls) and `monitor`. `monitor` runs an event-stream command, bounds and coalesces output injections, and is inspected through `/status monitors`. Schedules (`schedule1-2`), monitors (`monitor2`), and approved skill manifests (`manifest3`) are named within their session. A saved session reserves a schedule namespace when opened: its second schedule might be `schedule1-2`. Resuming keeps existing schedule IDs and starts a new namespace for new entries. A native background MCP task such as `job1-2` uses a process number and a task number; stop it from the session that launched it. Server-provided resource links keep their original URIs. ### `schedule` tool: Scheduled Messages and Tool Calls The agent's MCP `schedule` tool schedules either a message for future injection or a direct MCP tool call in the current session — at a specific time or the next idle. The user-facing [`/schedule`](../reference/02-session-commands.md#schedule-subcommand-args) slash command remains message-only. **Parameters:** | Parameter | Type / requirement | Meaning | |-----------|--------------------|---------| | `command` | string, required | `"add"`, `"list"`, `"remove"`, `"edit"` | | `message` | string, exactly one payload for `add` | exact text injected as a user message when the entry fires; mutually exclusive with `tool_call` | | `tool_call` | object, exactly one payload for `add` | `{"name":"tool_name","arguments":{...}}`; run an enabled MCP tool directly, without a parent-model turn | | `when` | string, optional for `add` | when to fire. Defaults to `"idle"` when both `when` and `every` are omitted. | | `every` | string, optional | repeat interval — entry re-schedules itself after each firing until removed | **`when` formats** (local timezone): - `"idle"` — fires the next time the session becomes idle (no running taps, no running background jobs) - `"now"` (fires immediately on the next scheduler tick) - Relative: `"in 5m"`, `"in 2h"`, `"in 1h30m"`, `"in 90s"` - Time today: `"15:30"`, `"3:30pm"`, `"9am"` (past times fire tomorrow) - Exact: `"2030-03-22 15:30"` **`every` format** (omit for one-shot): - `"idle"` — fires on every idle transition (pairs with `when="idle"` or omitted) - Same syntax as relative `when` without the `in` prefix — `"10m"`, `"1h"`, `"1h30m"` - Pass `"none"` (or `"off"`) in `edit` to clear an existing interval | Command | Required Params | Description | |---------|----------------|-------------| | `add` | exactly one of `message` or `tool_call` | Schedule a message or tool call. `when` defaults to `"idle"`. `description` and `every` optional. | | `list` | -- | Show pending entries with payloads and countdown | | `remove` | `id` | Cancel future firings by ID, not work already launched | | `edit` | `id` | Update `when`, `description`, or `every`; supplying `message` or `tool_call` replaces the whole payload (never merges arguments). Supply at most one payload. Cannot switch an entry between idle and time modes; remove and add to change modes. | One-shot entries fire once and are removed; repeating entries (`every` set) re-schedule automatically after each firing. Idle entries fire only when the response loop is idle AND no tap-runs or detached shell jobs are running, so messages cannot interrupt in-flight work. Schedules are saved in the session log and restored when that session resumes; they do not fire while the process is stopped. Direct tool calls must be available in the session both when scheduled and when fired. Scheduling does not bypass normal permissions or guardrails: they apply at fire time. Tool calls use the working directory captured when scheduling, and results and errors arrive in the session inbox. Schedules are session-bound, not system cron. Repeating tool calls skip ticks while the same schedule is busy instead of overlapping or queuing executions; a launched `tap` run counts as busy until it finishes. Removing a schedule stops future firings only; use `tap(action="stop", session="")` to cancel an already launched run. For a repeating timer, supply both `when` and `every`; a time interval alone is rejected. Give repeating messages a stop condition. Call `schedule`: ```jsonl {"command": "add", "when": "in 10m", "every": "10m", "message": "Check the deployment status. If complete, remove this schedule using its ID from schedule list."} {"command": "list"} ``` When `tap` is enabled, schedule an agent run directly with ordinary `tap` arguments nested under `tool_call.arguments` — there are no tap-specific schedule fields: ```json {"command":"add","when":"in 5m","tool_call":{"name":"tap","arguments":{"action":"run","prompt":"Review auth"}}} ``` Use `message` instead when the parent agent should interpret the task with conversation context before choosing tools. ### `monitor` — Long-Lived Event Streams The orchestration `monitor` tool has `start`, `list`, and `stop` actions. `start` requires an inline `command` and optionally accepts `description`, `working_directory`, `flush_interval_seconds`, `max_batch_bytes`, `timeout_ms`, and `persistent`. The command runs once through `sh -c`; stdout is delivered to the session inbox in bounded coalesced batches, stderr is diagnostic, and unexpected exit is injected once. Monitors are session-owned, are never auto-restarted, and stop on explicit `stop` or session cleanup. | Monitor option | Default | Accepted range / meaning | |----------------|---------|--------------------------| | `flush_interval_seconds` | `30` | `5`–`3600` seconds between deliveries | | `max_batch_bytes` | `65536` | `1024`–`1048576` bytes retained per batch | | `timeout_ms` | `600000` | `1000`–`86400000` ms lifetime | | `persistent` | `false` | Ignore the deadline until stop or session cleanup | A monitor defaults to a 600000 ms lifetime. `persistent = true` removes that deadline, but session cleanup still stops it. For an existing log file, call `monitor` (requires `sh` and `tail`): ```jsonl {"action": "start", "command": "tail -n 0 -f /tmp/service.log", "flush_interval_seconds": 30, "persistent": true} {"action": "list"} ``` Use the returned ID to stop it: ```json {"action": "stop", "id": "monitor-id-from-list"} ``` ```text /status monitors ``` ## Runtime Server Tools Use these tools to add servers, or activate skills and capabilities during a session. ### `mcp` — Dynamic MCP Server Management Manage MCP servers at runtime without editing config. **Parameters:** | Parameter | Type / requirement | Meaning | |-----------|--------------------|---------| | `action` | string, required | `"list"`, `"add"`, `"enable"`, `"disable"`, `"remove"`, `"persist"`, `"unpersist"` | | Action | Description | |--------|-------------| | `list` | Show all servers with status and persistence info | | `add` | Register a new server (does not connect yet) | | `enable` | Connect and activate a registered server's tools. Accepts an optional `tools` array to apply a per-enable filter (overrides the registered filter; empty/omitted = all tools advertised by the server). | | `disable` | Deactivate server tools (config stays) | | `remove` | Unregister entirely | | `persist` | Save server config to config dir. If the server is enabled, auto-binds it to the current role; if disabled, clears `auto_bind` (file persists but won't auto-load). | | `unpersist` | Remove persisted config file | **Add parameters:** | Parameter | Type / requirement | Meaning | |-----------|--------------------|---------| | `name` | string | Unique server name | | `server_type` | string | `"stdio"` or `"http"` | | `command` | string | Executable (for stdio) | | `args` | array | Arguments (for stdio) | | `url` | string | Endpoint (for http) | | `timeout_seconds` | number | Per-operation timeout; tool-call progress resets this idle deadline, and it holds while you answer a server's question (default: 30) | | `tools` | array | Tool filter (empty = all, supports wildcards like `"github_*"`). Also accepted by `enable` for a per-enable filter. | For a local HTTP MCP server already listening at this endpoint, call `mcp` in sequence: ```jsonl {"action": "add", "name": "local_api", "server_type": "http", "url": "http://localhost:3000/mcp"} {"action": "enable", "name": "local_api"} {"action": "persist", "name": "local_api"} {"action": "disable", "name": "local_api"} {"action": "unpersist", "name": "local_api"} {"action": "remove", "name": "local_api"} ``` ### `skill` — Skill Management from Taps Manage local, tap, and MCP skills (reusable instruction packs). **Parameters:** | Parameter | Type / requirement | Meaning | |-----------|--------------------|---------| | `action` | string, required | `"list"`, `"use"`, `"forget"` | | `name` | string | Local skill name or server-qualified MCP skill reference (required for `use` and local `forget`) | | `resource` | string | Supporting file URI for MCP skill `use` | | `manifest` | string | Manifest identifier from MCP skill `use`, required for supporting files | | `pattern` | string | Substring filter (for `list`) | | `offset` | integer | Pagination offset (default: 0) | | `limit` | integer | Max results (default: 20) | Call `skill` to list, activate, then forget an installed skill. Replace `code-review` with a name from `list`: ```jsonl {"action": "list", "limit": 20} {"action": "use", "name": "code-review"} {"action": "forget", "name": "code-review"} ``` Activation injects instructions; forgetting removes the active entry and lets the next automatic compression clean up its old content. For Skills over MCP (SEP-2640), `list` includes skills from connected servers enabled for the session. Pass the server-qualified reference, for example `docs:skill://release/SKILL.md`, to `use`. Octomind asks the user to approve the skill and returns its verified instructions as tool output. To read a supporting file, call `use` with the same `name`, the file URI as `resource`, and the returned `manifest` identifier. MCP skills require a static manifest and a session that can answer elicitation. Existing session tool permissions apply. **Skill resources:** Skills can include `scripts/`, `references/`, and `assets/` subdirectories. When activated, a resource catalog with absolute paths is provided. > **Internal note:** the dispatcher also accepts a `use_silent` action used for silent / auto-activation (env-loaded skills, `/skill` activation). It is not part of the JSON schema enum — the user/AI-facing actions are only `list`, `use`, and `forget`. To force-load an installed skill at session startup, use its exact name: ```bash OCTOMIND_SKILLS=code-review octomind run ``` Replace `code-review` with an installed name; multiple names are comma-separated. ### `capability` — Discover and Activate Domain Bundles Activate MCP server bundles ("capabilities") on demand. Capabilities are TOML-defined groups of MCP servers and tool filters distributed via taps (`/capabilities//.toml`). **Parameters:** | Parameter | Type / requirement | Meaning | |-----------|--------------------|---------| | `action` | string, required | `"list"`, `"discover"`, `"enable"`, `"disable"` | | `name` | string | Capability name (required for `enable` and `disable`) | | `intent` | string | Free-text intent for `discover` (e.g., `"I need to query a database"`) | | Action | Description | |--------|-------------| | `list` | Show every installed capability with active marker | | `discover` | Semantic search by intent — capabilities scoring above 0.2 cosine, top 5 returned | | `enable` | Register and connect a capability's MCP servers (domain-gated — see below) | | `disable` | Disconnect a capability's tools (refcount-aware — see below) | Use an installed name returned by `list` in place of `database-postgres`: ```jsonl {"action": "list"} {"action": "discover", "intent": "I need to query a Postgres database"} {"action": "enable", "name": "database-postgres"} {"action": "disable", "name": "database-postgres"} ``` **`discover` requires the embedding model.** Semantic discovery embeds your intent with the local embedding model (muvon/octomind-embed). If that model is not yet initialized, `discover` returns an error rather than degrading — wait a moment after startup and retry. Results are filtered to cosine score > 0.2 and capped at the top 5. **`enable` is domain-gated.** A capability whose manifest binds it to specific domains can only be enabled when the session's current domain matches; enabling a cap bound to other domains is refused with an error. Capabilities with no `domains` list are universal and enable anywhere. **`disable` is refcount-aware.** When multiple active capabilities (or a role's static config) reference the same underlying MCP server, disabling one capability only strips *that* capability's tools — the server keeps running for its other consumers. The server process is fully shut down only when this was the last referencer and no static role config owns it. **Auto-activation.** Capabilities also auto-activate before each API call when the user's message strongly matches a capability's hand-authored triggers (semantic match via local embedding, no LLM in the loop). Activation uses a similarity threshold of 0.68 with a 0.05 abstain-on-tie margin and considers the top 3 trigger scores; the active set is bounded by an LRU eviction policy (soft cap of 4). See [Token Efficiency](16-token-efficiency.md#deterministic-auto-activation) for the full algorithm. **Boot-time forcing.** Use `OCTOMIND_CAPABILITIES` to force-enable a comma-separated list of capabilities at startup. Every comma-delimited value must be the exact installed capability directory/name; this path does not perform semantic discovery, alias expansion, or fuzzy matching. Forced capabilities are still domain- and environment-gated. For an installed capability named `database-postgres`: ```bash OCTOMIND_CAPABILITIES=database-postgres octomind run ``` ## Calling external tools from scripts (`code` tool) Instead of one JSON tool call per step, the model can write one short script that calls the tools of your external MCP servers (`stdio` or `http`), including servers added at runtime with the `mcp` tool or a capability. The `code` tool runs the script and returns only what the script prints or returns. The `code` tool is part of the `core` builtin server. **What the model is sent.** Builtin tools (`recall`, `tap`, `mcp`, ...) are sent as usual, plus `code`. External tools are not sent as tool definitions. The `code` description lists each one on a line: how to call it, `server.tool({arg: type, ...})` with the fields of nested objects and list items written out, then the first sentences of its description. The text also says why one script should hold several calls: each `code` call sends the conversation again. Inside a script, `help("server")` and `help("server.tool")` print the full descriptions on demand. If no external tool is listed (none connected, or all kept as definitions), `code` is not sent. When the list would be longer than one tool result may be (`mcp_response_tokens_threshold`, 20,000 tokens by default), it is not sent with every request. The `code` description then names each server with its number of tools, and a second builtin tool, `search_tools`, is sent with it. Given what a tool should do, in the model's own words or by name, it prints the five tools that match best, ready to call in the next script; `help("server")` inside a script lists a server's tools too. The match fuses two rankings with reciprocal rank fusion: BM25 over each tool's server, name, description and argument names, which finds the exact words a model types, and cosine similarity of embeddings from octomind's local embedding model, which finds a tool described in other words ("remove a file" for `delete_path`). Only the role's own tools are listed and searched. Like `code`, `search_tools` comes with code mode whatever the role grants, and is not sent while the whole list fits. Every call of a listed tool runs through a script. A model may still write such a call as a tool of its own, by the listed name (`server.tool`) or by the tool's own name; octomind turns it into the `code` call it means, `return await server.tool({...})`, before it is shown or run. Text that spells a number, a boolean, null, a list or an object is first read as the tool's schema types it, because the model wrote the call without the schema; the type check answers what still does not fit. A call that names a server instead of a tool becomes `help("server")`, which lists the server's tools. The first time a tool is called this way, the model is also given the tool's full description, and again after a compaction removed it. **Example.** Read two files in parallel, then replace a config file with multi-line text written in the script: ```ts const [a, b] = await Promise.all([ files.read({ path: "src/a.rs" }), files.read({ path: "src/b.rs" }), ]); print(`a: ${a.split("\n").length} lines, b: ${b.split("\n").length} lines`); await files.write({ path: "notes.txt", content: `first line second line` }); ``` The `files` server and its tools stand for whatever your servers expose. The `code` call takes one parameter, `script`; it has no second parameter for text. **Script rules.** - TypeScript; plain JavaScript is valid. Top-level `await` and `return` work. - Everything the script needs is written in it. Long or multi-line text (file content, patches) is a template literal, `` `...` ``, with a backtick and `${` escaped inside it, like any TypeScript literal. - `await server.tool({...})` resolves to the tool's text output. A tool that declares an MCP `outputSchema` resolves to its structured result instead, typed from that schema; the list shows the type after `->`. A failed tool throws an `Error`, and so does a tool that declares an output schema but returns no structured result. - The value of the last expression, or of `return`, is the result. `print(...)` adds lines to it. - `Promise.all` runs calls at the same time. `sleep(ms)` waits. - No imports, files, network or process access. Tools are the only way out. - Limits: 256 MB of script memory, 1 MB of printed and returned text, one hour in total. A script that computes for 10 seconds without calling a tool, sleeping or finishing is stopped. **Checks before a script runs.** The script is type-checked in strict mode by the TypeScript compiler (version 6.0.3). The compiler is embedded in the Octomind binary and runs in an embedded QuickJS engine, so Node.js is not needed. An unknown tool, a wrong or missing argument, a missing `await`, or a text result used as a list rejects the whole script, and no tool is called. Right before each call, the arguments are checked again against the tool's JSON schema. This catches values typed `any` and integer versus number. Each call a script makes passes the same guardrails and `tool.before` plugin check as a direct call; scripts run only inside a session, where those checks live. If a script fails half way, the error says which tool calls ran. The plugin is shown the conversation as it was when the round started, and marks such a call with `script_call_id`, the id of the `code` call. Notes or a plan change it returns for such a call are applied when the round ends. **What the rest of the session sees of a script.** The `code` result keeps a record of every call the script made: the tool, its arguments, whether it failed or was denied, and its output. The output of a read is kept only when the script printed it, because the model never saw the rest. With it: - the terminal shows one line per call under the `code` call (`▸ server.tool(arguments) ✓`); - compaction treats a file a script read and printed, or edited, like a file the model read or edited directly; - the `tool.after` plugin event lists each call under its `code` call in `script_calls`. A plugin can replace only the `code` call's output: the script, not the model, read each call's result. WebSocket, JSONL and ACP clients get each call as it happens: a `tool_use` frame when the script starts it and a `tool_result` frame with the full output when it ends, like a direct call. Its `tool_id` is `:`, `n` counting the calls in the order the script started them, so a client can show it under its `code` call. A server is told which calls a script makes: octomind sends `script: true` in the session context of such a call (`experimental.session` in the client capabilities). The result of that call goes to the script, and the model sees only what the script prints. `octofs` uses this: a file a script views is not counted as seen by the model, so the model's own later view of it is complete. Everything else is the same for a script, including the line ids `octofs` puts on numbered file lines in shell output (`grep -n`, `nl -ba`): a script that prints such lines hands the model ids it can edit by. **Turning code mode off (`code_mode`).** `[mcp] code_mode` (default `true`) applies to every session: the main one, agents, layers and workflows. On, every external tool is reached through scripts, and `code` is there whenever the session has an external tool, whatever the role's servers and `allowed_tools` say; `allowed_tools` still decides which external tools the list shows. Two tools of one server whose script names collide: the second is numbered (`get_item_2`). Off, every tool is sent to the model as a plain tool definition and there is no `code` tool. ```toml [mcp] code_mode = false ``` **Known limits.** - The first script of a process waits about one second while the compiler loads. Loading starts in the background as soon as a request offers the `code` tool. The embedded compiler is rebuilt with `assets/typescript/vendor.sh` (pinned version, checksum-verified), which writes the files next to it. ## External Filesystem Tools Octomind loads external tool schemas at connection time. This repository does not define the parameter contracts of `octofs` or other companion servers; inspect your installed server before calling its tools: ```text /mcp full /status jobs ``` `/status jobs` also shows detached shell jobs discovered through MCP resource links. See [Local Tools](17-local-tools.md) if you want to expose your own project scripts. ## Health Monitoring MCP servers are monitored automatically: - Health checks every 120 seconds for external servers (HTTP + stdio) - Builtin servers are always considered healthy - Only restartable local processes auto-restart: stdio servers. HTTP endpoints are checked but cannot be restarted by Octomind (the HTTP config has no launch command). - Three consecutive restart failures mark a server failed; attempts are separated by a 30-second cooldown - A terminal `Failed` state is left alone by the monitor; it is not automatically probed or restarted again - Use `/mcp health` to run a check immediately on the active role's external servers. It is not read-only: it applies the same rules as the background monitor, so a dead stdio server is restarted (subject to the cooldown and failure limit above), an HTTP server without a live connection is reconnected, and `Failed` servers are skipped ## Common Questions **Why is a configured tool missing?** Check the active role, exact `auto_bind` tag, `server_refs`, and tool filters. An installed server is not necessarily enabled. Run: ```text /role /mcp list /mcp full /mcp health ``` **Why did discovery fail?** Wait for the local embedding model to initialize, then retry `discover`; `list` does not need semantic matching. Check missing environment variables if capability activation is refused. **Where are persisted servers?** They are in the data directory's `config/` subdirectory. On macOS/Linux the default is `~/.local/share/octomind/config/`; on Windows it is `%LOCALAPPDATA%/octomind/config/`. `OCTOMIND_DATA_DIR` relocates that data tree. Exact role names matter for `auto_bind`. ## Source Reference - [Built-in tools and routing](../../src/mcp/tool_map.rs) - [MCP config and defaults](../../src/config/mcp.rs) - [Runtime tools](../../src/mcp/runtime/mod.rs) - [Schedules and monitors](../../src/mcp/orchestration/mod.rs) - [External server lifecycle](../../src/mcp/health_monitor.rs) ## See also - [Configuration reference](../reference/03-config-reference.md) - [Session commands](../reference/02-session-commands.md) - [Tap system](../integration/04-tap-system.md) - [Local tools](17-local-tools.md)