Telegram配对码持续响应
修改OpenClaw
本技能为OpenClaw/Clawdbot提供MCP(Model Context Protocol)协议集成能力,支持连接和编排各类MCP工具服务器,实现跨会话状态持久化与多设备数据同步。
该技能让Clawdbot能够灵活接入各类外部工具服务,如文件管理和代码仓库,同时保障用户的工作状态在换设备或重启后不丢失。业务团队可借此构建连贯的自动化工作流,无需重复配置环境,提升跨协作效率。
落地案例:某开发团队使用Clawdbot连接GitHub MCP服务器管理代码评审。成员A在办公室电脑发起代码审查会话,IndexedDB自动保存进度;回家后成员A用手机登录,会话状态同步恢复,可直接继续批注。团队还可动态暂停不用的服务器连接,避免资源占用,待需要时再快速恢复。
安装依赖
npm install openclaw-claude-code-skill
初始化MCP系统
import { initializeMcpSystem, addMcpServer, executeMcpAction } from "openclaw-claude-code-skill";
// 启动所有配置的服务器
await initializeMcpSystem();
// 动态添加文件系统服务器
await addMcpServer("fs", {
command: "npx",
args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
});
// 调用工具读取文件
const result = await executeMcpAction("fs", {
method: "tools/call",
params: { name: "read_file", arguments: { path: "/tmp/test.txt" } }
});
创建持久化状态存储
import { createPersistStore, indexedDBStorage } from "openclaw-claude-code-skill";
const useStore = createPersistStore(
{ count: 0, items: [] },
(set, get) => ({
increment: () => set({ count: get().count + 1 }),
addItem: (item) => set({ items: [...get().items, item] })
}),
{ name: "my-store" },
indexedDBStorage // 或省略使用localStorage
);
合并多源会话数据
import { mergeSessions, mergeWithUpdate } from "openclaw-claude-code-skill";
const mergedSessions = mergeSessions(localSessions, remoteSessions);
const mergedConfig = mergeWithUpdate(localConfig, remoteConfig);
配置文件
创建mcp_config.json定义服务器:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"],
"status": "active"
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": { "GITHUB_TOKEN": "your-token" },
"status": "active"
}
}
}
见下方输入与输出表格。
| 项目 | 内容 |
|---|---|
| 输入 | MCP服务器配置(JSON)、工具调用请求、待合并的会话数据、状态存储初始值 |
| 输出 | 工具执行结果、可用工具清单、合并后的会话/配置对象、带持久化的Zustand存储实例 |
| 适用人群 | Node.js开发者、AI应用架构师、需多设备数据同步的产品团队 |
| 不包含 | MCP服务器二进制程序、云端同步后端服务、非TypeScript/JavaScript环境支持 |
原始链接:https://github.com/openclaw/skills/tree/main/skills/enderfga/claude-code-skill/SKILL.md
来源类型:开源项目