Sonar
Indexes and searches local Markdown note folders, using them as the source corpus for a shared long-term memory that AI agents can query.
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.

SONAR
One shared, 100% offline long-term memory for every AI agent you use — Claude Code, Codex, Antigravity, Grok, and any MCP client.
Less AI theater. More results. Built for daily production work, measured on real corpora, zero cloud calls, zero vendor lock-in.
Why Sonar Exists (In Plain English)
Every time you open a new AI chat or switch from Claude to Codex or Grok, your AI starts with amnesia. You re-explain past decisions, architecture rules, bug fixes, and preferences over and over again.
And if you try to plug in a cloud memory tool or a bloated vector framework, you quickly hit four real-world walls:
Privacy leaks — your notes, client context, and code snippets leave your machine.
Slow, noisy search — searching thousands of Markdown notes takes 3–5 seconds, misses exact ticket IDs, and fails when you ask in English about a German document.
Stale truths — old rules keep outranking newer decisions, so agents follow outdated instructions.
Heavy RAM & brittle dependencies — gigabytes of
node_modulesand memory-hungry vector graphs crash small servers or laptops.
Sonar solves all four. It runs as one tiny local service on your Mac, Linux machine, or private server. Every AI harness plugs into it via standard MCP (Model Context Protocol) over a single Unix socket.
Related MCP server: NarratorDB
How Sonar Works — Visual Field Guide

Quick Start (1-Command Setup for You, Your Team, or Family)
Sonar is designed as a clean, plug-and-play template. Zero private rules or personal paths are hardcoded — your own folders and rules live strictly in ~/.config/sonar/.
Requirements
Node.js 22+ (tested on Node
24.x)Python 3.9+ (for the lightweight zero-dependency MCP stdio proxy and
node-gyp)C/C++ build toolchain (
Xcode Command Line Toolson macOS, orbuild-essentialon Linux) for compilingbetter-sqlite3from source by default (SONAR_BUILD_FROM_SOURCE=1; opt-inSONAR_BUILD_FROM_SOURCE=0runsprebuild-installto fetch unpinned GitHub release binaries without SHA-256 verification and is not recommended)Optional: Gitleaks 8.19+ binary (required for the
gitleaks dirsubcommand) for secret screening before indexing
1. Clone and Install
git clone https://github.com/Tomi2k/sonar-memory.git
cd sonar-memory
./scripts/install.shWhat install.sh does:
Installs the 3 pinned production dependencies (
better-sqlite3,@huggingface/transformers,zod— 0 high/critical CVEs) withnpm ci --omit=dev --ignore-scripts, compilesbetter-sqlite3from source by default vianode-gyp(npm run build-release), and smoke-tests the lockfile-verified bundledonnxruntime-nodeCPU native bindings. (If installing manually instead of using./scripts/install.sh, always pass--ignore-scriptsand runcd node_modules/better-sqlite3 && npm run build-release;.npmrcis intentionally gitignored so local registry tokens are never committed.)Runs the full unit and contract test suite (
npm test).Downloads the two commit-pinned, open-license offline ONNX INT8 models (MIT
Xenova/multilingual-e5-small+ Apache-2.0cross-encoder/mmarco-mMiniLMv2-L12-H384-v1) and verifies every weight, tokenizer, and config file's SHA-256 checksum againstmodels/manifest.json.Initializes an empty
memory.dbschema and creates~/.config/sonar/config.jsonand~/.config/sonar/policy.json(mode0600).Installs
~/.local/bin/sonar,~/.local/bin/sonar-mcp, and~/.local/bin/sonar-check.
2. Point Sonar at Your Markdown Folders
Edit ~/.config/sonar/config.json and add the folders you want indexed (omitted database/index/modelRoot/socket keys default to ~/.local/share/sonar/*; avoid indexing untrusted third-party repositories unless needed):
{
"sources": [
"/Users/you/notes"
]
}3. Build the Initial Index & Start the Service
node --expose-gc ingest/reindex.mjs --config ~/.config/sonar/config.json
node --expose-gc server/mcp-server.mjs ~/.config/sonar/config.jsonVerify health in another terminal:
sonar-check
# [SONAR-OK] sonar-v1 bereit (...)Connect Any AI Harness (Claude, Codex, Antigravity, Grok)
Every agent connects through the exact same thin stdio proxy (~/.local/bin/sonar-mcp), talking to the single local daemon over Unix socket:
Claude Code (~/.claude.json)
{
"mcpServers": {
"sonar": {
"type": "stdio",
"command": "/Users/you/.local/bin/sonar-mcp",
"args": []
}
}
}Codex (~/.codex/config.toml) & Grok (~/.grok/config.toml)
[mcp_servers.sonar]
command = "/Users/you/.local/bin/sonar-mcp"
args = []Antigravity CLI (~/.gemini/config/mcp_config.json)
{
"mcpServers": {
"sonar": {
"command": "/Users/you/.local/bin/sonar-mcp",
"args": []
}
}
}Automatic Session-Start Health Check
Never start a session with a dead memory backend again. Add sonar-check --hook to your shell startup (.zshrc / .bashrc) or Claude SessionStart hooks:
# Prints nothing when healthy (<20 ms local socket, 20 s cache for SSH).
# Immediately prints an informational [SONAR-DOWN] notice if unreachable.
sonar-check --hookReal Measured Benchmarks (✓ measured)
Every number below was measured on a real production corpus (22,485 deduplicated documents / 321,906 chunks / 101,330 curated INT8 vectors, mixed German & English engineering, documentation, and decision records) across 120 authentic queries (27 exact IDs, 35 German, 20 English, 20 cross-lingual DE↔EN, 10 project-filtered, 8 multi-topic reference queries) on an 8-core x86_64 Linux server (Node 24.x, SQLite 3.x).
Metric (120 Queries) | Legacy HNSW + JS BM25 ( | Sonar | Sonar | Sonar Live Default ( | Sonar |
Median Latency ( | 3,424 ms | 94 ms | 100 ms | 203 ms (16.9x faster) | 313 ms |
| 4,752 ms | 315 ms | 317 ms | 531 ms (8.9x faster) | 565 ms |
Max Latency | 9,288 ms | 433 ms | 389 ms | 638 ms (14.6x faster) | 651 ms |
Overall | 0.6087 | 0.7255 | 0.8129 | 0.8254 (+0.217) | 0.8466 (+0.238) |
Overall | 0.6291 | 0.7518 | 0.8204 | 0.8328 (+0.204) | 0.8550 (+0.226) |
Exact Ticket/ID | 3.7% (p95 2,659 ms) | 85.2% (p95 22 ms) | 85.2% (p95 21 ms) | 85.2% (p95 26 ms) | 85.2% (p95 21 ms) |
German | 0.7037 | 0.7743 | 0.9409 | 0.9532 | 0.9798 (97.1% Hit@1) |
English | 0.8705 | 0.9315 | 0.9465 | 1.0000 (100% Hit@1) | 1.0000 (100% Hit@1) |
Cross-Lingual | 0.2246 (30% R@10) | 0.2790 | 0.3545 | 0.4315 (+92%) | 0.5500 (60% R@10) |
Vector RAM (Off-Heap) | 809 MB HNSW + 686 MB f32 | 37.5 MB | 37.5 MB | 37.5 MB (−97%) | 37.5 MB |
Live Service Peak RSS | 2.6–10.2 GB | 428 MB | 756 MB | 1.23 GB (both ONNX preloaded) | 1.13 GB |
Install Footprint ( | 1.9 GB | 494 MB (0 high/critical CVEs) | 494 MB | 494 MB | 494 MB |
Note: All metrics above were measured directly by eval/harness.mjs against the live Unix socket and index generations. Results on your machine depend on corpus size, CPU SIMD support (AVX-512 / Apple Silicon), and disk speed.
Technical Deep Dive
1. Architecture & Process Isolation
Single-Writer Canonical Store (
core/store/canonical.mjs): All durable memories, relations (supersedes,contradicts), and a monotonicsonar_changes(seq)journal live in one SQLite WAL database (memory.db).memory_retrieveandmemory_listalways read canonical SQLite directly (0 ms stale reads). New/updated entries since the last index build are blended intomemory_search_unifiedvia a live delta overlay (0 ms stale search).Worker-Thread Search Engine (
server/worker.mjs): Embeddings, INT8 vector scans, FTS5 queries, and cross-encoder inference execute inside a dedicatedworker_threadso the MCP HTTP/Unix-socket event loop never blocks.Separated Atomic Index Builder (
ingest/builder.mjs): Builds derived immutable generations (generation-<model>-<fingerprint>/) containingindex.db+vectors.i8+scales.f32, validatesPRAGMA quick_check, swapsCURRENTatomically, and hot-reloads the live server without restart. Unchanged corpora short-circuit via fingerprint skip.
2. Three-Lane Hybrid Retrieval (core/search/engine.mjs)
Exact Key B-Tree Fast-Path (
chunk_keys): Detects ticket IDs (BUG-1042,FEAT-2099), entry IDs, and exact filenames in< 5 ms— bypassing embedding and reranking completely.SQLite FTS5 + German Umlaut Folding (
core/normalize.mjs): Indexes both exact (2xweight) and stemmed (1xweight) tokens with consistentä↔ae,ö↔oe,ü↔ue,ß↔ssfolding, plus a lean identifier trigram table (fts_ident).Exact INT8 Flat-Scan (
core/search/vector-scan.mjs): Symmetric per-vector INT8 quantization (>0.999cosine fidelity, 384 bytes/vector off-heapInt8Array), 8x-unrolled V8 dot product, 100% exact metadata/project filter recall (zero HNSW post-filter drop-off), zero graph compaction overhead.
3. Truth Lifecycle & Conflict Workflow (core/store/canonical.mjs)
Superseded Auto-Redirect:
memory_supersedemarks an older canonicalmemory_entriesrecord archived, records asupersedesedge (with cycle detection, target-existence verification, and secret-screened reason), and automatically redirects search hits up to 3 hops to the active successor with asuperseded_notice. External/Markdownown-rulefiles cannot be overridden via MCPmemory_supersede.Contradiction Tracking:
memory_storechecks key-prefix and semantic neighbors (cosine ≥ 0.85) and returns non-blockingpossible_conflicts.memory_flag_conflictmarks unresolved contradictions so search surfaces both entries with aconflict_warninguntilmemory_resolvedeclares a winner.Hard Purge:
memory_purge(requiring explicitconfirm: true) deletes the canonical row and relations (PRAGMA secure_delete = ON+ WAL checkpoint retry), writes a purge tombstone that immediately blocks the entry inmemory_search,memory_source, andmemory_sources, and removes older backup index generations on disk. Runningingest/reindex.mjs --force(or the next scheduled reindex) rebuilds the activeindex.dbsnapshot (PRAGMA secure_delete = ON), removes every pre-purge generation on disk, and prunes orphaned vectors fromembed-cache.db.
4. MCP Tool Reference (16 Tools)
Tool | Purpose |
| Hybrid search ( |
| Store/upsert durable entry with secret screening, optional |
| Instant canonical SQLite lookup by |
| Paginated listing of active canonical entries |
| Soft-delete with tombstone protection |
| Hard-delete ( |
| Mark |
| Flag an unresolved contradiction between two entries |
| Resolve a conflict by declaring the winner (optionally superseding the loser) |
| Inspect active successor chain and relation history for a reference |
| Read full original indexed source text or list indexed sources |
| Sub-millisecond index, RAM, vector, and conflict telemetry |
5. CLI Usage
sonar search "how to restore backups" --limit 5 --rerank auto
sonar store --key "deploy-rule" --value "Always run quick_check before cutover" --namespace patterns
sonar supersede --old-ref "patterns/old-rule" --new-ref "patterns/deploy-rule" --reason "Updated procedure"
sonar conflict --ref-a "patterns/rule-a" --ref-b "patterns/rule-b" --reason "Conflicting port"
sonar resolve --relation-id 1 --winner-ref "patterns/rule-b"
sonar history --ref "patterns/old-rule"
sonar stats
sonar-checkSecurity & Privacy Model
100% Offline Runtime:
env.allowRemoteModels = falseandlocal_files_only = truein both embedder and reranker. Run under systemdPrivateNetwork=yes+ProtectSystem=strict+NoNewPrivileges=yes(seedeploy/sonar.service.example).Commit-Pinned SHA-256 Model Verification:
download-models.mjsfetches immutable 40-character Hugging Face commit revisions, and every ONNX weight, tokenizer, and config file is verified againstmodels/manifest.jsonbefore loading (fail-closed). Only permissive open-source models (MIT and Apache-2.0) are accepted.Trusted Root Scoping (
trustedRoots), Trust-Weighted Ranking & Untrusted Content Framing: Markdown files only receivetrust: "own-rule", non-expiringkind: "rule", or same-root frontmattersuperseded_byredirection when located inside directories explicitly listed intrustedRoots. Files outsidetrustedRootsare classified asworkspace-doc(orarchive-doc), strongly demoted via trust weights in both hybrid RRF (0.55x/0.45xvs1.25xforown-ruleand1.0xforinternal-memory) and Cross-Encoder reranking (-1.5/-2.0logit bias vs+2.0/+1.0), and flagged withuntrusted: truepluscontent_warninginmemory_search,memory_source, andmemory_sourcesoutputs. Soft trust weighting reduces prompt-injection priority on comparable matches rather than hard-blocking untrusted passages, so avoid indexing untrusted third-party repositories unless you actually need them.Persistent Memory Write Guard:
memory_store,memory_supersede,memory_resolve,memory_delete, andmemory_purgecarrydestructiveHint: truein MCP annotations. By default, the MCP daemon sets"allowMcpRuleMutations": false(config.json), blocking any MCP mutation ofkind: "rule"orprovenance_type: "user_claim"entries at the server boundary even if an MCP client auto-approvesdestructiveHint: truetools. Operators who explicitly enable"allowMcpRuleMutations": truestill require explicitconfirm_rule_write: trueorconfirm_rule_supersede: truefor creating, overwriting (including archived or soft-deleted entries), deleting, purging, or supersedingkind: "rule"oruser_claimentries (which then depends on the MCP client prompting the user ondestructiveHint: truetools). Tags and metadata (capped at16 KiB) pass through the same secret screening gate asvalue.Secret Screening Gate:
core/secret-screen.mjsintegrates Gitleaks 8.19+ (gitleaks dir --exit-code 99, versioning both binary version andgitleaks.tomlhash in its cache key) and fails closed on any non-zero/non-99 exit, missing/invalid JSON report, or missing/unreadableSONAR_GITLEAKS_BIN/SONAR_GITLEAKS_CONFIG; when no binary is configured, it warns onstderrand applies an expanded built-in regex gate.Strict RPC Schema Validation: All 16 MCP tools validate incoming
params.argumentswithzodat the daemon boundary (enforcing types, bounds, and length limits before touching SQLite or the worker).Zero Telemetry: No analytics, no remote pings, no external fonts or SaaS calls.
Clean Repo Separation: Personal exclusion patterns, project rules, and private evaluation suites live strictly outside the repository (
~/.config/sonar/policy.json,config.json).
Configuration & Custom Policy
Copy examples/config.example.json and examples/policy.example.json to ~/.config/sonar/ (leading ~/ paths are expanded automatically).
In policy.json, you can customize:
trustedRoots— explicit directories whose rule documents (policies/,rules/,CLAUDE.md,AGENTS.md) are trusted as non-expiringown-ruleentries (empty by default).extraSkipDirs— folder names to ignore completely (in addition to.git,node_modules,vendor,.venv,dist,build,.expires-tagged temp folders, and git worktrees).extraWorktreeDirPatterns— regexes for mirrored ephemeral worktree copies.extraArchivePatterns— folders indexed in Tier 2 (FTS5 full-text only, 0 vector RAM).extraCoreCuratedPatterns— high-priority rule/handbook paths guaranteed Tier 1 vectors.projectRules— regex rules mapping file paths toprojectmetadata tags.
For Linux servers, see deploy/sonar.service.example, deploy/sonar-reindex.service.example, and deploy/sonar-reindex.timer.example. For macOS, see deploy/com.sonar.daemon.plist.example.
Limits & Tested Environment
Tested Platforms:
macOS (Apple Silicon, Node
24.x, Python3.12+)Ubuntu Linux x86_64 (AVX-512 capable host, Node
24.x, SQLite3.x, systemd)
Scale Target: INT8 flat-scan is ideal up to ~250,000 curated vectors (
< 100 MBRAM, exact filter recall). Beyond ~500k curated vectors, shard by namespace or swap in an ANN index.Dependencies: 3 runtime npm packages (
better-sqlite3,@huggingface/transformers,zod). Always install via./scripts/install.sh(ornpm ci --omit=dev --ignore-scriptsfollowed bycd node_modules/better-sqlite3 && npm run build-release) rather than barenpm installso transitive postinstall hooks never run;.npmrcis intentionally gitignored to avoid accidental auth-token commits.install.shcompilesbetter-sqlite3from source vianode-gypby default (SONAR_BUILD_FROM_SOURCE=1; opt-inSONAR_BUILD_FROM_SOURCE=0runsprebuild-installto fetch unpinned GitHub release binaries without SHA-256 verification).Reranker Latency Budget: On heavily loaded CPUs,
rerank: "auto"enforces a strict250 msdeadline and falls back cleanly to hybrid RRF rankings so agent sessions never stall.
License
MIT License — Copyright (c) 2026 Timothy Scherman. See LICENSE.
Built by Timothy Scherman (timothyscherman.com). Less AI theater. More results.
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
Persistent, inspectable memory for AI agents with lineage, correction, and a hosted MCP endpoint.
Persistent memory for AI agents across Claude, ChatGPT and any MCP client.
Persistent memory, knowledge graph, task management and more for AI agents via MCP.
A second brain for your AI agent. Shared memory for your team's AI agents, plus public and private knowledge bases — works with ChatGPT, Claude, Cursor and any MCP client.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceProvides a local vector memory store for AI agents with semantic search, offline embeddings, and MCP integration, enabling tools like Claude and Cursor to store and retrieve information without cloud dependencies.16 npmMIT
- AlicenseNot gradedqualityDmaintenanceLocal-first long-term memory database for AI systems, providing SQLite FTS5/BM25 retrieval and optional SentenceTransformer embeddings via MCP server.MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to store and recall durable facts, decisions, and lessons over MCP using hybrid semantic and keyword search, typed memories, graph relations, sessions, and time-travel queries. Runs locally with no server process or API key, persisting everything to files that both agents and a CLI can share.18 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents and any MCP-compatible client to persist, search, update, and delete plain-text memories across sessions, using BM25 lexical ranking over SQLite FTS5 with namespace filtering, tags, free-form metadata, and JSONL export/import — entirely local, with zero external infrastructure.1MIT