Add it to Claude Code
claude mcp add -e "DIGITAL_BRAIN_API_KEYS=${DIGITAL_BRAIN_API_KEYS}" -e "SUPABASE_URL=${SUPABASE_URL}" -e "SUPABASE_SERVICE_ROLE_KEY=${SUPABASE_SERVICE_ROLE_KEY}" -e "GOOGLE_API_KEY=${GOOGLE_API_KEY}" digital-brain -- npx -y @dswillden/digital-brain-mcpDIGITAL_BRAIN_API_KEYSSUPABASE_URLSUPABASE_SERVICE_ROLE_KEYGOOGLE_API_KEYMake your agent remember this setup
digital-brain's config, env vars, and the gotchas you hit — recalled in every future Claude Code, Cursor, and Codex session.
npx conare@latestFree · one command · indexes the sessions already on disk. Set up in the browser instead →
What it does
- Persistent long-term memory for AI clients
- Cross-modal semantic search for text, images, PDFs, audio, and video
- Unified vector space using Google Gemini Embedding 2
- Secure storage with Supabase pgvector and Row Level Security
- Interleaved embedding for richer search results
Tools 9
store_memoryStores text-based memory in the vector database.store_fileStores a file using base64 encoding.store_file_from_urlFetches and stores a file from a provided URL.search_memoryPerforms cross-modal semantic search across stored memories and files.get_file_urlGenerates a signed download URL for a stored file.list_memoriesLists stored memories.update_memoryUpdates an existing memory entry.delete_memoryDeletes a memory entry.get_statsRetrieves statistics about the stored memory.Environment Variables
DIGITAL_BRAIN_API_KEYSrequiredComma-separated API keys for authentication.SUPABASE_URLrequiredThe URL of your Supabase project.SUPABASE_SERVICE_ROLE_KEYrequiredThe service role key for Supabase database access.GOOGLE_API_KEYrequiredAPI key for Google Gemini Embedding 2.Try it
Original README from dswillden/digital-brain-mcp
🧠 Digital Brain MCP
A Second Brain powered by Model Context Protocol (MCP), Google Gemini Embedding 2, and Supabase pgvector — deployed on Vercel.
Connect any MCP-compatible AI client (Claude, Cursor, OpenCode, Copilot, etc.) and give it persistent long-term memory. Store text, images, PDFs, audio, and video — all embedded in a unified vector space for cross-modal semantic search.
Architecture
AI Client (Claude / Cursor / OpenCode / Copilot)
│
▼ MCP Protocol (Streamable HTTP + SSE)
│ Authorization: Bearer <api-key>
┌──────────────────────────────────────────┐
│ Vercel (Next.js) │
│ /api/mcp/[transport] │
│ │
│ ┌── Auth Middleware ──┐ │
│ │ Bearer token check │ │
│ └─────────────────────┘ │
│ │
│ Tools: │
│ • store_memory (text) │
│ • store_file (base64 upload) │
│ • store_file_from_url (URL fetch) │
│ • search_memory (cross-modal) │
│ • get_file_url (signed download) │
│ • list_memories │
│ • update_memory │
│ • delete_memory │
│ • get_stats │
│ │
│ REST Endpoint: │
│ • POST /api/upload (direct file) │
└──────────┬─────────────┬─────────────────┘
│ │
┌─────┴─────┐ ┌───┴──────────────┐
▼ ▼ ▼ ▼
┌─────────┐ ┌──────────────┐ ┌───────────┐
│ Gemini │ │ Supabase │ │ Supabase │
│ Embed 2 │ │ PostgreSQL │ │ Storage │
│ API │ │ + pgvector │ │ (files) │
│ │ │ vector(768) │ │ │
└─────────┘ └──────────────┘ └───────────┘
Multimodal Embedding
Gemini Embedding 2 maps all modalities into the same 768-dimension vector space. This means:
- A text query like "architecture diagram" can find a stored PNG image
- Searching for "meeting notes" can return an audio recording of a meeting
- A PDF of a research paper and a text summary live side by side in the same search space
Supported File Types
| Modality | MIME Types | Limits |
|---|---|---|
| Image | image/png, image/jpeg, image/webp, image/gif |
Up to 6 per request |
application/pdf |
Up to 6 pages | |
| Audio | audio/mpeg, audio/wav, audio/ogg, audio/mp3, audio/aac, audio/flac |
— |
| Video | video/mp4, video/quicktime, video/webm |
Up to 120 seconds |
Interleaved Embedding
When you provide a description alongside a file, the system creates an interleaved embedding — a single vector that captures both the visual/audio content AND your text description. This produces significantly richer search results compared to embedding the file alone.
How It Works
- You say (in Claude/Cursor/etc): "Remember that the EBR system uses Azure Functions for the API layer"
- MCP client calls your Digital Brain's
store_memorytool - Gemini Embedding 2 converts the text into a 768-dimension vector
- Supabase stores the text + vector in PostgreSQL with pgvector
- Later, you ask: "What tech does the EBR system use?"
search_memoryembeds your query, runs cosine similarity search, returns the matching memory
For files, the flow is the same — except the file bytes are sent to Gemini for multimodal embedding, and the raw file is stored in Supabase Storage with a signed download URL generated on retrieval.
Security Model
The server uses Bearer token authentication on every request:
- Fail-closed: If no API keys are configured, ALL requests are rejected
- Multi-key support: Set multiple comma-separated keys in
DIGITAL_BRAIN_API_KEYSso each client gets its own key (and you can rotate independently) - Row Level Security (RLS): Enabled on the Supabase
memoriestable — onlyservice_rolecan access data. The anon key has zero access. - Service Role Key: Only stored server-side in Vercel env vars, never exposed to clients
- Private Storage: The
brain-filesbucket is private — files are only accessible via time-limited signed URLs (1 hour expiry)
Generating API Keys
# Generate a strong 256-bit key
openssl rand -hex 32
Tech Stack
| Component | Technology | Purpose |
|---|---|---|
| Embeddings | Gemini Embedding 2 (gemini-embedding-2-preview) |
Multimodal embeddings — text, images, audio, video, PDF all in one vector space |
| Vector DB | Supabase + pgvector | PostgreSQL with vector similarity se |