> For AI agents: the complete documentation index is available at https://enclo.nstlopez.com/llms.txt, the full documentation bundle is available at https://enclo.nstlopez.com/llms-full.txt.

# MCP tools

`enclo mcp` runs an MCP server over stdio. Once registered (see
[Connect your harness](https://enclo.nstlopez.com/guide/harnesses.md)), it exposes these nine tools to the
agent:

| Tool                        | What it does                                                                     |
| --------------------------- | -------------------------------------------------------------------------------- |
| [`run`](#run)               | Runs a shell command as root and returns its exit code, stdout, and stderr       |
| [`write_file`](#write_file) | Writes up to 5 MiB of text to a file, creating parent directories as needed      |
| [`read_file`](#read_file)   | Reads a text file, or any file with `encoding: "base64"`                         |
| [`push`](#push)             | Copies a host directory into the sandbox, skipping files matched by `.gitignore` |
| [`create`](#create)         | Creates a new sandbox, either empty or cloned from an existing sandbox's disk    |
| [`list`](#list)             | Lists sandboxes created through MCP                                              |
| [`stop`](#stop)             | Terminates a running command while leaving the sandbox running                   |
| [`shutdown`](#shutdown)     | Powers off a sandbox while keeping its disk; the next `run` boots it again       |
| [`remove`](#remove)         | Deletes an MCP-created sandbox and its disk                                      |

Every tool that operates on a sandbox accepts a `sandbox` argument with the
target sandbox ID (such as `sb_k3m9x2pq`). Omit it to target the session's
default sandbox, which is created on first use.

## run

Runs a shell command in a sandbox and returns its exit code, stdout, and
stderr. Multiple commands can run in parallel. If a command runs longer than 45
seconds, `run` returns a still-running status with an `exec_id`.

| Argument          | Type    | Default       | Meaning                                                                                                                                           |
| ----------------- | ------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `command`         | string  |               | Shell command line executed as `sh -c <command>` by root. Required unless `exec_id` is provided                                                   |
| `sandbox`         | string  | the session's | Target sandbox ID                                                                                                                                 |
| `cwd`             | string  | `/root`       | Absolute working directory inside the sandbox. Must already exist                                                                                 |
| `timeout_seconds` | integer | 600           | Maximum runtime in seconds (up to 3600) before the command is stopped with exit code 124                                                          |
| `exec_id`         | integer |               | ID of a still-running command returned by an earlier `run` call. Pass with `sandbox` only to wait up to another 45 seconds and collect new output |

## write_file

Writes text to a file in a sandbox, overwriting any existing content and
creating parent directories as needed. Maximum size is 5 MiB.

| Argument  | Type   | Meaning                                                                  |
| --------- | ------ | ------------------------------------------------------------------------ |
| `path`    | string | Absolute file path in the sandbox, such as `/root/app/main.py`. Required |
| `content` | string | Exact text to write to the file. Required                                |
| `sandbox` | string | Target sandbox ID                                                        |

## read_file

Reads a file from a sandbox, returning text by default or the raw bytes of any
file (including binary files) with `encoding: "base64"`.

| Argument    | Type                   | Default       | Meaning                                                                 |
| ----------- | ---------------------- | ------------- | ----------------------------------------------------------------------- |
| `path`      | string                 |               | Absolute file path in the sandbox. Required                             |
| `sandbox`   | string                 | the session's | Target sandbox ID                                                       |
| `max_bytes` | integer                | 256 KiB       | Maximum bytes to return from the start of the file, up to 5 MiB         |
| `encoding`  | `"text"` or `"base64"` | `"text"`      | Use `"base64"` to return raw bytes encoded as base64 (for binary files) |

## push

Copies a directory from your host machine into a sandbox, merging into any
existing files at the destination. Files matched by `.gitignore` are skipped,
while `.git` is included. Prefer `push` over `write_file` for multi-file
projects. If a copy takes longer than 45 seconds, `push` returns an `exec_id`
that you can pass to `run` to keep waiting or to `stop` to cancel.

| Argument  | Type         | Default                         | Meaning                                                                                    |
| --------- | ------------ | ------------------------------- | ------------------------------------------------------------------------------------------ |
| `path`    | string       |                                 | Absolute path to the host directory. Cannot be `/` or your home directory itself. Required |
| `dest`    | string       | `/root/<name of the directory>` | Absolute destination path in the sandbox                                                   |
| `sandbox` | string       | the session's                   | Target sandbox ID                                                                          |
| `exclude` | string array |                                 | Additional exclude patterns in `.gitignore` syntax, such as `"node_modules/"`              |

## create

Creates a new sandbox and returns its ID. Without `from`, the sandbox starts
empty; with `from`, it starts as a copy of the named sandbox's disk. You do not
need to call `create` before `run` because the session's default sandbox is
created automatically on first use.

| Argument     | Type    | Default | Meaning                                                                |
| ------------ | ------- | ------- | ---------------------------------------------------------------------- |
| `from`       | string  |         | ID of any existing sandbox on this machine whose disk should be copied |
| `cpus`       | integer | 2       | Number of vCPUs, up to the host's core count                           |
| `memory_mib` | integer | 2048    | Memory in MiB, from 128 up to half of host memory                      |
| `network`    | boolean | `true`  | Whether the sandbox has outbound internet access                       |

## list

Lists sandboxes created by the MCP tools, showing each sandbox's ID, running
state, active command count, creation and last-used timestamps, and disk usage.
The session's default sandbox is marked. Sandboxes created manually with
`enclo new` are included in the total count but omitted from the list. Takes no
arguments.

## stop

Terminates a running command immediately instead of waiting for its timeout.
Pass `exec_id` to stop one command, or omit it to stop every running command
started by this session in that sandbox. The sandbox stays running with its
files and background processes intact. Use `shutdown` to power off the sandbox.

| Argument  | Type    | Meaning                                                                                           |
| --------- | ------- | ------------------------------------------------------------------------------------------------- |
| `sandbox` | string  | Target sandbox ID                                                                                 |
| `exec_id` | integer | Command ID to terminate. Omit to stop all running commands started by this session in the sandbox |

## shutdown

Powers off a sandbox. Running commands and background processes terminate,
while files on disk are preserved for the next `run`. Because sandboxes already
shut down automatically after 15 minutes of inactivity, call `shutdown` when
you want a clean restart or want to free host memory immediately.

| Argument  | Type   | Meaning           |
| --------- | ------ | ----------------- |
| `sandbox` | string | Target sandbox ID |

## remove

Permanently deletes an MCP-created sandbox and its disk. Sandboxes created
manually with the CLI cannot be removed through this tool.

| Argument  | Type    | Default | Meaning                                                          |
| --------- | ------- | ------- | ---------------------------------------------------------------- |
| `sandbox` | string  |         | ID of the sandbox to delete. Required                            |
| `force`   | boolean | `false` | Terminate any running commands in the sandbox before deleting it |
