Integration Guide

AgentBay + OpenClaw

Give your OpenClaw agent a persistent brain. Memories survive restarts, context transfers between sessions, and knowledge shares across your agent fleet.

How It Works

OpenClaw connects to AgentBay via MCP (Model Context Protocol). Every memory operation flows through a secure, authenticated channel. Your agent stores what it learns, and recalls it when relevant — across sessions, restarts, and even across different machines.


  ┌─────────────────────────────────────────────────────────┐
  │                    Your Machine                         │
  │                                                         │
  │  ┌──────────────┐         ┌──────────────────────────┐  │
  │  │              │  MCP    │                          │  │
  │  │   OpenClaw   │────────▶│   AgentBay MCP Server    │  │
  │  │   Agent      │◀────────│   (npx aiagentsbay-mcp)  │  │
  │  │              │         │                          │  │
  │  └──────────────┘         └────────────┬─────────────┘  │
  │                                        │                │
  └────────────────────────────────────────┼────────────────┘
                                           │ HTTPS
                                           ▼
                               ┌───────────────────────┐
                               │                       │
                               │   AgentBay Cloud      │
                               │                       │
                               │  ┌─────────────────┐  │
                               │  │  Memory Engine   │  │
                               │  │  ┌───┐ ┌───┐    │  │
                               │  │  │FTS│ │VEC│    │  │
                               │  │  └───┘ └───┘    │  │
                               │  │  ┌───┐ ┌───┐    │  │
                               │  │  │TAG│ │ALI│    │  │
                               │  │  └───┘ └───┘    │  │
                               │  └─────────────────┘  │
                               │                       │
                               │  ┌─────────────────┐  │
                               │  │  Knowledge DB    │  │
                               │  │  (encrypted)     │  │
                               │  └─────────────────┘  │
                               │                       │
                               └───────────────────────┘

Figure 1: Single Agent — Memory Flow


  ┌─────────────┐    ┌─────────────┐    ┌─────────────┐
  │  OpenClaw    │    │ Claude Code │    │   Cursor    │
  │  (Mac Mini)  │    │  (Laptop)   │    │   (IDE)     │
  └──────┬───────┘    └──────┬──────┘    └──────┬──────┘
         │                   │                   │
         │       MCP         │       MCP         │
         ▼                   ▼                   ▼
  ┌────────────────────────────────────────────────────┐
  │              AgentBay Cloud                        │
  │                                                    │
  │  ┌──────────┐  ┌──────────┐  ┌──────────┐        │
  │  │ Brain A  │  │ Brain B  │  │ Brain C  │        │
  │  │(OpenClaw)│  │(Claude)  │  │(Cursor)  │        │
  │  └────┬─────┘  └────┬─────┘  └────┬─────┘        │
  │       │              │              │              │
  │       └──────────────┼──────────────┘              │
  │                      ▼                             │
  │            ┌──────────────────┐                    │
  │            │   Shared Team    │                    │
  │            │   Knowledge      │                    │
  │            │                  │                    │
  │            │  Auto-shared     │                    │
  │            │  pitfalls,       │                    │
  │            │  decisions,      │                    │
  │            │  patterns        │                    │
  │            └──────────────────┘                    │
  │                                                    │
  └────────────────────────────────────────────────────┘

Figure 2: Multi-Agent Team — Shared Knowledge

Setup Guide

1Get Your API Key

Sign up at AgentBay and create an API key from your dashboard.

# 1. Register at https://www.aiagentsbay.com/register
# 2. Go to Dashboard → API Keys
# 3. Create a new key (starts with ab_live_)
2Configure OpenClaw MCP

Add AgentBay as an MCP server in your OpenClaw configuration.

// In your OpenClaw config (openclaw.json or MCP settings):
{
  "mcpServers": {
    "agentbay": {
      "command": "npx",
      "args": ["aiagentsbay-mcp", "--api-key", "ab_live_your_key_here"]
    }
  }
}

// Or use the HTTP endpoint (no npm needed):
{
  "mcpServers": {
    "agentbay": {
      "url": "https://www.aiagentsbay.com/api/mcp",
      "headers": {
        "Authorization": "Bearer ab_live_your_key_here"
      }
    }
  }
}

The npm package runs locally and proxies to the cloud. The HTTP endpoint connects directly. Both provide the same 117 MCP tools.

3Store Your First Memory

Once connected, your OpenClaw agent can store and recall memories using MCP tools.

# Your agent calls these MCP tools automatically:

# Store a pattern
agentbay_memory_store(
  title="Auth uses JWT with 24h expiry",
  content="The authentication system uses JWT tokens...",
  type="PATTERN",
  tags=["auth", "jwt", "security"]
)

# Recall relevant memories
agentbay_memory_recall(
  query="how does authentication work?"
)
# → Returns matching memories ranked by relevance
4Set Up a Project (Optional)

Projects scope memories to a specific codebase. Your agent gets full context on join.

# Create a project
agentbay_project_create(name="my-app")

# One-call onboarding — agent gets everything:
agentbay_project_onboard(project_id="...")
# → Returns: file tree, tasks, knowledge, failures, directives

# Store project-scoped knowledge
agentbay_knowledge_record(
  project_id="...",
  title="Database migration pattern",
  content="Always use prisma db push, never migrate dev in prod",
  type="PITFALL"
)
5Join a Team (Optional)

Teams let multiple agents share knowledge. When one agent learns a pitfall, every agent on the team sees it.

# Your OpenClaw agent joins a team with other agents
# (Claude Code, Cursor, custom agents)

# Set auto-share policy — pitfalls propagate automatically
agentbay_team_set_policy(
  team_id="...",
  auto_share_types=["PITFALL", "DECISION", "ARCHITECTURE"]
)

# Now when OpenClaw stores a PITFALL:
# → Auto-shared to Claude Code and Cursor
# → They see it before making the same mistake
Memory Lifecycle

Every memory goes through a lifecycle that keeps knowledge fresh and relevant.


  Agent stores memory
         │
         ▼
  ┌──────────────┐
  │  Validation   │──── Poison detection (20+ patterns)
  │  & Dedup      │──── Duplicate check (title + type)
  └──────┬────────┘
         │
         ▼
  ┌──────────────┐
  │  Persist &    │──── Encrypt content (AES-256)
  │  Embed        │──── Generate search vectors
  └──────┬────────┘
         │
         ▼
  ┌──────────────┐
  │  Entity       │──── Extract: files, functions, tools
  │  Extraction   │──── Auto-link related entries
  └──────┬────────┘
         │
         ▼
  ┌──────────────┐
  │  Team         │──── If type matches auto-share policy
  │  Auto-Share   │──── Copy to team scope
  └──────┬────────┘
         │
         │                    ┌──────────────────────┐
         │   Nightly ────────▶│  Dreaming Cycle      │
         │                    │                      │
         │                    │  • Promote entries    │
         │                    │  • Synthesize related │
         │                    │  • Find conflicts     │
         │                    │  • Update vectors     │
         │                    └──────────────────────┘
         │
         ▼
  ┌──────────────┐
  │  Recall       │──── 4-strategy fusion search
  │  (on query)   │──── Confidence-weighted ranking
  └──────────────┘

Figure 3: Memory Lifecycle — From Store to Consolidation

Search Architecture

When your agent recalls a memory, AgentBay runs four independent search strategies in parallel and fuses the results for maximum accuracy.


                    ┌─────────────┐
                    │    Query    │
                    │ "auth bug"  │
                    └──────┬──────┘
                           │
              ┌────────────┼────────────┐
              │            │            │
              ▼            ▼            ▼
     ┌────────────┐ ┌───────────┐ ┌───────────┐
     │   Alias    │ │    Tag    │ │ Full-Text │
     │  Matching  │ │ Intersect │ │  Search   │
     │            │ │           │ │  (BM25)   │
     │ Exact name │ │ Category  │ │  Keyword  │
     │ lookups    │ │ matching  │ │  ranking  │
     └─────┬──────┘ └─────┬─────┘ └─────┬─────┘
           │              │              │
           └──────────────┼──────────────┘
                          │
                          ▼
                 ┌─────────────────┐
                 │   RRF Fusion    │
                 │                 │
                 │  Combines all   │
                 │  strategies     │
                 │  by rank        │
                 └────────┬────────┘
                          │
                          ▼
                 ┌─────────────────┐
                 │  Confidence     │
                 │  Weighting      │
                 │                 │
                 │  Fresh > Stale  │
                 │  Verified > New │
                 └────────┬────────┘
                          │
                          ▼
                 ┌─────────────────┐
                 │   Top Results   │
                 │   (ranked)      │
                 └─────────────────┘

Figure 4: Multi-Strategy Search Fusion

This multi-strategy approach means your agent finds the right memory whether the query is an exact function name (getUserById), a tag-based category (auth), or a natural language question (how does the login flow work?).

What Should Your Agent Store?

Store These

  • PATTERN Reusable code patterns
  • PITFALL Bugs and their root causes
  • DECISION Why you chose X over Y
  • ARCHITECTURE System design choices
  • DEPENDENCY Library configurations
  • PERFORMANCE Optimization notes
  • CONTEXT Deploy configs, env vars
  • TEST_INSIGHT Testing strategies

Don't Store These

  • Raw logs or stack traces (store the fix, not the noise)
  • Temporary status updates
  • Secrets or API keys (use env vars)
  • Entire file contents (store patterns from the file)
  • Duplicate information (auto-dedup handles this)
Security Model

  ┌─────────────────────────────────────────────┐
  │              Agent Request                   │
  └─────────────────────┬───────────────────────┘
                        │
                        ▼
  ┌─────────────────────────────────────────────┐
  │  Authentication     │  API key validation    │
  │                     │  Rate limiting         │
  └─────────────────────┬───────────────────────┘
                        │
                        ▼
  ┌─────────────────────────────────────────────┐
  │  Content Safety     │  Poison detection      │
  │                     │  (prompt injection,    │
  │                     │   data exfiltration,   │
  │                     │   destructive cmds)    │
  └─────────────────────┬───────────────────────┘
                        │
                        ▼
  ┌─────────────────────────────────────────────┐
  │  Encryption         │  AES-256 at rest       │
  │                     │  HTTPS in transit      │
  └─────────────────────┬───────────────────────┘
                        │
                        ▼
  ┌─────────────────────────────────────────────┐
  │  Access Control     │  Project-scoped        │
  │                     │  Team roles            │
  │                     │  Agent permissions     │
  └─────────────────────────────────────────────┘

Figure 5: Security Layers

Every memory write is scanned for prompt injection, data exfiltration, and destructive commands before storage. Content is encrypted at rest. Team sharing uses role-based access control (admin, contributor, viewer, auditor).

Advanced: Python SDK Integration

For deeper integration, use the Python SDK alongside MCP.

from agentbay import AgentBay

# Connect to your brain
brain = AgentBay("ab_live_your_key", project_id="your-project")

# Auto-memory chat — wraps any LLM call
response = brain.chat(
    [{"role": "user", "content": "Fix the auth session bug"}],
    provider="openai",
    model="gpt-4o"
)
# Automatically: recalls relevant memories → injects context → calls LLM → stores learnings

# Direct memory operations
brain.store("Always hash passwords with bcrypt cost 12",
            title="Password hashing", type="PATTERN")
results = brain.recall("password security")

# Team operations
brain.team("my-team").set_policy(auto_share_types=["PITFALL", "DECISION"])
brain.team("my-team").invite("cursor-agent", role="contributor")