---
title: "OpenClaw"
description: "Connect OpenSRE to OpenClaw for native context lookup and RCA write-back"
---

OpenSRE integrates with OpenClaw in a native, one-way support loop:

- OpenSRE can search recent OpenClaw conversations during an investigation.
- OpenSRE can read full OpenClaw threads for extra engineering context.
- OpenSRE writes completed RCA findings back into OpenClaw through the OpenClaw bridge.

OpenSRE no longer ships a separate `opensre-mcp` command. You do not need to register OpenSRE itself as an MCP server inside OpenClaw.

## Setup

### 0. Preflight the local OpenClaw CLI

Before you onboard OpenClaw in OpenSRE, make sure the OpenClaw CLI itself is healthy in the same shell:

```bash
node -v
openclaw --help
openclaw gateway status
```

Expected result:

- `node -v` shows Node `v22.12+` or newer
- `openclaw --help` exits cleanly
- `openclaw gateway status` does not fail immediately

If you use `nvm`, the safe sequence is:

```bash
nvm install 22
nvm use 22
node -v
openclaw --help
```

`nvm alias default 22` only affects future shells. It does not switch the current shell that launches `uv run opensre`.

### 1. Install and configure OpenSRE locally

```bash
make install
uv run opensre onboard
```

### 2. Configure the OpenSRE → OpenClaw bridge

Use the guided wizard:

```bash
uv run opensre onboard
```

Or use the direct integration setup command:

```bash
uv run opensre integrations setup openclaw
uv run opensre integrations verify openclaw
```

Recommended bridge settings:

```bash
OPENCLAW_MCP_MODE=stdio
OPENCLAW_MCP_COMMAND=openclaw
OPENCLAW_MCP_ARGS="mcp serve"
```

### 3. Verify the bridge

From the repo root:

```bash
uv run opensre integrations verify openclaw
uv run opensre health
```

### 4. Run a smoke test

Use the bundled OpenClaw fixture directly:

```bash
uv run opensre investigate -i tests/fixtures/openclaw_test_alert.json
```

If verification still fails, the next manual checks are:

```bash
openclaw gateway status
openclaw gateway run
uv run opensre integrations verify openclaw
```

## Write-back behavior

After every completed investigation, OpenSRE attempts to write the full RCA report back into OpenClaw.

- If the investigation state contains an `openclaw_context.conversation_id`, OpenSRE first tries to append the result to that conversation.
- Otherwise, OpenSRE creates a new OpenClaw conversation containing the RCA report, root cause, remediation steps, and confidence score.

## Investigation behavior

When OpenClaw is configured, OpenSRE now prefers the high-signal conversation actions first:

- `search_openclaw_conversations` to find recent related context
- `get_openclaw_conversation` to read the full thread
- `send_openclaw_message` to append a concrete follow-up

The lower-level raw bridge tools remain available, but they are treated as fallback paths instead of the default investigation path.

## Accurate RCA

OpenClaw improves RCA quality by supplying engineering context, but OpenClaw alone is not enough for a strong investigation.

For accurate RCA, also configure at least one of these:

- `Grafana` or `Datadog` for metrics/logs/traces
- `AWS` for infra topology and runtime state
- `GitHub` for deploy/code-change context

A good local validation sequence is:

```bash
uv run opensre integrations verify openclaw
uv run opensre integrations verify grafana
uv run opensre integrations verify github
uv run opensre investigate -i tests/fixtures/openclaw_test_alert.json
```

Contributor-facing regression coverage for this path lives in:

- `tests/test_openclaw_integration.py`
- `tests/tools/test_openclaw_mcp_tool.py`
- `tests/utils/test_openclaw_delivery.py`
- `tests/e2e/openclaw/` (e2e suite — see the "End-to-end tests" section below)

## Environment variables

| Variable | Meaning | Default |
| --- | --- | --- |
| `OPENCLAW_MCP_MODE` | OpenClaw bridge transport: `stdio`, `streamable-http`, or `sse` | `streamable-http` |
| `OPENCLAW_MCP_COMMAND` | Executable used for `stdio` mode | `openclaw` |
| `OPENCLAW_MCP_ARGS` | Space-separated arguments for `stdio` mode | `mcp serve` |
| `OPENCLAW_MCP_URL` | Remote MCP endpoint for `streamable-http` or `sse` | _none_ |
| `OPENCLAW_MCP_AUTH_TOKEN` | Optional bearer token for remote MCP transports | _empty_ |

## Troubleshooting

- `OpenClaw bridge validation failed: Node.js ... is required`: switch the current shell to Node `22.12+` or newer. With `nvm`: `nvm install 22 && nvm use 22 && nvm alias default 22`. With Homebrew: `brew install node@22 && brew link --overwrite node@22`. Then re-run `openclaw --help` before retrying onboarding.
- `uv run opensre integrations verify openclaw` fails against `http://127.0.0.1:18789/`: that URL is the OpenClaw Control UI/Gateway, not the MCP bridge. Use `stdio` mode with `openclaw mcp serve`.
- `search_openclaw_conversations` or write-back fails with `Connection closed` or `ECONNREFUSED`: the OpenClaw Gateway is not running. Check `openclaw gateway status`, then run `openclaw gateway run`.
- `Command not found: openclaw`: install the OpenClaw CLI or point `OPENCLAW_MCP_COMMAND` at the full executable path.

## End-to-end tests

The OpenClaw e2e suite lives at [`tests/e2e/openclaw/`](https://github.com/Tracer-Cloud/opensre/tree/main/tests/e2e/openclaw). See its [README](https://github.com/Tracer-Cloud/opensre/tree/main/tests/e2e/openclaw/README.md) for prerequisites, how to run the suite, scenario layout, and CI behavior.
