Setup

# From backend/ directory
python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
 
# Copy and configure environment
cp .env.example .env
# Edit .env: set SUPABASE_URL, SUPABASE_KEY, ANTHROPIC_API_KEY, MEM0_API_KEY
# Optional: VOYAGE_API_KEY, VAULT_PATH, GRAPHITI_ENABLED
 
# Apply database migrations (run in Supabase SQL editor, in order 001–016)
# See: backend/supabase/migrations/

Running the MCP Server

# Local (stdio — default, used by Claude Code)
python -m second_brain.mcp_server
 
# Docker (HTTP transport)
docker compose up -d
 
# With custom transport
MCP_TRANSPORT=http MCP_PORT=8000 python -m second_brain.mcp_server

CLI

brain --help
brain recall "content writing patterns"
brain ask "What's our positioning?"
brain learn --category content "Session notes..."
brain migrate              # Run data migration
brain vault-ingest --dry-run
brain vault-ingest --live

Testing

# All tests (from repo root or backend/)
pytest backend/tests/
 
# Verbose
pytest backend/tests/ -v -s
 
# Single test file
pytest backend/tests/test_ingest.py
 
# With coverage (if installed)
pytest backend/tests/ --cov=second_brain

Optional Extras

# Graphiti knowledge graph support
pip install -e ".[graphiti]"
 
# Ollama local model support
pip install -e ".[ollama]"
 
# Subscription (Claude Max/Pro) auth
pip install -e ".[subscription]"