> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anonalabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Agents via MCP

> Give Claude Code, Codex, Cursor or any MCP client its own sandboxes.

`anona-compute mcp` is a [Model Context Protocol](https://modelcontextprotocol.io) server. It acts with the CLI's credential, so install the CLI, sign in once, and register it with your agent:

```bash mcp_install.sh theme={null}
npm install -g @anona-labs/anona-compute
anona-compute login    # browser sign-in; or: printenv ANONA_API_KEY | anona-compute login --with-api-key
```

> [tab] Claude Code
>
> ```bash claude_code.sh theme={null}
> claude mcp add anona-compute -- anona-compute mcp
> ```

> [tab] Codex
>
> ```bash codex.sh theme={null}
> codex mcp add anona-compute -- anona-compute mcp
> ```
>
> Or in `~/.codex/config.toml`:
>
> ```toml theme={null}
> [mcp_servers.anona-compute]
> command = "anona-compute"
> args = ["mcp"]
> ```

> [tab] Cursor
>
> `~/.cursor/mcp.json`, or `.cursor/mcp.json` in a project:
>
> ```json theme={null}
> {
>   "mcpServers": {
>     "anona-compute": { "command": "anona-compute", "args": ["mcp"] }
>   }
> }
> ```

> [tab] Other clients
>
> Any client that starts stdio servers: command `anona-compute`, arguments `mcp`. Put `--profile <name>` before `mcp` to use another [profile](https://docs.anonalabs.com/compute/cli/configuration.md), and `--read-only` after it to offer only the read-only tools.

## Tools

| Tool | What it does |
| - | - |
| `whoami` | User, organization and role (or the masked API key) |
| `list_sandboxes`, `get_sandbox` | State, template, end time (empty means no limit), metadata |
| `list_templates` | The organization's templates, with their build status |
| `create_sandbox` | Template, `timeout_seconds` (`-1` for no limit), `internet` on or off, metadata, environment variables, auto-pause |
| `kill_sandbox`, `pause_sandbox`, `resume_sandbox`, `extend_sandbox` | Lifecycle; `extend_sandbox` takes `-1` for no limit |
| `run_command` | Runs `bash -l -c`, returns stdout, stderr and exit code; `timeout_seconds` (default 60) |
| `start_process`, `read_process_output`, `kill_process` | Background processes; output is read by offset, optionally waiting for more |
| `read_file`, `write_file`, `list_files` | Text or base64 content, directory listings |
| `get_live_view_url` | A short-lived view (or control) link for the desktop, DOM or terminal |
| `get_preview_url` | A shareable link to one port of a sandbox (a dev server the agent started), 1 minute to 24 hours |
| `get_usage` | Usage and cost for a billing period: meters, totals, a projection for the current month, the most expensive sandboxes |
| `get_ssh_config` | Signs a 10-minute SSH certificate and returns an `ssh_config` block |
| `desktop_screenshot` | PNG of the `desktop` template's screen, as image content |

Every call goes to the API with your credential, so your role and your API key's scopes decide what works. A dashboard viewer, or `--read-only`, gets `whoami`, `list_sandboxes`, `get_sandbox`, `get_usage` and view-only `get_live_view_url`. `get_usage` needs the `usage:read` scope on an API key.

Background-process output is kept by the MCP server process (the last 4 MiB per stream), so it is lost if the agent restarts the server.

## Check it without an agent

Talk to the server over stdio yourself, the way an agent does:

```python mcp_check.py theme={null}
import json, subprocess

srv = subprocess.Popen(["anona-compute", "mcp"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, text=True)

def call(id, method, params=None):
    srv.stdin.write(json.dumps({"jsonrpc": "2.0", "id": id, "method": method, "params": params or {}}) + "\n")
    srv.stdin.flush()
    return json.loads(srv.stdout.readline())

call(1, "initialize", {"protocolVersion": "2025-06-18", "capabilities": {}, "clientInfo": {"name": "check", "version": "0"}})
srv.stdin.write(json.dumps({"jsonrpc": "2.0", "method": "notifications/initialized"}) + "\n")
print([t["name"] for t in call(2, "tools/list")["result"]["tools"]])

created = call(3, "tools/call", {"name": "create_sandbox", "arguments": {"template": "base", "timeout_seconds": 600}})
sandbox_id = created["result"]["structuredContent"]["sandbox_id"]
ran = call(4, "tools/call", {"name": "run_command", "arguments": {"sandbox_id": sandbox_id, "command": "echo hi from mcp"}})
print(ran["result"]["structuredContent"])
call(5, "tools/call", {"name": "kill_sandbox", "arguments": {"sandbox_id": sandbox_id}})
srv.stdin.close()
srv.wait()
```

## Over HTTP

For clients that connect to a URL instead of starting a process, serve streamable HTTP on a loopback address. Every request needs the bearer token:

```text theme={null}
ANONA_COMPUTE_MCP_TOKEN=$(openssl rand -hex 24) anona-compute mcp --http 127.0.0.1:8765
# endpoint http://127.0.0.1:8765/mcp, header Authorization: Bearer $ANONA_COMPUTE_MCP_TOKEN
```

Only loopback addresses are accepted, because the server acts with your credentials. Without `ANONA_COMPUTE_MCP_TOKEN` a random token is printed on start.

## Inside a sandbox

The `coding-agent` template ships Claude Code, Codex, OpenCode, pi, Kimi Code, Mistral Vibe and Cursor Agent, each wired to a computer-use MCP server and an `anona` skill. Give the agent its provider key as an environment variable when you create the sandbox. See [Templates](https://docs.anonalabs.com/compute/concepts/templates.md#coding-agent).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.