Skip to main content

OpenClaw ACP Stdio Wrapper

将 openclaw acp 包装为标准 stdio ACP 服务器的桥接工具。

背景

openclaw acp 是 OpenClaw 的 ACP (Agent Client Protocol) 桥接进程,但它不是标准的ACP协议。本项目通过 stdio 包装层,将其转化为了标准的 ACP 消息处理能力,使其能够被 Clawdboz 等 ACP 客户端正常调用。

功能

  • Gateway 管理:自动检测并启动 openclaw gateway(端口 18789)
  • ACP 桥接:启动并管理 openclaw acp 子进程
  • 协议翻译:自动转换 initialize 请求的 protocolVersion
  • Agent Fallback:当 openclaw acp 不支持某些方法(如 session/prompt、tools/call)时,直接调用 openclaw agent CLI 获取真实回复
  • 流式通知:为 session/prompt 提供标准的 ACP 流式响应(thinking → agent_message_chunk → stopReason)
  • 自动建 Session:每次启动自动分配全新 session,对话上下文相互隔离

安装

pip install openclaw-acp

或从源码安装:

git clone https://github.com/Dr-Lv/openclaw-acp
cd openclaw-acp
pip install -e .

依赖

  • Python >= 3.10
  • OpenClaw CLI (openclaw 命令需在 PATH 中)
  • 运行中的 OpenClaw Gateway(wrapper 会自动启动,也可提前手动运行)

使用

安装后会暴露 openclaw-acp 命令:

# 基本启动
openclaw-acp

# 指定 openclaw 二进制路径
openclaw-acp --openclaw-bin /opt/homebrew/bin/openclaw

环境变量

变量 说明 默认值
OPENCLAW_SESSION_ID 强制使用指定 session ID(留空则每次启动自动新建) 自动生成 UUID

作为 MCP/ACP 服务器配置

在支持 stdio ACP 的客户端(如 Cursor、Claude Desktop)中配置:

{
  "mcpServers": {
    "openclaw": {
      "command": "openclaw-acp"
    }
  }
}

工作原理

┌─────────────┐     Content-Length/NDJSON      ┌──────────────────────┐     NDJSON      ┌─────────────┐
│   ACP 客户端 │  ────────────────────────────> │ openclaw-acp-wrapper │ ──────────────> │ openclaw acp│
│  (Clawdboz) │                              │                      │               │             │
│             │  <──────────────────────────── │   - 协议翻译         │ <─────────────│   bridge    │
│             │     NDJSON (session/update)    │   - Agent fallback   │               │             │
└─────────────┘                                │   - 流式通知         │               └─────────────┘
                                               └──────────────────────┘
                                                        │
                                                        │ 启动/管理
                                                        ▼
                                               ┌──────────────────────┐
                                               │   openclaw gateway   │
                                               │    (127.0.0.1:18789) │
                                               └──────────────────────┘

协议说明

Wrapper 的输入支持两种格式:

  • Content-Length 分帧(标准 MCP/ACP)
  • 换行分隔 JSON(newline-delimited JSON)

输出统一使用 换行分隔 JSON,与 clawdboz 等客户端兼容。

License

MIT

Metadata

Release files for openclaw-acp 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openclaw-acp 0.1.1
File Size Uploaded Provenance
openclaw_acp-0.1.1.tar.gz 14.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for openclaw-acp 0.1.1
File Interpreter ABI Platform
openclaw_acp-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 48.7 kB

Release files / openclaw_acp-0.1.1.tar.gz

Download URL openclaw_acp-0.1.1.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
cac49f9d9ba08bb7f1d3f4695a9ebf0caf2f51907c4192df4af9ff012b9d58ca
BLAKE2b-256 checksum
How to use checksums
080c58a157a01fe0c6d89e8aa86034a9358f7c10d85d50ed860158cb7472041e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / openclaw_acp-0.1.1-py3-none-any.whl

Download URL openclaw_acp-0.1.1-py3-none-any.whl
Size 33.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f93c171e7e7d9bc7539062ffd6afd16cd9c7f9113564bd7e3ff5eb95e11f018
BLAKE2b-256 checksum
How to use checksums
db6a79f89e02fd18f917fb746659bce2d4c5522c5094350cdb08ee831ddb5ba1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for openclaw-acp 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page