使用说明
openclaw cli
通过终端与OpenClaw对话 openclaw-cli,或将其作为MCP服务器运行 openclaw-cli mcp.
安装CLI
curl -fsSL https://raw.githubusercontent.com/TimoBechtel/openclaw-cli/main/install.sh | bash
技能
此回购提供了一项技能 skills/openclaw-cli/SKILL.md 因此代理可以直接调用CLI。
安装时使用:
npx skills add TimoBechtel/openclaw-cli --skill openclaw-cli
CLI使用情况
openclaw-cli ask "Is there anything on my calendar for today?" # one-off question
openclaw-cli ask "Let's cancel this appointment and block 1h this afternoon for a coding session." --session-key "<session-key>" # continue same conversation
openclaw-cli ask "Send me a rain report for tomorrow on Telegram." --json # script-friendly JSON object: { response, sessionKey }
openclaw-cli ask "What should I do next?" --context=none # opt out of auto context injection
cat prompt.txt | openclaw-cli ask "Create a skill from this" # combine message argument + piped content
cat prompt.txt | openclaw-cli ask # stdin-only input also works
openclaw-cli mcp # run as an MCP server over stdio
当省略时, --session-key 是自动生成的。
MCP设置
Cursor的MCP配置示例(~/.cursor/mcp.json):
{
"mcpServers": {
"openclaw": {
"command": "openclaw-cli",
"args": ["mcp"],
"env": {
"OPENCLAW_GATEWAY_TOKEN": "your-token-here"
}
}
}
}
配置
| 变量 | 描述 | 默认值 |
|---|---|---|
OPENCLAW_BASE_URL |
OpenClaw网关URL | http://127.0.0.1:18789 |
OPENCLAW_GATEWAY_TOKEN |
身份验证的承载令牌 | - |
OPENCLAW_AGENT_ID |
目标代理ID | main |
OPENCLAW_SESSION_KEY_PREFIX |
生成的会话密钥的前缀 | - |
OPENCLAW_ALIAS |
MCP工具描述中的别名 | OpenClaw |
需求
启用 OpenResponses 在您的OpenClaw配置中:
{ gateway: { http: { endpoints: { responses: { enabled: true } } } } }
请勿将您的OpenClaw网关暴露于公共互联网。使用 尾标 用于远程访问。
从源代码构建
你需要 包子.
bun install
bun run build:all