# Repository Briefing: rahilp/second-brain-cloudflare
> Source: https://repoforai.com/repo/rahilp/second-brain-cloudflare (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/rahilp/second-brain-cloudflare
- **Official Docs / Website**: https://www.thesecondbrain.dev
- **Category**: RAG, Data & Memory (知识库 / 爬虫 / 记忆层)
- **Primary Language**: TypeScript
- **License**: MIT
- **Engineering Health**: A+ (94/100 · Maintenance 35/35 · Adoption 19/25 · Releases 20/20 · License 20/20)
- **Latest Release**: installer-v4.0.7 (2026-11-30) — https://github.com/rahilp/second-brain-cloudflare/releases
- **Review Snapshot**: 2026-12-03
- **Deployment / Stack Signals**: MCP, Self-Hosted, API
- **Momentum**: 886 ★ total (+1 24h / +8 7d) · 133 forks
- **Topics**: `ai-memory`, `claude`, `claude-ai`, `claude-code`, `cloudflare`, `cloudflare-workers`, `d1`, `ios-shortcuts`, `mcp`, `model-context-protocol`, `obsidian-plugin`, `personal-knowledge-management`
- **When to Use**: Best for: Individuals and single teams that want several AI clients to recall the same decisions, preferences, and project history from a Cloudflare deployment they control. Skip if: You need offline or on-premises operation, multiple independently administered teams in one instance, or a retrieval stack with replaceable storage and ranking components.

## Overview
```text
### Architecture & Core Mechanics
Second Brain is a TypeScript application built around a single Cloudflare Worker. REST and MCP expose the same persistent memory system to AI clients and capture integrations. D1 backs memory storage and ranked full-text retrieval; Vectorize and Workers AI provide semantic search, with KV also part of the Worker stack. Captured records are classified, checked for duplicates and contradictions, linked to related records, and indexed for recall. Recall can follow those relationships and return source-backed context.

The package uses `@cloudflare/workers-oauth-provider` and the `@modelcontextprotocol/client`, `@modelcontextprotocol/server`, and `@modelcontextprotocol/sdk` packages. The repository separates `src/`, `db/`, `integrations/`, and `installer/`, with `wrangler.jsonc` for Worker configuration. Workspace is the access boundary; projects group records by subject and can overlap without changing who can read them. Tags and source provide separate facets for classification and provenance.

### Key Capabilities & Differentiators
Retrieval supports both semantic recall and relevance-ranked full-text matching. The latter matters for ticket IDs, versions, names, and exact phrases, and remains available alongside capture when Vectorize is unavailable. New deployments use the full-text index immediately; existing deployments build it over nightly runs. The shipped embedding models favor English, with a multilingual option in desktop settings. Memory operations include as-of recall, timestamped updates, history, undo, explicit relationships, and status changes. `brief` surfaces outstanding items, while `digest` reads the latest existing summary.

Team Edition gives each member a private workspace and exposes a shared workspace as `company` in the API, CLI, and MCP tools. Sharing moves one canonical record; only its author or an admin can edit or remove the shared record. Admins do not gain access to personal workspaces. For agent gateways, `get_prompt_capsule` exposes a deterministic, read-only projection of canonical core or project entries. It emits slots in fixed order, skips malformed entries, and reports ambiguous slots instead of selecting one silently.

### Trade-offs & Limitations
Compared with assembling MCP, storage, embeddings, and a retrieval pipeline around a general-purpose vector database, Second Brain ships a usable memory product with editing, history, export, and sharing. The tradeoff is that its operational path and retrieval design are tied to Cloudflare primitives. Self-hosting here means deploying into an account you control, not running offline or on arbitrary infrastructure. A local-first store is a better starting point if offline operation is mandatory; a bespoke stack is a better fit if storage, ranking, or tenancy must be independently controlled.

Each brain currently supports one shared team. The optional `team` parameter and `list_teams` tool do not imply that the dashboard can create or switch between multiple teams. Without the Vectorize workspace metadata index, recall searches the broader candidate pool before applying access limits. Unauthorized records are not returned, but they can crowd eligible records out of the nearest matches. Treat free-tier fit as workload-dependent: traffic and migration backfills consume managed-service allowance, and a full re-embed uses Workers AI allowance for every memory.

### Hardware & Deployment Guide
The desktop installer, Deploy to Cloudflare flow, and manual CLI path provision the same application in your Cloudflare account. The manual path uses Node/npm and Wrangler tooling: run `npm install`, `npm run vectors:create`, then `npm run deploy`. The documented Vectorize settings are 384 dimensions and cosine similarity. Connect MCP clients at `/mcp`, using OAuth where supported or a strong randomly generated `AUTH_TOKEN` in an `Authorization: Bearer` header for static clients. Query-string token authentication was removed in v3.

`vectors:create` also creates the `workspace_id` metadata index. When adding it to an existing deployment, check `/health` for `workspaceFilter.supported` and plan the documented reset and re-embedding steps together: adding the index without re-embedding can remove older records from semantic recall. The `installer-v4.0.7` release provides macOS `.dmg` and Windows `.exe` downloads, with separate update artifacts. Existing deployments should be upgraded to 4.0.4 or later before December 5, 2026, to avoid the older behavior where client connections stop working 90 days after setup.
```

## Key Capabilities
```text
- Runtime: One TypeScript Cloudflare Worker serves REST and MCP, backed by D1, Vectorize, Workers AI, and KV.
- Retrieval resilience: Captures and indexed keyword recall remain available when Vectorize is down; existing deployments build the full-text index through nightly runs.
- Temporal memory: `recall` supports as-of queries, `history` exposes previous text, and `undo` can restore trashed memories.
- Workspace boundaries: Private-by-default capture and one shared team per brain; sharing moves the canonical record rather than duplicating it.
- Gateway context: Prompt Capsules emit canonical entries in a fixed slot order and omit ambiguous slots while reporting them.
- Vector provisioning: Manual setup uses a 384-dimensional cosine index; `workspace_id` metadata filtering is important for team recall.
```

## Quick Start / Clone
```bash
npm install
npm run vectors:create
npm run deploy
```
