Skip to main content

SecondBrain

Your personal AI memory. On your device. On your terms.

License: MIT Version CI Python 3.12+ Powered by actants MCP

An open-source, local-first personal memory daemon. Captures, embeddings, knowledge graph, and audit log never leave your device.

Quick start · How it works · Why · ⭐ Star us on GitHub


Why this exists

Modern knowledge work generates more context than any human can hold — meetings, threads, docs, browser tabs, code windows. The tools that promise to help typically lock your memory inside a vendor or stream your screen to someone else's GPU.

SecondBrain is a personal memory daemon that runs entirely on your Mac. It captures your screen, indexes it across four storage layers, and exposes that memory to any MCP-aware assistant — Claude Desktop, Cursor, Codex — through seven first-class tools. The default LLM is local Ollama; if you opt into a hosted provider, only the prompt text leaves your machine, and only because you said so.

Quick start

macOS 14+ (Apple Silicon). Windows/Linux paths raise NotImplementedError today.

git clone https://github.com/openintelligence-labs/secondbrain && cd secondbrain
python3 -m venv .venv && .venv/bin/pip install -e '.[dev,ml]'
.venv/bin/secondbrain run --fps 1                 # start the capture daemon

The [ml] extra installs the local text embedder (sentence-transformers + PyTorch). Skip it if you plan to use Ollama-served embeddings or the --stub-embedder flag — local embeddings pull ~2 GB of model weights on first use. For visual recall via ColQwen2.5 add [visual]; for BYO hosted LLMs add [byo-llm].

For the full desktop app (Tauri shell + Swift sidecars), build the two extra components after the Python install:

( cd swift/SecondBrainCapture && swift build -c release )
( cd app && npm install && npm run build && cd src-tauri && cargo build --release )
.venv/bin/secondbrain ui                          # launches the desktop window

Want to drive it without granting macOS Screen Recording first? Run ./demo.sh for a seeded fixture workday.

Features

What it does
Continuous capture ScreenCaptureKit sidecar at 1 fps, AX-tree-first dedup cascade (deny-list → AX-hash → dirty-rect → dHash → pHash → SSIM), <1ms median per gate.
Hybrid retrieval Tantivy BM25 ⊕ LanceDB cosine → RRF k=60 → mxbai-rerank. p95 of 35 ms over 500 captures.
Visual recall ColQwen2.5 late-interaction embeddings let you search for what a screen looked like, not just what it said.
Bi-temporal knowledge graph Kùzu KG tracks valid-time and transaction-time for every entity. "What did I know about X last Tuesday?" is a first-class query.
MCP-native A FastMCP server exposes 7 tools — memory.search, memory.who, memory.digest, memory.forget, and more — over stdio or Streamable HTTP.
BYO-LLM Default is local Ollama. Switch to OpenAI, Anthropic, Gemini, Groq, or Mistral with three environment variables. Every LLM hot path has a deterministic heuristic fallback.
GDPR by construction SQLCipher AES-256 at rest, age-encrypted files, biometric-gated session keys, signed audit log, and memory.forget as a first-class cascading delete.

How it works

  screen ──▶ cascade ──▶ extract ──▶ ┬─▶ SQLite  (OLTP, SQLCipher)
  (SCK)     (dedup 6   (entities,    ├─▶ LanceDB (dense vectors)
            stages)    importance)   ├─▶ tantivy (BM25)
                                     └─▶ Kùzu    (bi-temporal KG)
                                           │
                               ┌───────────┴────────────┐
                               ▼                        ▼
                        hybrid retrieval         Tauri desktop
                        (RRF k=60 + rerank)      + MCP server (7 tools)

Everything above the retrieval line stays on disk, encrypted. The MCP server and desktop app sit on top of the same retrieval layer, so a query from Claude Desktop and a click in the timeline window run the identical pipeline.

CLI surface

Command Purpose
secondbrain run Start the capture daemon. --fps, --ocr-fallback, --llm, --visual flags.
secondbrain run-synthetic Same pipeline, synthetic frames — no display or TCC required.
secondbrain index Bulk re-index OLTP → KG / Lance / tantivy.
secondbrain search "<query>" Hybrid search with optional --rerank.
secondbrain who "<name>" Person card across every source that mentions them.
secondbrain digest --period day Daily/weekly/monthly reflection. Add --llm for LLM synthesis.
secondbrain forget --capture-id <id> --reason <r> GDPR Art. 17 cascading delete.
secondbrain ui Launch the Tauri desktop app + HTTP gateway.
secondbrain mcp FastMCP stdio server for Claude Desktop / Cursor / Codex.
secondbrain mcp-doctor Diagnostic + paste-ready MCP client config.
secondbrain preflight Verify TCC permissions, sidecars, and dependencies.
secondbrain install-agent / uninstall-agent / agent-status macOS launchd integration.
secondbrain backup <path> / restore <path> Encrypted snapshot + restore.
secondbrain status Capture and storage metrics.

Configuration

SecondBrain is configured by environment variables — no config file required for the local-only default. To point it at a hosted LLM, install the matching extra and export three vars:

# 1. Install the SDK for your chosen provider.
pip install -e '.[openai]'         # or [anthropic] / [gemini] / [groq] / [mistral]
                                    # or [byo-llm] for all five at once

# 2. Tell SecondBrain to use it.
export SECONDBRAIN_LLM_PROVIDER=openai         # ollama (default) | openai | anthropic
                                                # | gemini | groq | mistral
export SECONDBRAIN_LLM_MODEL=gpt-4o-mini       # any model the provider serves
export SECONDBRAIN_LLM_API_KEY=sk-...          # not needed for local Ollama
# export SECONDBRAIN_LLM_BASE_URL=...          # only for self-hosted endpoints

# 3. Verify.
secondbrain mcp-doctor                          # prints loaded providers + warnings

Captures, embeddings, KG nodes, and the audit log never leave your device. With a hosted LLM, only the prompted text egresses — and only on the calls you opted into.

Contributing

Contributions are welcome. Before opening a PR:

  1. Browse src/secondbrain/ — modules are organised by pipeline stage (capture/, memory/, store/, search/, api/).
  2. Run the deterministic suite: pytest tests/ --ignore=tests/test_macos_sck.py --ignore=tests/test_ocr.py (no network, no TCC required).
  3. Project conventions: Pydantic models across module boundaries, heuristic fallback for every LLM hot path, capture IDs as hex UUIDs.

Questions, ideas, and bug reports go in GitHub Discussions and Issues.

Star history

Star history

License

MIT © Open Intelligence Labs.

Metadata

Release files for secondbrain-ai 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for secondbrain-ai 0.3.2
File Size Uploaded Provenance Actions
secondbrain_ai-0.3.2.tar.gz 154.2 kB With provenance Details for secondbrain_ai-0.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for secondbrain-ai 0.3.2
File Interpreter ABI Platform Actions
secondbrain_ai-0.3.2-py3-none-any.whl Python 3 none any Details for secondbrain_ai-0.3.2-py3-none-any.whl

Total release size: 291.6 kB

Release files / secondbrain_ai-0.3.2.tar.gz

Download URL secondbrain_ai-0.3.2.tar.gz
Size 154.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5771aac59b48701ef27c92b48f8dd11ecfbefa4f021733112fbe2d6ff357b0a2
BLAKE2b-256 checksum
How to use checksums
e708f838f4ba24719e33cdef672fe6d2463fa72e36d31944b481361a82de386f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.

Transparency log

Release files / secondbrain_ai-0.3.2-py3-none-any.whl

Download URL secondbrain_ai-0.3.2-py3-none-any.whl
Size 137.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9ef3fa6d629218eef91255398c024bc3a9cc015ffffa8b1e59a1413641c64de4
BLAKE2b-256 checksum
How to use checksums
a45214a76c6d3d87674256a38bdb315fce641e4d08f9f697546911dbfdac3ebd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.

Transparency log

Security for secondbrain-ai 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for secondbrain_ai-0.3.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page