Give your AI agents persistent memory in one API call.
Copy-paste ready instructions for any MCP-compatible agent (Hermes, Claude Code, Cursor, OpenCode). Replace the API key placeholder before sharing.
# Agent Onboarding: Brainbase
> **For:** Any MCP-compatible AI agent
> **Brainbase URL:** `https://brainbase.belweave.ai`
> **API Key:** `BB_API_KEY_PLACEHOLDER` ← **replace before use**
---
## 1. What You Have Access To
You are an autonomous agent with **persistent memory** via Brainbase — a polyglot knowledge graph combining Supabase Postgres + pgvector (system of record) with Neo4j (graph projection). Every user gets an isolated brain that stores everything your team learns, reads, and decides.
**Your job:** Read from the brain before answering. Write to the brain when you learn something new. Link related concepts so the graph stays connected.
---
## 2. Authentication
All write operations (and MCP calls) require an API key:
```
Authorization: Bearer ***
```
**Base URL:** `https://brainbase.belweave.ai/api/mcp`
**Multi-brain support:** If you need to access a brain other than your default, add:
```
X-Brain-Id: <brain-uuid>
```
---
## 3. MCP Tools (23 Available)
Connect via JSON-RPC 2.0 to `POST /api/mcp`.
### Read Tools (no quota cost)
| Tool | Purpose | Key Params |
|------|---------|------------|
| `search` | Full-text search pages | `query: string` |
| `query` | Natural language search | `question: string` |
| `get_page` | Get full page content + links + timeline | `slug: string` |
| `get_links` | Outgoing links from a page | `slug: string` |
| `get_backlinks` | Pages that link TO this page | `slug: string` |
| `get_timeline` | Timeline entries for a page | `slug: string` |
| `get_health` | Brain stats + score | — |
| `get_stats` | Detailed stats by type | — |
| `get_graph` | Full graph (nodes + edges) | — |
| `list_pages` | List pages with filters | `type?, written_by?, limit?, offset?` |
| `traverse_graph` | Walk the graph from a page | `slug, depth?, direction?, link_type?` |
| `list_triggers` | List active trigger rules | — |
| `pagerank` | Most central pages (Neo4j GDS or fallback) | `limit?` |
| `communities` | Louvain community detection | `limit?` |
| `shortest_path` | Shortest path between two pages | `from, to, max_depth?` |
| `similar_pages` | Pages similar by link structure | `slug, limit?` |
### Write Tools (quota-limited)
| Tool | Purpose | Key Params |
|------|---------|------------|
| `put_page` | Create/update a page | `slug, title, type?, content?, frontmatter?, written_by?` |
| `delete_page` | Remove a page | `slug` |
| `add_link` | Create typed link | `from, to, link_type?, written_by?` |
| `remove_link` | Remove a link | `from, to` |
| `add_timeline_entry` | Add event to timeline | `slug, date, summary, detail?, source?, written_by?` |
| `upsert_trigger` | Create automation rule | `name, conditions, actions, enabled?, cooldown_minutes?` |
| `run_triggers` | Manually fire rules on page | `slug, title, type?, content?` |
### Enrichment (REST API)
Brainbase's enrichment pipeline creates rich, sourced pages for people and companies with
a single API call. Uses Brave Search + OpenAI formatting.
`POST /api/brain/enrich` — See [Enrichment API](#enrichment) section below.
---
## 4. How to Think About the Brain
### Page Structure
Every page has:
- **slug** — unique ID (e.g., `people/garry-tan`, `projects/brainbase`)
- **type** — `person`, `company`, `project`, `concept`, `email`, `idea`, etc.
- **content** — markdown body
- **links** — typed connections to other pages (`related`, `works_at`, `invested_in`, `founded`, etc.)
- **timeline** — dated events
- **embeddings** — OpenAI text-embedding-3-small vector for semantic search
### Your Read Pattern (ALWAYS DO THIS FIRST)
```
1. User asks a question
2. SEARCH the brain first → get relevant slugs
3. GET_PAGE on the most relevant result → read full context
4. GET_LINKS / TRAVERSE_GRAPH → explore connections
5. Answer the user WITH citations to brain pages
```
### Your Write Pattern
```
1. You learn something new (from email, web, conversation)
2. PUT_PAGE with proper frontmatter:
---
type: email | person | company | concept | project
date: YYYY-MM-DD
source: agentmail | web | conversation
tags: [newsletter, security, ai]
---
3. If related pages exist → ADD_LINK to connect them
4. If dates mentioned → ADD_TIMELINE_ENTRY
```
---
## 5. Example Workflows
### Example 1: Answer a question about someone
```json
// 1. Search
{"method": "tools/call", "params": {"name": "search", "arguments": {"query": "Garry Tan"}}}
// 2. Get page
{"method": "tools/call", "params": {"name": "get_page", "arguments": {"slug": "people/garry-tan"}}}
// 3. Get connections
{"method": "tools/call", "params": {"name": "get_links", "arguments": {"slug": "people/garry-tan"}}}
// 4. Find most connected people
{"method": "tools/call", "params": {"name": "pagerank", "arguments": {"limit": 10}}}
```
### Example 2: Ingest a security alert
```json
// 1. Write the page
{"method": "tools/call", "params": {"name": "put_page", "arguments": {
"slug": "security/cve-2025-1234",
"title": "CVE-2025-1234: Critical RCE in OpenSSL",
"type": "concept",
"content": "# CVE-2025-1234...",
"frontmatter": {"date": "2025-04-29", "severity": "critical", "source": "nist"}
}}}
// 2. Link to affected project
{"method": "tools/call", "params": {"name": "add_link", "arguments": {
"from": "security/cve-2025-1234",
"to": "projects/brainbase",
"link_type": "affects"
}}}
```
### Example 3: Set up a trigger
```json
{"method": "tools/call", "params": {"name": "upsert_trigger", "arguments": {
"name": "cve-alert",
"conditions": {"pageType": "concept", "contentContains": ["CVE", "vulnerability"]},
"actions": [{"type": "notify", "message": "🚨 CVE detected: {slug}"}],
"enabled": true
}}}
```
### Example 4: Graph intelligence
```json
// Find shortest path between two entities
{"method": "tools/call", "params": {"name": "shortest_path", "arguments": {
"from": "people/garry-tan",
"to": "companies/anthropic",
"max_depth": 4
}}}
// Find similar pages by link structure
{"method": "tools/call", "params": {"name": "similar_pages", "arguments": {
"slug": "people/garry-tan",
"limit": 10
}}}
```
---
## 6. Important Rules
### DO
- **Search the brain first** before using external APIs or claiming ignorance
- Use descriptive slugs: `people/first-last`, `companies/company-name`, `projects/project-name`
- Include frontmatter with `type`, `date`, and `source`
- Link related pages — isolated pages are useless
- Write in markdown with headers for structure
- Use timeline entries for dated events
- Use `written_by` parameter to track which agent created content
### DON'T
- Don't write pages without checking if they already exist (search first)
- Don't create generic slugs like `page-1` or `untitled`
- Don't dump raw data — summarize and structure it
- Don't forget to link — the graph is the value
- Don't expose the API key in logs or user-facing output
---
## 7. Page Types & Conventions
| Type | Use For | Example Slug |
|------|---------|--------------|
| `person` | People your team knows | `people/jane-doe` |
| `company` | Companies, orgs | `companies/openai` |
| `project` | Code projects, initiatives | `projects/brainbase` |
| `concept` | Ideas, frameworks, CVEs | `concepts/rag-pipeline` |
| `email` | Ingested emails | `email/team/2026-04-29/subject` |
| `idea` | Raw thoughts, brainstorming | `ideas/agent-email-integration` |
| `place` | Locations, venues | `places/san-francisco` |
---
## 8. Troubleshooting
| Issue | Fix |
|-------|-----|
| `401 Unauthorized` | API key missing or invalid |
| `403 Forbidden` | You don't have access to that brain |
| `404 Page not found` | Slug doesn't exist — create it or check spelling |
| Quota exceeded | Write operations are rate-limited; wait or contact your admin |
| Graph empty | Brain has < 2 pages or no links — start adding content |
| `neo4j_not_configured` | Graph intelligence requires Neo4j; falls back to Postgres for some ops |
---
## 9. Architecture Notes
- **Database:** Polyglot — Supabase Postgres + pgvector (system of record) + Neo4j (graph projection)
- **Search:** Hybrid full-text + semantic (embeddings), RRF fusion, 7-stage pipeline
- **Graph:** Typed wikilinks stored as edge rows, projected to Neo4j for intelligence
- **Pipeline:** `put_page` → embeddings → auto-extract (wikilinks + dates + semantic links) → triggers → actions
- **Graph Backend:** Set `BRAINBASE_GRAPH_BACKEND=auto|postgres|neo4j` to control routing
- **Hosting:** Vercel, edge-cached reads
---
**Last updated:** 2026-05-03Choose your interface — CLI, SDK, or direct MCP. All use the same API under the hood.
# CLI (recommended for humans)
npm install -g brainbase-cli
brainbase config set apiKey bb_live_...
brainbase search "Garry Tan"
# SDK (recommended for Node.js apps)
npm install brainbase-sdkCopy-paste ready configs for any MCP-compatible agent. Pick your poison.
Best for agents, scripts, curl. JSON-RPC 2.0.
// 1. Initialize
POST https://brainbase.belweave.ai/api/mcp
{ "jsonrpc": "2.0", "method": "initialize", "id": 1 }
// 2. Search
POST https://brainbase.belweave.ai/api/mcp
{ "jsonrpc": "2.0", "method": "tools/call",
"params": { "name": "search", "arguments": { "query": "Garry Tan" }},
"id": 2 }
// 3. Get page
POST https://brainbase.belweave.ai/api/mcp
{ "jsonrpc": "2.0", "method": "tools/call",
"params": { "name": "get_page", "arguments": { "slug": "people/garry-tan" }},
"id": 3 }
// 4. Write
POST https://brainbase.belweave.ai/api/mcp
{ "jsonrpc": "2.0", "method": "tools/call",
"params": { "name": "put_page",
"arguments": {
"slug": "ideas/new-thing",
"title": "My New Idea",
"type": "idea",
"content": "# Hello world"
}},
"id": 4 }Shell composability, pipes, jq. Lowest cognitive overhead.
# Install & configure once
npm install -g brainbase-cli
brainbase config set apiKey <YOUR_API_KEY>
brainbase config set baseUrl https://brainbase.belweave.ai
brainbase config set brainId <BRAIN_ID> # optional
# Read
brainbase search "Garry Tan"
brainbase query "who invested in Anthropic"
brainbase health
brainbase stats
brainbase page people/garry-tan
brainbase links people/garry-tan
brainbase timeline people/garry-tan
brainbase list --type person --limit 10
brainbase traverse people/garry-tan --depth 2 --direction both
# Graph Intelligence (Neo4j)
brainbase pagerank --limit 25
brainbase communities --limit 500
brainbase shortest-path people/garry-tan companies/y-combinator
brainbase similar people/garry-tan --limit 10
brainbase graph-sync
# Enrichment
brainbase enrich "Satya Nadella" --type person --tier 2
brainbase enrich "Stripe" --tier 2 # auto-detects company
# Write
brainbase put-page ideas/new-thing "My Idea" --type idea --content "# Hello"
brainbase delete-page ideas/obsolete
brainbase add-link people/garry-tan companies/y-combinator --type works_at
brainbase remove-link people/garry-tan companies/old-company
brainbase add-timeline people/garry-tan "2024-03-01" "Became YC CEO"
# Jobs & API keys
brainbase jobs
brainbase jobs 42
brainbase api-keys
brainbase api-keys --create "my-new-key"
# Override per-command (flags > env > config)
brainbase health --api-key bb_live_other --brain-id other-brainFor Node.js / Bun apps. Full TypeScript support.
import { Brainbase } from "brainbase-sdk";
const brain = new Brainbase({
apiKey: "bb_live_...",
baseUrl: "https://brainbase.belweave.ai",
brainId: "<uuid>", // optional multi-brain
});
// Read
const results = await brain.search("Garry Tan");
const page = await brain.getPage("people/garry-tan");
const health = await brain.health();
const stats = await brain.stats();
const graph = await brain.graph();
const links = await brain.links("people/garry-tan");
const timeline = await brain.timeline("people/garry-tan");
const pages = await brain.listPages({ type: "person", limit: 10 });
const traversal = await brain.traverse("people/garry-tan", { depth: 2 });
// Ask (LLM-generated answer with sources)
const answer = await brain.ask("Who invested in Anthropic?");
// { answer: "...", sources: [...], confidence: 0.87 }
// Enrichment (3-tier system)
const result = await brain.enrich({
name: "Satya Nadella",
type: "person",
tier: 2, // 1=deep(async), 2=standard(sync), 3=quick(sync)
context: "Microsoft CEO",
});
// Graph Intelligence (Neo4j)
const pageRank = await brain.pageRank(25);
const clusters = await brain.communities(500);
const path = await brain.shortestPath("people/a", "companies/b");
const similar = await brain.similarPages("people/garry-tan", 10);
await brain.graphSync();
// Write
await brain.putPage({
slug: "ideas/new-thing",
title: "My New Idea",
type: "idea",
content: "# Markdown",
written_by: "agent-name",
});
await brain.addLink("people/garry-tan", "companies/y-combinator", "works_at");
await brain.addTimelineEntry("people/garry-tan", "2024-03-01", "Became YC CEO");
await brain.addTag("people/garry-tan", "founder");
// Jobs
const job = await brain.getJob(42);
const jobs = await brain.listJobs({ status: "active" });
// API Keys
const keys = await brain.listApiKeys();
const created = await brain.createApiKey("my-new-key");Read endpoints return data. Write endpoints require API key auth and count against quota.
/api/brain/healthBrain statistics and health score.
/api/brain/statsDetailed brain statistics (pages by type, embed coverage, most connected).
/api/brain/search?q=...Full-text + ILIKE search across all pages.
/api/brain/list?type=&written_by=&limit=&offset=List all pages with metadata. Filter by type or author.
/api/brain/page/<slug>Single page with content, links, and timeline.
/api/brain/timeline/<slug>Timeline entries for a page.
/api/brain/tags?slug=...Tags on a page.
/api/brain/versions/<slug>Page version history.
/api/brain/activity?limit=&action=Brain activity feed.
/api/brain/raw-data?slug=&source=Stored provenance data for a page.
/api/brain/graphFull knowledge graph (nodes + edges).
/api/brain/traverse?slug=&depth=&direction=&link_type=Graph traversal from a page (out/in/both, max depth 5).
/api/askLLM-generated answer with cited sources. POST body: {question}
/api/brain/page/<slug>Create or update a page. Body: {title, type?, content?, frontmatter?, written_by?}
/api/brain/page/<slug>Delete a page and its associated data.
/api/brain/linkCreate a link. Body: {from, to, link_type?, written_by?}
/api/brain/linkRemove a link. Body: {from, to}
/api/brain/timelineAdd timeline entry. Body: {slug, date, summary, detail?, source?, written_by?}
/api/brain/tagsAdd or remove tags. Body: {slug, tag, action: 'add'|'remove'}
/api/brain/enrich✨ Enrich a person/company page. 3-tier pipeline with Brave search + OpenAI. Body: {name, type?, tier?, context?, force?}
/api/brain/graph-syncTrigger Postgres → Neo4j sync. Ensures graph projection is current.
/api/brain/intel/pagerank?limit=PageRank centrality scores. GDS or degree fallback.
/api/brain/intel/communities?limit=Louvain community detection. Requires Neo4j GDS.
/api/brain/intel/shortest-path?from=&to=&maxDepth=Shortest path between two pages. Pure Cypher, always available.
/api/brain/intel/similar?slug=&limit=Node similarity by link structure. GDS or Jaccard fallback.
/api/jobsList all jobs. Optional: ?status=&limit=
/api/jobs/<id>Get job status by ID.
/api/jobs/<id>/retryRetry a failed job.
/api/keysList all API keys (masked).
/api/keysCreate new API key. Body: {name}
/api/keys?id=Revoke an API key.
/api/mcpJSON-RPC MCP endpoint. 23 tools: search, query, get_page, get_links, get_backlinks, get_timeline, get_health, get_stats, get_graph, list_pages, traverse_graph, list_triggers, pagerank, communities, shortest_path, similar_pages, put_page, delete_page, add_link, remove_link, add_timeline_entry, upsert_trigger, run_triggers.
The enrichment pipeline creates rich, sourced pages for people and companies with a single API call. Uses Brave Search for live web research and OpenAI for structured template formatting. No manual page building required.
# Enrich a person (Tier 2 — includes Brave web search)
curl -X POST https://brainbase.belweave.ai/api/brain/enrich \
-H "Authorization: Bearer <YOUR_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"name":"Satya Nadella","type":"person","tier":2}'
# Response
# {
# "slug": "people/satya-nadella",
# "action": "created",
# "sources": ["brave", "openai"],
# "_diag": { "braveCalled": true, "braveResults": 5 },
# "linksCreated": 3,
# "rawDataStored": 2
# }person, company, or auto (heuristics — default)tier1, 2 (default), or 3contextFree text about the entity (1.6-1.9x richer pages)forceRe-enrich even if updated within 7 daysBrainbase uses polyglot storage: Supabase Postgres + pgvector as the system of record, with an optional Neo4j projection for graph intelligence. Each user gets an isolated brain.
7-stage hybrid search: FTS → vector search → RRF fusion → compiled truth boost → backlink boost → intent re-ranking → structured handlers.
Set BRAINBASE_GRAPH_BACKEND to control routing:
auto (default) — Try Neo4j, fall back to Postgrespostgres — Always Postgres (recursive CTEs)neo4j — Neo4j only, no fallbackNightly autonomous enrichment: extract wikilinks → embed → orphans (semantic links) → patterns → entity tiers → graph-sync.