OpenClaw Integration

Integrate MoltBrain with OpenClaw to give your multi-channel AI assistant persistent memory across Discord, Slack, iMessage, and Teams. Your agent remembers conversations, preferences, and context across all channels.

Installation

OpenClaw supports multiple integration methods. Choose the one that best fits your setup.

RECOMMENDED

Extension Method

The extension method provides full lifecycle hook integration, giving you automatic memory capture and injection at every stage of the agent loop.

Installation Steps
# Install MoltBrain extension
cp -r moltbrain-extension ~/.openclaw/extensions/moltbrain

# Restart OpenClaw gateway
openclaw gateway restart

Note: The extension directory is typically located at~/.openclaw/extensions/on Unix systems or %APPDATA%\.openclaw\extensions\ on Windows.

MCP Server Method

Use the Model Context Protocol server for a standardized integration that works with any MCP-compatible client.

MCP Configuration
# Add to OpenClaw MCP configuration
{
  "mcp": {
    "servers": {
      "moltbrain": {
        "command": "node",
        "args": ["path/to/moltbrain/mcp-server.js", "--stdio"],
        "env": {
          "MOLTBRAIN_WORKER_PORT": "37777"
        }
      }
    }
  }
}

After adding the configuration, restart OpenClaw to load the MCP server.

Skill Method

Install MoltBrain as an OpenClaw skill for tool-based integration:

Skill Installation
# Copy skill.json to OpenClaw skills directory
cp moltbrain-skill.json ~/.openclaw/skills/moltbrain.json

# Configure in OpenClaw config
{
  "skills": {
    "moltbrain": {
      "enabled": true
    }
  }
}

Features

Cross-Channel Memory

Your agent remembers conversations across all channels. Start a conversation on Discord, continue on Slack, and your agent maintains full context.

Example flow:

User asks about auth on Discord
Agent remembers OAuth2 setup from previous session
User switches to Slack
Agent continues with full context, no re-explaining needed

Lifecycle Hooks

MoltBrain integrates at every stage of the agent lifecycle, providing automatic memory capture and injection.

Lifecycle Hook Flow

SESSION START
    │
    ▼
onSessionStart()
    ├─► Query SQLite for recent observations
    ├─► Search ChromaDB for relevant context
    └─► Inject top N memories into agent context
    │
    ▼
onMessage(userMessage)
    ├─► Extract keywords from message
    ├─► Semantic search in ChromaDB
    └─► Add relevant memories to context
    │
    ▼
onResponse(agentResponse)
    ├─► Extract observations
    ├─► Generate embeddings
    ├─► Store in SQLite
    └─► Store in ChromaDB
    │
    ▼
onSessionEnd()
    ├─► Generate session summary
    └─► Store session metadata

onSessionStart()

Queries memories and injects context. Agent starts with full project history.

onMessage()

Searches for relevant memories based on user message. Adds to context dynamically.

onResponse()

Captures observations from agent response. Stores facts, decisions, code.

onSessionEnd()

Generates summary of session. Aggregates learnings and decisions.

Configuration

Configure MoltBrain in your OpenClaw extension settings or environment variables.

Basic Configuration

Extension Configuration
{
  "MOLTBRAIN_WORKER_PORT": 37777,
  "MOLTBRAIN_CONTEXT_OBSERVATIONS": 50,
  "MOLTBRAIN_PROVIDER": "claude",
  "MOLTBRAIN_PRUNE_DAYS": 0
}

MOLTBRAIN_WORKER_PORT - Port for the worker service (default: 37777)

MOLTBRAIN_CONTEXT_OBSERVATIONS - Number of memories to inject (default: 50)

MOLTBRAIN_PROVIDER - LLM provider for embeddings (claude, openai)

MOLTBRAIN_PRUNE_DAYS - Days before pruning old memories (0 = never)

MCP Tools Available

When using the MCP server method, these tools are available to your agent:

recall_context

Recall relevant context from memory

{
  "query": "authentication setup",
  "limit": 50,
  "projectPath": "/Users/dev/my-app"
}

search_memories

Semantic search across all memories

{
  "query": "JWT token structure",
  "limit": 10
}

save_memory

Manually save an observation to memory

{
  "type": "decision",
  "content": "Use PostgreSQL for data storage",
  "metadata": {
    "files": ["database.ts"]
  }
}

Use Cases

Multi-Channel Continuity

User starts conversation on Discord, switches to Slack, continues on iMessage - agent remembers everything.

Project Memory

Agent remembers architecture decisions, code patterns, and preferences across all sessions.

Learning Over Time

Agent learns from every interaction and builds upon previous work, not starting from scratch each time.

Troubleshooting

Extension not loading

Check that the extension is in the correct directory and restart OpenClaw gateway.

ls ~/.openclaw/extensions/

Worker service connection failed

Ensure the worker service is running on the configured port.

curl http://localhost:37777/health