Documentation

Give your AI agents persistent memory in one API call.

Quickstart

npm install brainbase-sdk

SDK Usage

import { Brainbase } from "brainbase-sdk";

const brain = new Brainbase({ apiKey: "bb_live_..." });

// Search your brain
const results = await brain.search("who do I know at Apple?");
// → [{ slug: "people/tim-cook", title: "Tim Cook", score: 0.92, ... }]

// Get a page
const page = await brain.getPage("people/garry-tan");
// → { title: "Garry Tan", content: "...", links: [...], timeline: [...] }

// Brain health
const stats = await brain.health();
// → { page_count: 687, link_count: 257, brain_score: 75 }

// Full knowledge graph
const graph = await brain.graph();
// → { nodes: [...], edges: [...] }

// Page links
const links = await brain.links("people/preetham-kyanam");
// → { outgoing: [...], incoming: [...] }

MCP Server

Connect any MCP-compatible agent directly:

// OpenCode / Claude Code / Cursor config
{
  "mcpServers": {
    "brainbase": {
      "command": "node",
      "args": ["brainbase-mcp"],
      "env": { "BRAINBASE_URL": "https://brainbase.belweave.ai" }
    }
  }
}

Or use the HTTP endpoint: POST /api/mcp with Authorization: Bearer bb_liv...

CLI

brainbase search "garry tan"
brainbase health
brainbase page "people/garry-tan"
brainbase links "people/preetham-kyanam"
brainbase graph

API Reference

All read endpoints are public. Write endpoints require API key auth.

Read

GET/api/brain/health

Brain statistics and health score.

GET/api/brain/stats

Detailed brain statistics (pages by type, embed coverage, most connected).

GET/api/brain/search?q=...

Full-text + ILIKE search across all pages.

GET/api/brain/list?type=&limit=&offset=

List all pages with metadata. Filter by type.

GET/api/brain/page/<slug>

Single page with content, links, and timeline.

GET/api/brain/timeline/<slug>

Timeline entries for a page.

GET/api/brain/graph

Full knowledge graph (nodes + edges).

GET/api/brain/traverse?slug=&depth=&direction=

Graph traversal from a page (out/in/both, max depth 5).

Write (Auth Required)

PUT/api/brain/page/<slug>

Create or update a page. Body: {title, type?, content?, frontmatter?}

DELETE/api/brain/page/<slug>

Delete a page and its associated data.

POST/api/brain/link

Create a link. Body: {from, to, link_type?}

DELETE/api/brain/link

Remove a link. Body: {from, to}

POST/api/brain/timeline

Add timeline entry. Body: {slug, date, summary, detail?, source?}

MCP

POST/api/mcp

JSON-RPC MCP endpoint. 16 tools: search, query, get_page, get_links, get_backlinks, get_timeline, get_health, get_stats, get_graph, list_pages, traverse_graph, put_page, delete_page, add_link, remove_link, add_timeline_entry.

Architecture

Brainbase is built on GBrain by Garry Tan. Each user gets their own isolated Postgres database on Supabase with pgvector for hybrid search. The knowledge graph uses typed wikilinks for relational queries that vector search alone can't reach.