Second Brain Engine
Provides read-only incremental ingestion from local Git repositories, scanning project repos in place and scrubbing secrets before writing memory notes into the vault.
Provides memory retrieval and guarded read/write access over a private Obsidian Markdown vault, including note and section reads, context packs, search, and hash-protected note updates.
Provides read-only ingestion from a local Zotero SQLite database, scanning references in place and scrubbing secrets before adding notes to the vault.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Second Brain Engine
Bi-temporal Obsidian Markdown MCP memory engine - guarded SQLite FTS5 retrieval, bilingual YAML indexing, read-only connectors, deterministic vault linting, and 5-class golden evaluation.
Principles · Architecture · Workflow · Benchmarks · Quickstart · Documentation · References
This repository implements a local, zero-billing memory and decision engine for AI coding agents working over a decoupled Obsidian Markdown vault.
It is an Apache-2.0 fork and extension of COvert96/obsidian-memory-mcp designed to run cleanly on constrained single-workstation Linux hardware (15 GiB RAM ceiling, 0 external API billing, 0 required embedding model downloads).
1. System Purpose and Scope
1.1 Purpose
The engine gives local CLI agents (such as Antigravity CLI agy, with optional opt-in support for other MCP clients) deterministic, sub-millisecond access to curated project decisions, architecture specs, and engineering atoms across multiple domains (swe, agent, ds).
It keeps all durable knowledge as plain, human-editable Markdown files inside a separate private vault while treating SQLite FTS5 and structural graphs strictly as disposable derived caches.
1.2 Engineering Problems Addressed
Session Amnesia and Repeated Context Loading: Agents start new sessions blind or burn thousands of tokens reading raw folders. The engine serves token-budgeted context packs and ranked FTS5 snippets (
~73xpayload reduction vs full vault reads).Stale Decision Pollution: Standard keyword search surfaces outdated architecture notes alongside active ones. Migration
003_bitemporal_metadatafiltersstatus: supersededandarchivednotes out of default retrieval while preserving full history for audit (include_superseded=True).Cross-Language Lexical Blind Spots Without Heavy Vectors: Pure body-only FTS5 misses bilingual Indonesian/English queries, while heavy local vector stacks exhaust laptop RAM/VRAM. The parser indexes structured YAML fields (
summary_id,summary_en,search_queries,aliases) at BM25 weight6.0.Prompt Injection and Secret Leakage From Automated Ingestion: Copying raw logs or untrusted inbox files directly into agent prompts risks secret exposure and instruction hijacking.
00-inbox/**is read-denied by guardrails,sync_connectors.pyscrubs credentials before writing, andagentsviewingestion filterssecret_leak_count = 0.Unmeasured Retrieval Quality: Most personal knowledge setups rely on anecdote.
scripts/run_golden_eval.pyenforces deterministic launch-blocking thresholds across five query classes (exact-id,paraphrase,multi-hop,superseded,abstention).
1.3 Scope and System Boundaries
Inside System Boundary: Public MCP server package (
src/obsidian_memory_mcp/), Alembic schema migrations (001through003), read-only incremental connectors (scripts/sync_connectors.py), deterministic vault linter (scripts/vault_lint.py), 5-class golden eval harness (scripts/run_golden_eval.py), local MCP registrar (scripts/connect_local_mcp.py), and release quality gates.Outside System Boundary: Private Obsidian vault contents (kept in a separate local/private directory), workstation dotfiles / agent development environment, calendars and schedulers, cloud vector databases, and paid inference APIs.
Related MCP server: exomem
2. Core Engineering Principles
Markdown Single Source of Truth: Plain Markdown + YAML inside a decoupled private vault owns all durable state;
.mcp/SQLite indexes andgraphify-out/graphs are disposable caches rebuildable in< 2 s.Bi-Temporal Supersession Over Deletion: Outdated decisions are marked
status: supersededwithsuperseded_by: "[[replacement]]"instead of deleted, keeping default retrieval clean and audit trails intact.Zero-Billing, Lightweight Local Footprint: Retrieval uses deterministic SQLite FTS5 (
< 1 msmedian,~82 MBpeak RSS) with$0API spend and0mandatory local model downloads.Read-Only In-Place Ingestion: External sources (
~/Projects/,~/.agentsview/sessions.db,~/Zotero/zotero.sqlite) are never moved or mutated; connectors open SQLite with?mode=ro, scrub secrets, and report status loudly in40-ops/health.md.Fail-Closed Guardrails and Optimistic Locking: Deny rules override allow rules (
00-inbox/**read-denied,99-system/**write-denied); updates requireexpected_hashand write every mutation to an append-onlywrite_audittable.Evidence Before Claims: Every release gate, lint check, secret scan, and 5-class benchmark runs deterministically and reports real failures honestly without hiding trade-offs.
3. System Architecture and Trust Boundaries
Major Architectural Units
Architectural Unit | Primary Responsibility | Canonical Reference |
Bi-Temporal Parser & FTS5 Indexer | Extracts YAML | |
Temporal & Recency Retrieval Service | Filters | |
Guarded FastMCP Server (9 Tools) | Serves | |
Read-Only Incremental Connectors ( | Scans Git repos, clean | |
Deterministic Vault Linter ( | Enforces YAML schema, | |
5-Class Golden Eval Harness ( | Measures Hit@K across | |
Local MCP Registrar ( | Wires local |
4. End-to-End Operational Lifecycle (S0-S5)
Stage | Activity | Primary Tool / Command | Exit Gate |
S0 - Bootstrap | Initialize private vault layout, validate |
| Config valid; MCP reachable by client |
S1 - Qualify | Formulate measurable targets per project (Wang Step 1 Memo + Health Scorecard Gates | Vault template | Explicit baseline, target, kill criterion |
S2 - Ingest | Pull incremental updates from Git repos, |
| Secrets scrubbed; 2x run = |
S3 - Index & Graph | Rebuild incremental FTS5 index and optional zero-token structural graph |
|
|
S4 - Retrieve & Mutate | Agent loads bounded context pack, searches active notes, writes atoms with | MCP tools ( |
|
S5 - Verify & Commit | Lint vault integrity, run 5-class golden eval, scan secrets, commit vault locally |
|
|
Detailed stage-by-stage procedures and troubleshooting live in docs/SECOND-BRAIN-WORKFLOW.md.
5. Empirical Validation Summary
5.1 Engine Quality Gates (VERIFIED)
Gate | Command | Measured Result | Status |
Static Lint & Strict Types |
|
| PASS |
Architectural Boundaries |
|
| PASS |
Unit & Integration Suite |
|
| PASS |
Secret & Path Hygiene |
|
| PASS |
5.2 Live 5-Class Golden Eval Reference Benchmark (24 Queries, VERIFIED)
Measured on a live private Second Brain vault (31 curated Markdown notes, 84 sections, 67 blocks; full index build 415 ms, optional graphify build 145 nodes / 118 edges at 0 LLM tokens):
Query Class | Measured Hit@5 / Pass | Launch-Blocking Threshold | Status |
|
|
| PASS |
|
|
| PASS |
|
|
| PASS |
|
|
| PASS |
|
|
| PASS |
Latency: median
0.637 ms, p950.866 ms, max1.201 ms.Memory: peak RSS
81.86 MB(< 100 MBtarget).Token Payload Reduction:
185.7avg search payload tokens vs13,615curated vault tokens (73.32xreduction).
Honest Trade-Off Record: The single
paraphrasemiss (1 / 24) occurred when querying an Indonesian word (ditolak) against a note containing only the English term (Rejected). Because SQLite FTS5 uses strict lexicalANDwithout an embedding model, cross-language recall depends on populating concise bilingualsummary_id,summary_en, andsearch_queriesfrontmatter on key notes.
Buy-vs-Build Rejection Record: Before forking
COvert96/obsidian-memory-mcp, heavier alternatives were audited and rejected for a15 GiBRAM /4 GiBVRAM workstation: Hindsight (2.2-3.3 GBidle RAM andpg0OOM issue#1572), Basic Memory (reported frontmatter rewrite hazard#2125), QMD full (2.1 GBmandatory model download), and SpencerBrain (32 GBRAM /16 GBVRAM target).
6. Quickstart and Daily Operations
6.1 Requirements
Python
>= 3.12anduvLinux or macOS (Windows paths also supported by
mcp-memory)A separate local Obsidian Markdown vault directory
Optional:
gitleaks(secret scanning) andgraphify(zero-token structural graph)
6.2 Initial Setup
# 1. Clone and install dependencies
git clone https://github.com/npcmaul/second-brain-engine.git
cd second-brain-engine
uv sync --group dev
# 2. Configure your separate private vault (copy config-example.yaml -> <vault>/memory-mcp.yaml)
uv run mcp-memory config validate ~/Projects/my-second-brain
uv run mcp-memory index --full --yes ~/Projects/my-second-brain
# 3. Register the vault locally (writes gitignored memory-mcp-server.yaml and wires agy MCP)
uv run python scripts/connect_local_mcp.py \
--vault ~/Projects/my-second-brain \
--project-name second-brain6.3 Daily Wrap-Up Loop
cd ~/Projects/second-brain-engine
uv run python scripts/sync_connectors.py --vault ~/Projects/my-second-brain
uv run mcp-memory index ~/Projects/my-second-brain
uv run python scripts/vault_lint.py ~/Projects/my-second-brain
# Optional: run your vault golden benchmark and refresh structural graph
uv run python scripts/run_golden_eval.py \
--vault ~/Projects/my-second-brain \
--golden ~/Projects/my-second-brain/99-system/golden-eval.yaml
cd ~/Projects/my-second-brain && graphify update .6.4 Release Verification Gates
uv run ruff check
uv run mypy --strict src
uv run lint-imports
uv run python scripts/radon_gate.py
uv run pytest --cov=obsidian_memory_mcp --cov-fail-under=80 -q tests
gitleaks detect --source . --no-git --no-banner7. Engineering Documentation Reading Order
Read these documents in sequence for complete architectural and operational context:
System Overview (This Document): Purpose, principles, trust boundaries, benchmarks, and quickstart.
Architecture and Control Flow: Trust zones, bi-temporal SQLite FTS5 schema, ranking math, component contracts, and security invariants.
Second Brain End-to-End Workflow: Vault contract,
S0-S5lifecycle, connector idempotency, 5-class golden eval methodology, and troubleshooting.Upstream System Architecture: Core package layout and module dependency boundaries.
Vault Setup & Indexing Guide: Vault configuration and parser internals.
Retrieval Guide & Context Packs Guide: Query filters, ranking, and strict/soft token budgets.
Write Tools Guide & Tool Reference: All 9 MCP tool contracts,
expected_hashlocking, andwrite_audit.Error Codes, Python API, & Release Checklist: Structured errors, public API boundaries, and release process.
8. Governance, Security, and Licensing
Security Policy: SECURITY.md - never commit private vault data, credentials, or
memory-mcp-server.yaml.Contribution Guidelines: CONTRIBUTING.md
Changelog: CHANGELOG.md
License: Apache License 2.0 (preserving upstream copyright and license terms).
9. References and Upstream Provenance
Source | Author / Organization | What This Repository Adopted | Provenance | License |
| Core FastMCP server, SQLite FTS5 index, token-budgeted context packs, guarded direct-write tools, | FORKED BASE | Apache-2.0 | |
| Graphify contributors | Optional zero-token structural graph layer ( | INTEGRATED | - |
Wes McKinney / Kenn ( | Read-only local session telemetry source ( | INTEGRATED | MIT | |
Zachary Rice ( | Pre-commit and repository secret-leak gate across engine and private vaults | INTEGRATED | MIT | |
Alexandr Wang 4-Step Framework & AI Project Health Scorecard v2 | Alexandr Wang / Dr. Andrey Holz | Project qualification workflow (One-Line Sanity Check, 1-page Memo, Mandatory Gates | METHODOLOGY | - |
ASD | Controlled technical documentation clarity standard | ADAPTED | - |
The bi-temporal migration (003_bitemporal_metadata), bilingual YAML metadata indexer, hyperbolic recency + supersession retrieval defaults, sync_connectors.py, vault_lint.py, run_golden_eval.py, and connect_local_mcp.py were built in this repository on top of the Apache-2.0 upstream base.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Token-efficient MCP memory for Markdown vaults. Tiered search, GraphRAG, AI memories.
Team memory for AI coding agents and code reviews, reviewed by humans and served over MCP.
Shared long-term memory vault for AI agents with 20 MCP tools.
Persistent, inspectable memory for AI agents with lineage, correction, and a hosted MCP endpoint.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceTurns an Obsidian vault into semantic memory for coding agents, providing read-only semantic search and a human-approved write workflow via MCP.8MIT
- FlicenseNot gradedqualityAmaintenanceDurable memory with sources, proof, history, and review for MCP-capable agents. It turns a Markdown/Obsidian vault into a local knowledge substrate, enabling agents to store, search, and retrieve governed knowledge.2,221 PyPI9-
- AlicenseAqualityCmaintenanceEnables AI agents to access a local-first personal context and memory layer through MCP tools for bootstrapping user context, semantically searching Markdown vault knowledge, reading files, listing topics, and adding controlled memories. It provides deterministic context retrieval, provenance-cited vector search, and secure vault operations while keeping data local and model-independent.6MIT
- AlicenseNot gradedqualityBmaintenanceA local MCP server that gives coding agents shared long-term memory stored as plain Markdown in your Obsidian vault, enabling hybrid recall of past project context, verified write-back of confirmed results with receipts, and automatic capture of conversations plus optional daily summaries. It runs entirely offline on CPU with no cloud calls or telemetry.43 PyPI1MIT