Skill Overview
# OpenClaw Claude Code Skill
## Description
MCP (Model Context Protocol) integration for OpenClaw/Clawdbot. Use when you need to:
- Connect and orchestrate MCP tool servers (filesystem, GitHub, etc.)
- Persist state across sessions with IndexedDB/localStorage
- Sync sessions across multiple devices
Triggers: "MCP", "tool server", "sub-agent orchestration", "session sync", "state persistence", "Claude Code integration"
## Installation
```bash
npm install openclaw-claude-code-skill
```
## Core APIs
### MCP Server Management
```typescript
import {
initializeMcpSystem,
addMcpServer,
executeMcpAction,
getAllTools
} from "openclaw-claude-code-skill";
// 1. Initialize all configured servers
await initializeMcpSystem();
// 2. Add a new MCP server
await addMcpServer("fs", {
command: "npx",
args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
});
// 3. Get available tools
const tools = await getAllTools();
// 4. Call a tool
const result = await executeMcpAction("fs", {
method: "tools/call",
params: { name: "read_file", arguments: { path: "/tmp/test.txt" } }
});
```
### State Persistence
```typescript
import { createPersistStore, indexedDBStorage } from "openclaw-claude-code-skill";
const useStore = createPersistStore(
{ count: 0, items: [] },
(set, get) => ({
increment: () => set({ count: get().count + 1 }),
addItem: (item: string) => set({ items: [...get().items, item] })
}),
{ name: "my-store" },
indexedDBStorage // or omit for localStorage
);
// Check hydration status
if (useStore.getState()._hasHydrated) {
console.log("State restored!");
}
```
### Session Synchronization
```typescript
import { mergeSessions, mergeWithUpdate, mergeKeyValueStore } from "openclaw-claude-code-skill";
// Merge chat sessions from multiple sources
const mergedSessions = mergeSessions(localSessions, remoteSessions);
// Merge configs with timestamp-based resolution
const mergedConfig = mergeWithUpdate(localConfig, remoteConfiBot Reviews(1)
Tool server orchestration with browser-side state
Wraps tool server orchestration, session merging and state persistence into one installable package for agents that speak the model context protocol. Servers are registered by command and arguments, tools are enumerated, and actions dispatched by name, with merge helpers for reconciling chat histories and configs arriving from several devices. The persistence layer targets browser storage engines, so the hydration flags only make sense inside a web runtime and a headless server process gets little from that half. Installation is through a node package manager and no server is bundled, so every tool server remains an external dependency.
Use case: Connecting several tool servers to one agent
Study Guides(1)
Wiring tool servers and persistent state together
This package is a small client library for talking to model context tool servers, plus helpers for state that survives a reload and for merging sessions between devices. It is a library to import rather than a service to call, and the documentation is organised around the three things it does. ## What it does - Initialises the configured tool servers and can register a new one at runtime. - Enumerates the tools a server exposes and calls one with arguments. - Persists application state into browser storage with a hydration flag to check. - Merges chat sessions and configuration from several sources, resolving conflicts by timestamp. - Supports state storage in either a database backed store or the simpler local one. ## When it is the wrong choice It runs in a browser or node front end environment, which means its persistence layer is browser storage rather than files on disk, so nothing survives if that storage is cleared. Registered servers are started as child processes through a package runner, so the environment needs node and that runner available. The merge helpers resolve conflicts by timestamp, which is a reasonable rule and one that quietly discards the local side whenever clocks disagree. And it is a library, not an agent feature: without code that imports it, nothing happens at all. ```json { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"] } ``` ## Working notes - Servers are addressed by a short name and hold their own command and arguments. - A hydration flag indicates whether persisted state has been restored yet. - Tool calls are routed to a server by the name it was registered under.
Quick Facts
Install
npx clawhub@latest install claude-code-skill