Memory & MCP 🟡
Memory gives AI long-term memory across sessions. MCP (Model Context Protocol) connects AI to external systems. This chapter explains both mechanisms.
I. Memory System
Memory is a Capability Plugin providing two tools:
memory_create(content)— write to long-term memorymemory_search(query)— retrieve from long-term memory
Each Bootstrap automatically searches for memories relevant to the current conversation and injects them into the System Prompt.
Memory Storage
Local vector store (memory-core plugin):
type MemoryEntry = {
id: string;
content: string;
embedding: Float32Array; // vector embedding via LLM API
tags: string[]; // agentId, sessionKey, etc.
createdAt: Date;
accessedAt: Date;
};
External memory service (memory-mcp plugin) — connects via MCP protocol:
plugins:
- id: memory-mcp
mcp:
command: npx
args: ['-y', '@mem0/mcp-server']
II. MCP (Model Context Protocol)
MCP is an open protocol by Anthropic allowing AI models to access external tools and data sources through a standardized interface.
Three Integration Modes
Mode 1: mcporter plugin (subprocess, most common):
plugins:
- id: mcporter
mcpServers:
filesystem:
command: npx
args: ['-y', '@modelcontextprotocol/server-filesystem', '/workspace']
github:
command: npx
args: ['-y', '@modelcontextprotocol/server-github']
env:
GITHUB_TOKEN: "${env:GITHUB_TOKEN}"
Mode 2: Embedded MCP (embedded-pi-mcp.ts) — runs in the same process, no subprocess needed. Used for LSP integration and other in-process tools.
Mode 3: HTTP MCP — connects to remote MCP servers over HTTP.
MCP Tool Registration
After an MCP Server starts, mcporter:
- Calls
tools/listto get the server's tool list - Wraps each MCP tool in OpenClaw's tool format (with JSON Schema)
- Registers via
api.tools.register() - Agent can call them just like built-in tools
III. Bundle MCP Mode
OpenClaw itself can act as an MCP Server — exposing Agent capabilities to external MCP clients. This enables nesting: another AI application can call OpenClaw agents via MCP.
Key Source Files
| File | Size | Role |
|---|---|---|
extensions/memory-core/ | - | Local vector memory plugin |
src/agents/embedded-pi-mcp.ts | 0.95KB | Embedded MCP Server |
extensions/mcporter/ | - | mcporter plugin (subprocess MCP) |
Summary
- Memory plugin provides cross-session memory:
memory_createwrites,memory_searchretrieves, Bootstrap auto-injects relevant memories. - Three MCP integration modes: subprocess (mcporter), embedded, remote HTTP.
- MCP tools integrate transparently: registered as regular agent tools, same usage experience as built-ins.
- Bundle MCP: OpenClaw itself can be exposed as an MCP Server for multi-layer AI nesting.