Integration Guides
OpenClaw Integration
Complete guide to integrating HyperMemory with OpenClaw
OpenClaw Integration
This guide covers integrating HyperMemory with OpenClaw, the open-source AI agent framework.
Prerequisites
- OpenClaw installed and configured
- A HyperMemory account (sign up)
- A HyperMemory API key
Installation
Step 1: Configure MCP servers
Add HyperMemory to your OpenClaw MCP configuration:
{
"mcpServers": {
"hypermemory": {
"type": "url",
"url": "https://api.hypermemory.io/mcp",
"headers": {
"Authorization": "Bearer YOUR_API_KEY"
}
}
}
}
Step 2: Set environment variable
Store your API key securely:
export HYPERMEMORY_API_KEY="your_api_key_here"
Update your configuration to use the environment variable:
{
"mcpServers": {
"hypermemory": {
"type": "url",
"url": "https://api.hypermemory.io/mcp",
"headers": {
"Authorization": "Bearer ${HYPERMEMORY_API_KEY}"
}
}
}
}
Step 3: Verify connection
Test the connection by listing available tools:
from openclaw import Agent
agent = Agent()
tools = agent.list_mcp_tools()
memory_tools = [t for t in tools if t.name.startswith('memory_')]
print(f"Found {len(memory_tools)} memory tools")
Expected output: Found 8 memory tools
Basic usage
Store memories programmatically
from openclaw import Agent
agent = Agent()
# Store a memory
result = await agent.call_tool(
"memory_store",
{
"content": "Project Phoenix deadline is Q3 2026",
"node_type": "project",
"metadata": {
"project": "Phoenix",
"deadline": "Q3-2026"
}
}
)
print(f"Stored memory: {result['id']}")
Recall memories
# Query memories
results = await agent.call_tool(
"memory_recall",
{
"query": "When is the Phoenix project deadline?",
"max_results": 5
}
)
for memory in results['results']:
print(f"- {memory['content']} (relevance: {memory['relevance']})")
Find related memories
# Find related nodes
related = await agent.call_tool(
"memory_find_related",
{
"node_id": "node_abc123",
"depth": 2
}
)
for node in related['results']:
print(f"- {node['content']} (distance: {node['distance']})")
Advanced patterns
Agent with persistent memory
Create an agent that automatically uses memory:
from openclaw import Agent, SystemPrompt
system_prompt = SystemPrompt("""
You are an assistant with persistent memory.
When the user shares information worth remembering:
- Use memory_store to save it
- Use appropriate node_types (person, project, decision, fact)
- Add relevant metadata
When the user asks about past information:
- Use memory_recall to search your knowledge
- Use memory_find_related to discover connections
Always confirm when you've stored or retrieved memories.
""")
agent = Agent(system_prompt=system_prompt)
Memory-augmented workflows
from openclaw import Agent, Workflow
class ResearchWorkflow(Workflow):
async def execute(self, topic):
# Check existing knowledge
existing = await self.agent.call_tool(
"memory_recall",
{"query": f"What do I know about {topic}?"}
)
if existing['results']:
# Build on existing knowledge
context = "\n".join([r['content'] for r in existing['results']])
else:
context = "No prior knowledge"
# Perform research
research_result = await self.agent.research(topic, context=context)
# Store new findings
await self.agent.call_tool(
"memory_store",
{
"content": research_result.summary,
"node_type": "research",
"metadata": {"topic": topic}
}
)
return research_result
Multi-agent memory sharing
from openclaw import Agent
# Create agents sharing the same memory graph
research_agent = Agent(
name="researcher",
mcp_config={"hypermemory": {...}}
)
writer_agent = Agent(
name="writer",
mcp_config={"hypermemory": {...}} # Same API key = same graph
)
# Research agent stores findings
await research_agent.call_tool(
"memory_store",
{"content": "Key finding: Market growing 15% YoY", "node_type": "research"}
)
# Writer agent retrieves them
findings = await writer_agent.call_tool(
"memory_recall",
{"query": "market research findings"}
)
Error handling
from openclaw import Agent, MCPError
agent = Agent()
try:
result = await agent.call_tool(
"memory_recall",
{"query": "project status"}
)
except MCPError as e:
if e.code == "RATE_LIMITED":
print(f"Rate limited. Retry after {e.retry_after} seconds")
elif e.code == "UNAUTHORIZED":
print("Check your API key")
else:
print(f"Error: {e.message}")
Troubleshooting
Tools not discovered
Symptoms: list_mcp_tools() returns empty or missing memory tools
Solutions:
- Verify the MCP server URL is correct
- Check API key is valid
- Restart the agent
Connection timeouts
Symptoms: Operations hang or timeout
Solutions:
- Check network connectivity
- Increase timeout settings:
agent = Agent(
mcp_timeout=30 # seconds
)
Memory not persisting
Symptoms: Stored memories aren’t found on recall
Solutions:
- Check the
memory_storeresponse for errors - Verify you’re using the same graph_id
- Wait a moment for indexing (usually instant)
Best practices
Batch related stores when possible to create relationships atomically.