| title | Getting Started |
|---|---|
| type | tutorial |
Install Second Brain, configure its dependencies, and verify your first memory round-trip in about 15 minutes.
Note
Before you begin, ensure you have:
- macOS with Homebrew installed
- Python 3.13+ (3.14 recommended)
- An MCP client — Kiro CLI or Claude Code
Second Brain stores memories and vector embeddings in PostgreSQL 17 with the pgvector extension, running natively via Homebrew.
brew install postgresql@17 pgvector
brew services start postgresql@17Expected output:
==> Successfully started `postgresql@17`
Tip
postgresql@17 is keg-only. Add its binaries to your PATH:
echo 'export PATH="/opt/homebrew/opt/postgresql@17/bin:$PATH"' >> ~/.zshrc
source ~/.zshrcpython3.14 -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txtExpected output (last lines):
Successfully installed psycopg2-binary-2.9.11 boto3-1.42.69 mcp-1.26.0 ...
Create the memory_bank role and database, then enable the pgvector extension:
createuser -s memory_bank 2>/dev/null || true
createdb -O memory_bank memory_bank 2>/dev/null || true
psql -h localhost -U memory_bank -d memory_bank -c "CREATE EXTENSION IF NOT EXISTS vector;"Note
The || true guards make these safe to re-run — they no-op if the role or database already exists.
Apply the schema. The migration runner adds tables and indexes to the memory_bank database and records applied versions, so it is safe to re-run:
./migrations/migrate.shExpected output:
apply: 001_initial_schema.sql
apply: 002_v2_columns.sql
...
apply: 011_backend_provenance.sql
apply: 012_agent_task_capture.sql
apply: 013_context_governance.sql
apply: 014_local_embedding_space.sql
apply: 015_enforce_active_embedding_space.sql
done
Migrations that were already applied are skipped: skip: <version> (already applied).
Second Brain uses local Ollama BGE-M3 for 1,024-dimension embeddings. Install the runtime, start it at login, and pull the model:
brew install ollama
brew services start ollama
ollama pull bge-m3Verify the active space:
.venv/bin/python -c \
'from src.embeddings import generate_embedding, active_embedding_space; v=generate_embedding("health check"); print(active_embedding_space(), len(v))'Expected output:
ollama:bge-m3:1024 1024
Note
AWS credentials are needed only if you explicitly select a Bedrock-backed reasoning profile. The active embedding path and backups do not require AWS.
Start the MCP server:
python -m src.mcp_serverThe server exposes 11 tools over stdio, adding memory_context and memory_context_outcome to the existing memory, relationship, learning, and briefing tools.
To connect your MCP client, add this stdio server configuration (adjust the path to your clone):
{
"mcpServers": {
"second-brain": {
"command": "/Users/<you>/second-brain/.venv/bin/python",
"args": ["-m", "src.mcp_server"],
"cwd": "/Users/<you>/second-brain"
}
}
}Client-specific config file locations vary by version. See Connect an AI agent for Kiro CLI and Claude Code notes.
pg_isready -h 127.0.0.1 -p 5432 -U memory_bankExpected output:
127.0.0.1:5432 - accepting connections
In your connected agent, run:
-
Create a test memory:
"Use
memory_createto store a memory with content 'Second Brain is operational' and type 'research'." -
Search for it:
"Use
memory_searchto find memories about 'operational'."
You see the memory you just created in the results.
.venv/bin/python -m pytest tests/test_db.py tests/test_search.py tests/test_mcp_server.py -qExpected output:
... passed
Tests run against an isolated memory_bank_test database and mock Ollama calls — the local model
does not need to run during tests.
- Using Second Brain — day-to-day workflows: capturing, searching, and the dream cycle
- Operations — backups, scheduled jobs, monitoring, and SSO renewal