Pattern 2: MCP
Connect Claude Code, Cursor, Claude Desktop, ChatGPT, or any MCP-compatible client directly to the Mind Layer. Your assistant sees Sonzai as a set of tools and resources it can call by name.
The Mind Layer ships a hosted Streamable HTTP MCP endpoint at
https://api.sonz.ai/mcp/memory/{agent_id}. Point any MCP-compatible
client at it with your Sonzai API key — 34 tools, 4 resources, and
3 guided prompts. No local binary, no SSE port, no Go toolchain.
When to use this
- The user is already inside Claude Code, Cursor, Claude Desktop, ChatGPT, or another MCP-aware client.
- You want to drive Sonzai by conversation rather than by SDK code.
- You're prototyping — pick the
create-companionormind-layer-setupguided prompt and skip writing any code at all.
When to switch
- Building your own product UI — switch to Pattern 1: Managed Runtime.
- You want Sonzai inside your own LLM loop, not as a tool exposed to someone else's — switch to Pattern 4: Standalone Realtime.
Architecture
┌────────────────────────┐ ┌──────────────────────┐
│ Claude Code · Cursor │ │ Sonzai Mind Layer │
│ ChatGPT · VS Code │ │ │
│ Claude Desktop │ │ │
└──────────┬─────────────┘ └──────────┬───────────┘
│ │
│ Streamable HTTP (JSON-RPC 2.0) │
│ • list_agents │
│ • chat / start_session / end_session │
│ • search_memories / list_facts │
│ • get_personality / get_mood │
│ • generate_character / trigger_event │
│ • schedule_wakeup / list_notifications │
│ │
▼ │
https://api.sonz.ai/mcp/memory/{agent_id} │
Authorization: Bearer sk-your-api-key │
│
▼
Context Engine,
AI Service, DBs
End-to-end snippet
You need a project API key from your dashboard and an agent ID. Pick your client below — pasting the snippet is the entire setup.
# One-liner — registers the hosted MCP server with Claude Code:
claude mcp add --transport http sonzai \
https://api.sonz.ai/mcp/memory/AGENT_ID \
--header "Authorization: Bearer $SONZAI_API_KEY"
# Then from any Claude Code session you can say:
# "Chat with agent 'Luna' and say 'I had a great day hiking today!'"
# "Search Luna's memories about hiking adventures"
# "Use mind-layer-setup with assistant_name 'Aria' …"Streamable HTTP, not SSE
The 2026 MCP spec marks Streamable HTTP as the canonical remote transport. SSE is on a deprecation path across major clients — prefer HTTP for any new integration.
Treat the API key like a password
The Bearer token is your project API key — it grants full access to every agent in the project. Don't commit it to public repos; use per-developer scopes when collaborating.
Where to next
Pattern 1: Managed Agent Runtime
The highest-level path. You hand Sonzai a user message, Sonzai returns a streamed reply, and memory, mood, personality, and tool execution all happen on our side.
Pattern 3: OpenClaw
Drop the @sonzai-labs/openclaw-context plugin into an OpenClaw project and Sonzai becomes the agent's contextEngine — persistent memory, mood, personality, relationships, all under OpenClaw's existing chat loop.