运行时依赖
安装命令
点击复制技能文档
OpenClaw Claude Code 技能 Description
MCP (模型 上下文 Protocol) integration for OpenClaw/Clawd机器人. Use when you need to:
Connect and orchestrate MCP 工具 servers (file系统, GitHub, etc.) Persist 状态 across 会话s with 索引edDB/localStorage 同步 会话s across multiple devices
Triggers: "MCP", "工具 server", "sub-代理 orchestration", "会话 同步", "状态 persistence", "Claude Code integration"
安装ation npm 安装 OpenClaw-claude-code-技能
Core APIs MCP Server Management 导入 { 初始化Mcp系统, 添加McpServer, 执行McpAction, 获取All工具s } from "OpenClaw-claude-code-技能";
// 1. 初始化 all 配置d servers awAIt 初始化Mcp系统();
// 2. 添加 a new MCP server awAIt 添加McpServer("fs", { command: "npx", args: ["-y", "@模型上下文protocol/server-file系统", "/tmp"] });
// 3. 获取 avAIlable 工具s const 工具s = awAIt 获取All工具s();
// 4. Call a 工具 const 结果 = awAIt 执行McpAction("fs", { method: "工具s/call", params: { name: "read_file", arguments: { path: "/tmp/test.txt" } } });
状态 Persistence 导入 { 创建PersistStore, 索引edDBStorage } from "OpenClaw-claude-code-技能";
const useStore = 创建PersistStore( { count: 0, items: [] }, (设置, 获取) => ({ increment: () => 设置({ count: 获取().count + 1 }), 添加Item: (item: string) => 设置({ items: [...获取().items, item] }) }), { name: "my-store" }, 索引edDBStorage // or omit for localStorage );
// 检查 hydration 状态 if (useStore.获取状态()._哈希ydrated) { console.记录("状态 恢复d!"); }
会话 同步hronization 导入 { merge会话s, mergeWith更新, mergeKeyValueStore } from "OpenClaw-claude-code-技能";
// Merge chat 会话s from multiple sources const merged会话s = merge会话s(local会话s, remote会话s);
// Merge configs with timestamp-based resolution const mergedConfig = mergeWith更新(localConfig, remoteConfig);
Key Functions Function Purpose 初始化Mcp系统() 启动 all MCP servers from config 添加McpServer(id, config) 添加 new server dynamically 移除McpServer(id) 移除 a server 暂停McpServer(id) 暂停 a server 恢复McpServer(id) 恢复 a 暂停d server 执行McpAction(id, req) Call a 工具 on specific server 获取All工具s() 列出 all avAIlable 工具s 获取命令行工具ents状态() 获取 状态 of all MCP 命令行工具ents 设置ConfigPath(path) 设置 custom config file location 创建PersistStore() 创建 Zustand store with persistence merge会话s() Merge 会话 arrays mergeWith更新() Merge with timestamp resolution mergeKeyValueStore() Merge key-value stores Configuration
创建 mcp_config.json:
{ "mcpServers": { "file系统": { "command": "npx", "args": ["-y", "@模型上下文protocol/server-file系统", "/tmp"], "状态": "active" }, "github": { "command": "npx", "args": ["-y", "@模型上下文protocol/server-github"], "env": { "GITHUB_令牌": "your-令牌" }, "状态": "active" } } }
设置 custom config path:
导入 { 设置ConfigPath } from "OpenClaw-claude-code-技能"; 设置ConfigPath("/path/to/mcp_config.json");
Requirements Node.js 18+ TypeScript (optional but recommended) Links GitHub npm MCP Specification