Build Guide

Open Brain: Your AI-Readable Memory Infrastructure

One database. One protocol. Every AI you use shares the same persistent memory of you. No middleware, no SaaS chains, no lock-in.

TL;DR

Every AI platform has built a walled garden of memory. Claude doesn't know what you told ChatGPT. ChatGPT doesn't follow you into Cursor. Your knowledge is a hostage to whichever platform you've spent the most time with. Open Brain breaks that: a Postgres database with vector embeddings, exposed via MCP, that any tool can read from and write to. Type a thought into Slack, Telegram, or WhatsApp - or tell Claude "save this thought" mid-conversation - it's embedded and classified in seconds. Then search it by meaning from any AI client or chat app. Total cost: about $0.10-0.30/month.

Architecture

How Open Brain Works

One database at the center. Everything that can write to it can also read from it. Slack, Telegram, WhatsApp, Claude, ChatGPT, Cursor - they all go both ways. Everything connects through Supabase Edge Functions and MCP. Nothing running on your machine.

▼ Write (capture thoughts)
💬 SlackType a thought
✈️ TelegramType a thought
📲 WhatsAppType a thought
Claude"Save this thought"
ChatGPT"Remember this"
Cursor"Save this idea"
Ingest
Embed
Classify
Store

🗃 Open Brain DB

Postgres + pgvector on Supabase

Thoughts + Embeddings + Metadata

search_thoughts
list_thoughts
brain_stats
▲ Read (query your brain)
💬 Slack"search: career"
✈️ Telegram"search: career"
📲 WhatsApp"search: career"
Claude"What did I note?"
ChatGPT"Find my notes on..."
Cursor"Check my brain for..."

Capture Flow

Same pipeline whether you type in a chat app or say "save this" in an AI conversation

You capture a thought Type in Slack, Telegram, or WhatsApp. Or tell any AI "save this thought" mid-conversation.
Edge Function receives it Via platform webhook or MCP save_thought call.
Embed 1536d vector
+
Classify People, topics, type
Stored in your database Postgres + pgvector on Supabase.

Retrieval Flow

Any AI or chat app can search your brain by meaning, not keywords

You ask naturally "What did I note about career changes?" from any connected client.
search_thoughts via MCP Query sent to the Edge Function.
Query embedded Same 1536d vector space.
Cosine similarity match "leaving her job" matches "career changes" - zero shared keywords.
Ranked results returned With metadata and similarity scores.
Why Semantic Search Changes Everything "Sarah mentioned she's thinking about leaving her job" matches a query about "career changes" even though they share zero keywords. The vector embedding captures meaning, not text. That's the difference between Ctrl+F and actually understanding your notes.
Without Open Brain With Open Brain
Re-explain context in every new chat AI loads your context via MCP automatically
Locked into one platform's memory Any AI tool reads the same brain
Insights lost in old conversations Every thought searchable by meaning, forever
You own nothing, platform owns everything Your database, your protocol, your data

The Build Guide

45 minutes. Zero coding experience needed. Capture and query from Slack, Telegram, WhatsApp, or any AI client.

Before You Start

What You Need

~45 min total setup time
$0 Supabase free tier
$0 Platform free tier
~$5 OpenRouter credits (lasts months)
Service Role Cost
Supabase Your database - stores everything (Postgres + pgvector + Edge Functions) Free tier
OpenRouter Your AI gateway - embeddings ($0.13/M tokens) + metadata extraction via gpt-4o-mini ~$0.10-0.30/mo
Slack / Telegram / WhatsApp Your capture and query interface - type thoughts in, search them out (pick one or more) Free
Credential Tracker You'll generate API keys, passwords, and IDs across three services. Copy this list into a text editor right now and fill it in as you go. Each item tells you which step generates it.
--- OPEN BRAIN CREDENTIALS (fill as you go) ---

Supabase Project ref:         [Step 1 - from dashboard URL]
Supabase Database password:   [Step 1 - generated during setup]
Supabase Project URL:         [Step 3 - Settings > API]
Supabase Service role key:    [Step 3 - Settings > API]
OpenRouter API key:           [Step 4 - openrouter.ai/keys]
Capture Channel/Group ID:     [Step 5 - platform-specific [if using Slack/Telegram/WhatsApp]]
Bot Token / Bot API Key:      [Step 6 - platform-specific [if using Slack/Telegram/WhatsApp]]
Edge Function URL:            [Step 7 - after deploy]
MCP Access Key:               [Step 10 - generated random hex]
MCP Server URL:               [Step 11 - after deploy]

Part 1: Capture

Steps 1-9: Your message goes to an Edge Function, which embeds, classifies, and stores it. Works with Slack, Telegram, or WhatsApp.

1
Create Your Supabase Project
~3 minutes

Supabase is your database. It stores raw text, vector embeddings, and structured metadata. It also gives you a REST API and Edge Functions runtime automatically.

  1. Go to supabase.com and sign up (GitHub login is fastest)
  2. Click New Project in the dashboard
  3. Pick your organization (default is fine)
  4. Project name: open-brain
  5. Generate a strong database password - paste into credential tracker NOW
  6. Pick the Region closest to you
  7. Click Create new project and wait 1-2 minutes
Grab Your Project Ref It's the random string in your dashboard URL: supabase.com/dashboard/project/THIS_PART. Paste it into the tracker.
2
Set Up the Database
~5 minutes

Three SQL commands, pasted one at a time. Creates your storage table, search function, and security policy.

A. Enable the Vector Extension

In the left sidebar: DatabaseExtensions → search for "vector" → flip pgvector ON.

B. Create the Thoughts Table

Left sidebar: SQL EditorNew query → paste and Run:

SQL
create table thoughts (
  id          bigint generated always as identity primary key,
  content     text not null,
  embedding   vector(1536),
  metadata    jsonb default '{}'::jsonb,
  created_at  timestamptz default now(),
  updated_at  timestamptz default now()
);

C. Create the Search Function

New query → paste and Run:

SQL
create or replace function match_thoughts (
  query_embedding vector(1536),
  match_threshold float default 0.5,
  match_count     int default 10
)
returns table (
  id         bigint,
  content    text,
  metadata   jsonb,
  similarity float,
  created_at timestamptz
)
language sql stable
as $$
  select
    thoughts.id,
    thoughts.content,
    thoughts.metadata,
    1 - (thoughts.embedding <=> query_embedding) as similarity,
    thoughts.created_at
  from thoughts
  where 1 - (thoughts.embedding <=> query_embedding) > match_threshold
  order by thoughts.embedding <=> query_embedding
  limit match_count;
$$;

D. Lock Down Security

One more new query:

SQL
-- Enable Row Level Security
alter table thoughts enable row level security;

-- Service role full access only
create policy "Service role full access"
  on thoughts
  for all
  using (auth.role() = 'service_role');
Quick Verification Table Editor should show the thoughts table with columns: id, content, embedding, metadata, created_at, updated_at. Database → Functions should show match_thoughts.
3
Save Your Connection Details
~1 minute

In the left sidebar: Settings (gear icon) → API. Copy into your credential tracker:

  1. Project URL - listed at the top as "URL"
  2. Service role key - under "Project API keys" → click reveal
Security Treat the service role key like a password. Anyone with it has full access to your data.
4
Get an OpenRouter API Key
~2 minutes

OpenRouter is a universal AI gateway. One key gives you access to every major model. We use it for embeddings (text-embedding-3-small at $0.13/M tokens) and metadata extraction (gpt-4o-mini).

  1. Go to openrouter.ai and sign up
  2. Go to openrouter.ai/keys
  3. Click Create Key, name it open-brain
  4. Copy the key into your credential tracker immediately
  5. Add $5 in credits under Credits (lasts months at this usage)
Why OpenRouter Instead of OpenAI Directly? One account, one key, one billing relationship. And it future-proofs you - if you want to swap to a different embedding model later, change one line of code and redeploy.
5
Create Your Capture Channel / Group
~2 minutes
  1. If you don't have a Slack workspace, create one at slack.com (free tier works)
  2. Click + next to Channels → Create new channel
  3. Name it capture (or brain, inbox, whatever feels natural)
  4. Make it Private (recommended - this is personal)
  5. Get the Channel ID: right-click channel → View channel details → scroll to bottom (starts with C)
  6. Paste the Channel ID into your credential tracker
  1. Open Telegram and create a private group (not a channel)
  2. Name it Brain Capture
  3. To get the Chat ID, add @userinfobot or @RawDataBot to the group
  4. The bot will show you the Chat ID (starts with -). Copy it to your credential tracker
  5. Remove the bot from the group (the bot was only needed to get the ID)
  1. Go to developers.facebook.com and create a Meta Business account if you don't have one
  2. Create an App and choose Business type
  3. Add the WhatsApp product to your app
  4. In the WhatsApp section, click Get Started
  5. You'll need a phone number. Use your personal number or create a test number through Meta
  6. Note your Phone Number ID (displayed in the dashboard) - paste into credential tracker
6
Create the App / Bot
~5 minutes

This is the bridge between your platform and your database.

A. Create the App

  1. Go to api.slack.com/appsCreate New AppFrom scratch
  2. App Name: Open Brain, select your workspace
  3. Click Create App

B. Set Permissions

  1. Left sidebar → OAuth & Permissions
  2. Scroll to ScopesBot Token Scopes
  3. Add: channels:history, groups:history, chat:write
  4. Scroll up → Install to Workspace → Allow
  5. Copy the Bot User OAuth Token (starts with xoxb-) into credential tracker

C. Add App to Channel

In Slack, open your capture channel and type: /invite @Open Brain

Don't Set Up Events Yet Event Subscriptions require the Edge Function URL, which you'll get in Step 7. Come back to connect them in Step 8.

A. Create the Bot

  1. Open Telegram and search for @BotFather
  2. Send the command /newbot
  3. Choose a name (e.g., "Open Brain Bot") and username (must be unique, ends with "bot")
  4. BotFather will give you a bot token (starts with numbers). Copy it to your credential tracker

B. Add Bot to Your Group

  1. In your private group, add the bot: search for it by username and invite
  2. Send /start to activate the bot (it will listen for messages)
Save Your Token Store the bot token securely. You'll need it in Step 7 to configure the Edge Function.

A. Get Your Access Token

  1. In the Meta Developer Console, go to your app's WhatsApp settings
  2. Under API Access, create a System User or use your app token
  3. Generate a permanent access token with whatsapp_business_messaging permissions
  4. Copy the access token to your credential tracker

B. Verify Your Phone Number

  1. In WhatsApp settings, add your phone number and verify via SMS or call
  2. The verified number becomes your capture point
Test Messages You can send test messages from the Meta developer dashboard to make sure the setup works.
7
Deploy the Edge Function
~10 minutes

This is the brains of the operation. One function receives messages from your platform, generates an embedding, extracts metadata, stores everything, and replies with a confirmation.

New to the Terminal? The "terminal" is the text-based command line on your computer. On Mac, open the app called Terminal (search Spotlight). On Windows, open PowerShell. Everything below gets typed there, not in your browser.

A. Install the Supabase CLI

Mac with Homebrew
brew install supabase/tap/supabase
Windows / Linux / Mac without Homebrew
npm install -g supabase

If you don't have npm, install Node.js from nodejs.org first - npm comes with it.

B. Log In and Link

Terminal
supabase login
supabase link --project-ref YOUR_PROJECT_REF

C. Create the Function

Terminal
supabase functions new ingest-thought

Open supabase/functions/ingest-thought/index.ts in any text editor and replace its entire contents with the Edge Function code from the companion Substack guide.

What the Edge Function Does Receives event from your platform → Verifies it's from your capture channel/group → Calls OpenRouter for embedding (text-embedding-3-small) + metadata extraction (gpt-4o-mini) in parallel → Inserts into Supabase → Posts threaded confirmation in your platform.

D. Set Your Secrets

Terminal
supabase secrets set OPENROUTER_API_KEY=your-openrouter-key
supabase secrets set SLACK_BOT_TOKEN=xoxb-your-slack-bot-token
supabase secrets set SLACK_CAPTURE_CHANNEL=C0your-channel-id
Terminal
supabase secrets set OPENROUTER_API_KEY=your-openrouter-key
supabase secrets set TELEGRAM_BOT_TOKEN=your-bot-token-from-botfather
supabase secrets set TELEGRAM_CHAT_ID=-your-chat-id
Terminal
supabase secrets set OPENROUTER_API_KEY=your-openrouter-key
supabase secrets set WHATSAPP_ACCESS_TOKEN=your-access-token
supabase secrets set WHATSAPP_PHONE_ID=your-phone-id
supabase secrets set WHATSAPP_VERIFY_TOKEN=random-verify-token

SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY are automatically available inside Edge Functions - you don't set them.

E. Deploy

Terminal
supabase functions deploy ingest-thought --no-verify-jwt
Copy the URL Now After deployment, your function is live at:
https://YOUR_PROJECT_REF.supabase.co/functions/v1/ingest-thought
Paste it into your credential tracker. You need it for Step 8.
8
Connect Your Platform to the Edge Function
~3 minutes
  1. Go to api.slack.com/apps → select your Open Brain app
  2. Left sidebar → Event Subscriptions → toggle Enable Events ON
  3. Paste your Edge Function URL in the Request URL field
  4. Wait for the green checkmark: Verified
  5. Under Subscribe to bot events, add: message.channels and message.groups
  6. Click Save Changes (reinstall if prompted)
  1. Set the webhook via Telegram Bot API. In your terminal, run:
Terminal (replace values)
curl -X POST https://api.telegram.org/botYOUR_BOT_TOKEN/setWebhook \
  -H "Content-Type: application/json" \
  -d '{"url": "https://YOUR_PROJECT_REF.supabase.co/functions/v1/ingest-thought"}'
  1. You should get a response: {"ok":true,"result":true}
  1. Go to Meta Developer Console → your app's WhatsApp settings
  2. Under Webhooks, click Configure
  3. Paste your Edge Function URL as the Callback URL
  4. Enter your Verify Token (the random token you set in Step 7)
  5. Under Subscribe to webhook events, select: messages
  6. Click Verify and Save
9
Test It
~1 minute

Go to your capture channel / group and type:

Message
Sarah mentioned she's thinking about leaving her job to start a consulting business

Wait 5-10 seconds. You should see a confirmation:

Expected Reply
Captured as person_note -- career, consulting
People: Sarah
Action items: Check in with Sarah about consulting plans

Then open Supabase dashboard → Table Editor → thoughts. You should see one row with your message, an embedding, and metadata.

Part 1 Complete If that works, you have a working capture system. Every thought you type is now embedded, classified, and stored in your own database.

Part 2: Retrieval

Steps 10-13: A hosted MCP server that lets any AI or chat app search your brain and save thoughts by meaning.

10
Create an Access Key
~1 minute

Your MCP server will be a public URL. Generate a simple access key for authentication.

Mac / Linux
openssl rand -hex 32
Windows (PowerShell)
-join ((1..32) | ForEach-Object { '{0:x2}' -f (Get-Random -Maximum 256) })

Copy the 64-character output into your credential tracker. Then set it as a Supabase secret:

Terminal
supabase secrets set MCP_ACCESS_KEY=your-generated-key-here
11
Deploy the MCP Server
~10 minutes

One Edge Function. Four tools: semantic search, browse recent, remember frameworks, and stats.

A. Create the Function

Terminal
supabase functions new open-brain-mcp

B. Add Dependencies

Create supabase/functions/open-brain-mcp/deno.json:

deno.json
{
  "imports": {
    "@hono/mcp":                    "npm:@hono/mcp@0.1.1",
    "@modelcontextprotocol/sdk":      "npm:@modelcontextprotocol/sdk@1.24.3",
    "hono":                           "npm:hono@4.9.2",
    "zod":                            "npm:zod@4.1.13",
    "@supabase/supabase-js":          "npm:@supabase/supabase-js@2.47.10"
  }
}

C. Write the Server

Open supabase/functions/open-brain-mcp/index.ts and replace with the MCP server code from the companion guide.

What the MCP Server Exposes Four tools any connected client can call: search_thoughts (semantic search by meaning), list_thoughts (browse recent, filter by date/type), save_thought (capture a thought mid-conversation - "save this idea", "remember this"), brain_stats (counts, patterns, activity). Works from AI clients and chat bots alike.

D. Deploy

Terminal
supabase functions deploy open-brain-mcp --no-verify-jwt

Your MCP server is live at:

https://YOUR_PROJECT_REF.supabase.co/functions/v1/open-brain-mcp

Paste the full URL into your credential tracker as the MCP Server URL.

12
Connect Your Clients
~3 minutes

You need two things from your credential tracker: the MCP Server URL (Step 11) and the access key (Step 10).

Claude Desktop

Settings → Developer → Edit Config:

JSON Config
{
  "mcpServers": {
    "open-brain": {
      "type": "http",
      "url": "https://YOUR_PROJECT_REF.supabase.co/functions/v1/open-brain-mcp",
      "headers": {
        "x-brain-key": "your-access-key-from-step-10"
      }
    }
  }
}

Restart Claude Desktop. "open-brain" should appear in the MCP tools indicator.

Claude Code

Terminal
claude mcp add open-brain \
  --transport http \
  --url https://YOUR_PROJECT_REF.supabase.co/functions/v1/open-brain-mcp \
  --header "x-brain-key: your-access-key-from-step-10"

Other Clients

Cursor, VS Code Copilot, ChatGPT Desktop, Windsurf - every MCP-compatible client follows the same pattern: point it at the URL with the x-brain-key header. Check their MCP docs for where to add remote HTTP servers with custom headers.

13
Use It
You're done.

Use any connected platform naturally. Chat apps use slash commands, AI clients pick the right MCP tool automatically.

Where What You Say What Happens
Slack / Telegram / WhatsApp"Decision: moving launch to March 15..."Captured, embedded, classified
Claude / ChatGPT / Cursor"Save this thought: our onboarding assumes users understand permissions"save_thought
Slack / Telegram / WhatsApp"search: career changes"Semantic search
Claude / ChatGPT / Cursor"What did I capture about career changes?"search_thoughts
Any AI client"What did I capture this week?"list_thoughts (recent)
Any AI client"How many thoughts do I have?"brain_stats
Slack / Telegram / WhatsApp"list"Browse recent thoughts

Companion Prompts

Four prompts that cover the full lifecycle: migrate, discover, build the habit, review.

After Setup

Making It Compound

The system is infrastructure. These prompts are the habits that make it compound. Use them in order the first week, then keep the weekly review as your Friday ritual.

Run Once

1. Memory Migration

Extracts everything your AI already knows about you (from Claude, ChatGPT, etc.) and saves it to your Open Brain. Run once per platform. Every other AI you connect then starts with that foundation instead of zero.
Use When Stuck

2. Open Brain Spark

Interviews you about your tools, decisions, re-explanation patterns, and key people. Generates a personalized "Your First 20 Captures" list organized by category. Use when you're not sure what to capture first.
Reference

3. Quick Capture Templates

Five sentence starters optimized for clean metadata extraction. Decision capture, person note, insight capture, meeting debrief, AI save. After a week you won't need them - you'll develop your own patterns.
Weekly

4. The Weekly Review

End-of-week synthesis. Clusters by topic, scans for unresolved action items, detects patterns across days, finds connections you missed, identifies gaps. Five minutes on Friday afternoon. Gets more valuable every week as your brain grows.
Quick Reference

Five Capture Templates

Type these into your chat apps or say them naturally in AI conversations. Each is structured to trigger the right classification in your processing pipeline.

Decision Capture

Decision: [what]. Context: [why]. Owner: [who].

Example: Decision: Moving the launch to March 15. Context: QA found three blockers in the payment flow. Owner: Rachel.

👤

Person Note

[Name] - [what you learned]

Example: Marcus - mentioned he's overwhelmed since the reorg. Wants to move to the platform team.

💡

Insight Capture

Insight: [realization]. Triggered by: [what].

Example: Insight: Our onboarding assumes users understand permissions. Triggered by: watching a new hire struggle for 20 minutes.

📅

Meeting Debrief

Meeting with [who] about [topic]. Key points: [...]. Action items: [...].

Example: Meeting with design team about dashboard redesign. Key points: cutting three panels, keeping revenue chart. Action items: I send API spec by Thursday.

🤖

The AI Save

In chat apps: Saving from [AI tool]: [key takeaway].

In AI conversations: "Save this thought: [key takeaway]"

Example (Slack/Telegram/WhatsApp): Saving from Claude: Framework for evaluating vendor proposals - score on integration effort (40%), maintenance burden (30%), switching cost (30%).

Example (Claude/ChatGPT): "Remember this: the vendor evaluation framework we just built - integration effort 40%, maintenance burden 30%, switching cost 30%."

Troubleshooting

If Something Goes Wrong

The Supabase dashboard has a built-in AI assistant (chat icon, bottom-right). It has access to all Supabase docs and can help with every Supabase-specific step.

Problem Fix
Slack says "Request URL not verified" Redeploy: supabase functions deploy ingest-thought --no-verify-jwt
Slack messages aren't triggering the function Check Event Subscriptions for message.channels / message.groups. Verify app is invited to channel.
No confirmation reply in Slack Bot token wrong or chat:write scope missing. Reinstall app if you added scope after install.
Telegram webhook not receiving messages Verify webhook URL with getWebhookInfo. Make sure the bot was started with /start and you're messaging the bot directly (or added it to a group with privacy mode off).
WhatsApp messages not arriving Check Meta webhook verification token matches your Edge Function. Confirm the phone number is registered and the webhook subscription includes messages.
Function runs but nothing in database Check Edge Function logs (dashboard → Edge Functions → Logs). Likely wrong OpenRouter key or no credits.
AI client says "server disconnected" Check URL is exact (including https://, no trailing slash). Open URL in browser - you should get an error response, not 404.
Getting 401 errors Access key mismatch. Header must be x-brain-key (lowercase, with dash).
Search returns no results Make sure you sent test messages first. Try threshold 0.3 for a wider net.
First query is slow Cold start - Edge Function is waking up. Subsequent calls are faster.
Bottom Line

Key Takeaways

Memory is a lock-in strategy Every AI platform walls off what you've told it. Open Brain breaks that by giving every tool the same shared memory.
Context beats model selection An AI with your full history will outperform a better model that starts from zero every session.
Write anywhere, read anywhere Slack, Telegram, WhatsApp, Claude, ChatGPT, Cursor. Every connected client can save and search your thoughts.
Built for the agent web Memory infrastructure designed for machines first, with a human UI on top. Not the other way around.
Boring stack, on purpose Postgres + pgvector + MCP. Won't deprecate, won't chase growth metrics, won't get acquired and shut down.
Compounding returns Every thought captured makes the next search smarter. Six months of context permanently outpaces starting from zero.
Clarity for machines = clarity for you Good context engineering for agents accidentally builds good context engineering for yourself.
$0.10-0.30/month Less than your morning coffee costs more than this system costs all month.