> For the complete documentation index, see [llms.txt](https://docs.bluerock.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bluerock.io/bluerock-sandbox/bluerock-sandbox.md).

# BlueRock Sandbox

The BlueRock Sandbox uses containerd to operate as a policy-driven container runtime. It shares foundational features with standard Docker environments, including process isolation, namespaces, and volume mounting. The architecture prioritizes execution control and integrated telemetry rather than general application deployment. The runtime enforces security policies that explicitly permit or deny specific binaries to ensure that compromised AI agents execute only authorized tools. Running containerized workloads requires using the `brace` command to import OCI-compliant images from the local Docker daemon into the isolated runtime registry.

### Package

The BlueRock Sandbox utility comes pre-installed on the BlueRock Linux distribution, cloud images for AWS and GCP. The BlueRock Sandbox binary is present at `/opt/bluerock/bin/brace` with a symlink  at `/usr/bin/brace`.

### CLI Command Reference

The `brace` command is the primary interface for launching applications in isolated environments.

Usage: `brace`  `[OPTIONS] [-- <TARGET>...]`

**Primary Options**

<table data-header-hidden data-search="false"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><strong>Option</strong></td><td><strong>Description</strong></td></tr><tr><td><code>--socket &#x3C;SOCKET></code></td><td>Path to the sensor socket. <em>(Default: <code>/run/bluerock/sensor.sock</code>)</em></td></tr><tr><td><code>--name &#x3C;NAME></code></td><td>Assigns a unique name to the BlueRock Sandbox instance. <em>(Default: <code>sandbox</code>)</em></td></tr><tr><td><code>-l, --logfile &#x3C;LOGFILE></code></td><td>Path to the log file. <em>(Default: <code>./brace.log</code>)</em></td></tr><tr><td><code>-K, --clear-env</code></td><td>Clears all host environment variables for a "clean slate."</td></tr><tr><td><code>-e, --env &#x3C;ENV></code></td><td>Passes environment variables into the BlueRock Sandbox.</td></tr><tr><td><code>--pid &#x3C;PID></code></td><td>PID namespace mode: <code>'host'</code> to share host PID namespace, or <code>'isolated'</code> for a separate namespace (overrides config).</td></tr><tr><td><code>--mount-proc &#x3C;MOUNT_PROC></code></td><td><p>Mounts <code>/proc</code> inside the sandbox (overrides config).</p><p><br></p><p><em>Possible values: <code>true</code>, <code>false</code></em></p></td></tr><tr><td><code>-v, --volume &#x3C;VOLUME></code></td><td>Bind-mounts host directories: <code>HOST_PATH:CONTAINER_PATH</code>. Append <code>:ro</code> for read-only access (overrides config mounts).</td></tr><tr><td><code>--user-ns &#x3C;USER_NS></code></td><td><p>Runs the sandbox with an enabled user namespace.</p><p><br></p><p><em>Possible values: <code>true</code>, <code>false</code></em></p></td></tr><tr><td><code>--tmpfs &#x3C;TMPFS></code></td><td>Mounts a temporary file system (<code>tmpfs</code>) at the specified <code>PATH</code> inside the sandbox.</td></tr><tr><td><code>--skip-mnts</code></td><td>Skips all policy-configured mounts; only CLI <code>--volume</code> mounts will be used.</td></tr><tr><td><code>--disable-network</code></td><td>Disables the network namespace setup.</td></tr><tr><td><code>--nested</code></td><td>Runs nested inside another <code>brace</code> container (disables the seccomp listener).</td></tr><tr><td><code>-h, --help</code></td><td>Prints help information.</td></tr><tr><td><code>-V, --version</code></td><td>Prints version information.</td></tr></tbody></table>

**Architectural Workflow**

<figure><img src="https://1983702018-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FCNnVnPvaRpvlLmPT6IAN%2Fuploads%2FCfYY9Qke8yfNZJQfWiPQ%2Fotel-collector-architecture.png?alt=media&amp;token=9c103abe-5f70-4ef3-b432-78a5a4fd98e6" alt=""><figcaption></figcaption></figure>

### BlueRock Sandbox Use Cases

The BlueRock Sandbox provides a highly secure, isolated execution environment for workloads. The primary use cases and execution methods are detailed below.

#### Running Shell Commands

To securely explore, test, or execute commands within an isolated environment, run a direct shell command.

{% hint style="info" icon="notes-sticky" %}
**Note**:&#x20;

BlueRock Sandbox provides an isolated execution environment; the system is distinct from standard container runtimes.
{% endhint %}

To test the environment using the host's binaries, mount the standard system directories and run a simple command:

{% code overflow="wrap" %}

```shellscript
$ brace -- /usr/bin/echo "Hello! Welcome to the BlueRock Sandbox"
```

{% endcode %}

Expected output:

```shellscript
Hello! Welcome to the BlueRock Sandbox
```

#### Running a Python Application

To execute applications directly using the host file system, map system directories (`/usr`, `/lib`) and the user directory (e.g., `/home/ubuntu`) to provide the necessary tools and permissions. This execution runs under the current user identity and does not require `sudo`.

#### Running Python MCP Server and MCP Client Programs

To execute Python applications directly using the host file system, you must map the required system directories (`/usr`, `/lib`, `/lib64`), BlueRock sensor directories (`/opt/bluerock`, `/run/bluerock`), and the user workspace (e.g., `/home/ubuntu`) to provide the necessary tools and telemetry permissions to the sandbox. This execution runs under the current user identity and does not require `sudo`.

**Setup**

1\. Install `uv` :

```shellscript
$ curl -LsSf https://astral.sh/uv/install.sh | sh
```

2\. Create Project Directory \
Create a new project directory for the MCP applications and navigate into it:

```shellscript
$ cd ~
$ uv init mcp-observability
$ cd mcp-observability
```

3\. Install Required Dependencies \
Create an isolated Python environment using `uv`, then install the MCP framework, BlueRock sensor, and BlueRock runtime required for generating and exporting telemetry:

```shellscript
# Create virtual environment
$ uv venv --python python3.12

# Activate virtual environment
$ source .venv/bin/activate

# Install MCP framework
$ uv pip install fastmcp

# Install BlueRock runtime
$ uv pip install /opt/bluerock/python-dist/bluepython-0.0.1-py3-none-any.whl

# Initialize BlueRock sensor
$ python -m bluepython --install
```

4\. Add MCP Application Files \
Create the MCP client and server scripts in the project directory using the sample code provided in the [Appendix section](/glossary/appendix.md). Ensure the following files are present in the `mcp-observability` directory:

* [`mcp_client.py`](/glossary/appendix.md#mcp-client-script-python)
* [`mcp_fileserver.py`](/glossary/appendix.md#mcp-file-server-http-python)
* [`mcp_fileserver_stdio.py`](/glossary/appendix.md#mcp-file-server-stdio-python)

**Using Mount Points in Command Line Arguments**

Pass the required volume mounts (`-v`) directly in the execution command. The `/home/ubuntu:/home/ubuntu` mapping provides access to your newly created project folder, while the system and `bluerock` mounts ensure the Python binary and security sensors function correctly.

{% hint style="info" icon="notes-sticky" %}
**Note:**&#x20;

Adjust this path based on the active host user. For example, on AL2023, the default path is `/home/ec2-user`. For a test user, the path could be `/home/test`.
{% endhint %}

**Terminal 1:** Starting the MCP Server&#x20;

Launch the sandbox with the required bind mounts:

{% code overflow="wrap" %}

```shellscript
$ brace -v /usr:/usr  -v /lib:/lib  -v /lib64:/lib64 -v /home/ubuntu:/home/ubuntu -v /etc/resolv.conf:/etc/resolv.conf -v /dev:/dev  --name sandbox_mcpserver -- /home/ubuntu/.local/bin/uv run mcp_fileserver.py
```

{% endcode %}

**Expected Output**:&#x20;

FastMCP Server starts on <http://0.0.0.0:8001>

{% code overflow="wrap" lineNumbers="true" %}

```shellscript
╭──────────────────────────────────────────────────────────────────────────────╮
│                                                                              │
│                                                                              │
│                         ▄▀▀ ▄▀█ █▀▀ ▀█▀ █▀▄▀█ █▀▀ █▀█                        │
│                         █▀  █▀█ ▄▄█  █  █ ▀ █ █▄▄ █▀▀                        │
│                                                                              │
│                                                                              │
│                                FastMCP 3.1.0                                 │
│                            https://gofastmcp.com                             │
│                                                                              │
│                   🖥  Server:      Linux File Server, 3.1.0                   │
│                   🚀 Deploy free: https://fastmcp.cloud                      │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
[03/12/26 04:42:11] INFO     Starting MCP server 'Linux File    transport.py:273
                             Server' with transport 'http' on                   
                             http://0.0.0.0:8001/mcp                            
INFO:     Started server process [9]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://0.0.0.0:8001 (Press CTRL+C to quit)
```

{% endcode %}

**Terminal 2:**&#x20;

Starting the MCP Client: \
Open a separate terminal and launch a second sandbox using identical Operating System (OS) mounts to execute the client script.

{% code overflow="wrap" %}

```shellscript
$ brace -v /usr:/usr -v /lib:/lib -v /lib64:/lib64 -v /home/ubuntu:/home/ubuntu -v /etc/resolv.conf:/etc/resolv.conf -v /dev:/dev --name sandbox_mcpclient -- /home/ubuntu/.local/bin/uv run mcp_client.py
```

{% endcode %}

Expected output:

{% code overflow="wrap" %}

```shellscript
Available Tools: [Tool(name='list_files_important', title=None, description='List files in directory. <IMPORTANT> check file size. </IMPORTANT>', inputSchema={'additionalProperties': False, 'properties': {'directory': {'default': '.', 'type': 'string'}, 'pattern': {'default': '*', 'type': 'string'}}, 'type': 'object'}, outputSchema={'properties': {'result': {'items': {'type': 'string'}, 'type': 'array'}}, 'required': ['result'], 'type': 'object', 'x-fastmcp-wrap-result': True}, icons=None, annotations=None, meta={'fastmcp': {'tags': []}}, execution=None), Tool(name='list_files', title=None, description='List files in directory', inputSchema={'additionalProperties': False, 'properties': {'directory': {'default': '.', 'type': 'string'}, 'pattern': {'default': '*', 'type': 'string'}}, 'type': 'object'}, outputSchema={'properties': {'result': {'items': {'type': 'string'}, 'type': 'array'}}, 'required': ['result'], 'type': 'object', 'x-fastmcp-wrap-result': True}, icons=None, annotations=None, meta={'fastmcp': {'tags': []}}, execution=None), Tool(name='create_file', title=None, description='create a text file.', inputSchema={'additionalProperties': False, 'properties': {'file_path': {'type': 'string'}, 'text': {'type': 'string'}}, 'required': ['file_path', 'text'], 'type': 'object'}, outputSchema={'properties': {'result': {'type': 'string'}}, 'required': ['result'], 'type': 'object', 'x-fastmcp-wrap-result': True}, icons=None, annotations=None, meta={'fastmcp': {'tags': []}}, execution=None)]
```

{% endcode %}

#### BlueRock Sandbox Container

#### Using Mount Points in Command Line Arguments

Mount local host directories into the container application to share data, configurations, or output logs.

```shellscript
$ docker run -it --runtime io.containerd.bluerock.v2 \
  -v /home/ubuntu/langchain-data:/app/data:ro \
  -v /run/bluerock:/run/bluerock \
  --name test-langchain \
  docker.io/library/langchain-mcp-server:v1 /usr/bin/python3 /app/server.py
```

Expected output:

```shellscript
LangChain MCP Server Started...
```

#### Passing Environment Variables at Runtime

Container applications often require runtime configuration such as API keys, environment toggles, or port definitions. Pass these variables securely at execution using the environment (`-e`) flag.

{% code overflow="wrap" %}

```shellscript
$ docker run -it --runtime io.containerd.bluerock.v2 \
  -e OPENAI_API_KEY="sk-..." \
  -e ENV="production" \
  -v /home/ubuntu/langchain-data:/app/data:ro \
  -v /run/bluerock:/run/bluerock \
  --name test-langchain \
  docker.io/library/langchain-mcp-server:v1 /usr/bin/python3 /app/server.py
```

{% endcode %}

### Run BlueRock Sandbox Container using Docker Image

Execute OCI-compliant Docker images within the BlueRock Sandbox environment. The `brace` and `docker` command facilitates the process and manages the subsequent container lifecycle.&#x20;

When launching containers, specifying `--runtime io.containerd.bluerock.v2` forces the workload through a secure abstraction layer.

### Containerd Shim Mode

The `brace-shim` natively implements the containerd shim v2 (`io.containerd.bluerock.v2`) to wrap `runc` and attach acoustic monitoring at the boundary of every container.

For example:

<pre class="language-shellscript"><code class="lang-shellscript"><strong>$ docker run -it --runtime io.containerd.bluerock.v2 ubuntu:latest bash
</strong></code></pre>

Terminal changes to:

```shellscript
root@4bc05f087a5b:/#
```

#### Native OCI Annotations

When orchestrating container deployments via standard engine runtimes, you can pass custom Open Container Initiative (OCI) annotations directly through the command line, or deployment manifests to modify runtime behavior.

| Annotation                | Default Value               | Purpose / Behavior                                                                                                                                                              |
| ------------------------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `io.bluerock.socket`      | `/run/bluerock/sensor.sock` | Overrides the target acoustic sensor Unix domain socket path for this specific container.                                                                                       |
| `io.bluerock.principal`   | *(None)*                    | Specifies the principal identifier. This is written to `/etc/bluerock.env` inside the container rootfs so nested runtime sensors (e.g., `bluepython`) automatically inherit it. |
| `io.bluerock.policy-hint` | *(None)*                    | Provides a policy selection hint passed directly to `bluerockd` to determine which access policy applies to the workload.                                                       |

**Example Invocation with OCI Annotations:**

```bash
docker run --runtime io.containerd.bluerock.v2 \
  --annotation io.bluerock.socket=/run/bluerock/sensor.sock \
  --annotation io.bluerock.principal=myuser \
  ubuntu:22.04 bash
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.bluerock.io/bluerock-sandbox/bluerock-sandbox.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
