Files
wehub-resource-sync 4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:10:45 +08:00

161 lines
5.3 KiB
Plaintext

---
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.