loci
This MCP server lets you search, query, maintain, and explore a shared personal knowledge base and durable memory store.
Search indexed notes with hybrid vector + BM25 retrieval, returning ranked excerpts with citations and optional path/tag filters.
Ask questions and get LLM-synthesized answers grounded in retrieved excerpts, with optional claim-by-claim verification.
Explore Obsidian-style wikilinks around a note and query the memory/wiki knowledge graph for entity relations or hub entities.
Inspect the index contents, counts, models, and retrieval settings; trigger incremental or forced reindexing.
Generate curated, cross-linked wiki pages from indexed source excerpts.
Store durable memories (facts, decisions, preferences, lessons) as searchable markdown notes, and retract wrong or outdated memories.
Inspect per-AI-harness memory stats or regenerate harness digest notes into the shared memory pool.
Indexes and searches Obsidian vaults as a queryable knowledge base, with support for frontmatter tags, [[wikilinks]], and cross-vault retrieval with section-level citations.
Turn scattered notes, project docs and agent memories into a knowledge base you can search and ask questions about — as an MCP server, from your terminal, or in the browser.
loci combines vector search with BM25 and returns answers with file > section citations. Your files and index stay on your machine. Embedding and chat requests go to the providers you configure; local endpoints can keep the entire workflow offline.
MCP is the point. Mount loci-mcp in Claude Desktop, Cursor, Cline or any other MCP host and your assistant gets the whole knowledge base as tools. The console and a desktop shell are alternate front-ends to the same index — you never need them.
Quick start · MCP setup · Web console · Usage guide · 中文说明

Actual console UI with fictional demo data. No personal knowledge base, account or API key is connected; counts are illustrative.

What you can do
Need | How loci helps |
Find a decision buried in your notes | Hybrid search across directories, with tag, path and date filters |
Search for an exact identifier | Literal matching for |
Know whether a decision still applies |
|
Ask a question and check the evidence | Answers cite source sections; optional claim-by-claim verification |
Carry context between AI tools | MCP tools share one instance; durable memories are Markdown files |
See what each coding agent remembers | Harness discovery, file browsing, per-tool stats and digest notes |
Manage the knowledge base visually | Built-in Web console for search, Q&A, memories, indexing and audit |
Resume a task exactly where it left off | Structured state by exact key ( |
Prune memory with evidence instead of vibes | Memory health: citations, corrections and age per note ( |
Markdown, text, HTML, org-mode and chat exports work out of the box. Optional extras add PDF, Word and OCR support. Keep using your existing note editor or Obsidian vault.
Related MCP server: loci-mcp
What belongs where
Three kinds of "memory" fail differently, and mixing them is the classic misuse:
Kind | Lives in | Retrieved by | Right for | Wrong for |
Free-text knowledge | memory notes ( | hybrid retrieval | "what do we know about X" | exact resume of a task |
Structured state |
| exact key, no ranking | task snapshots, entity records, slot state worth persisting | prose you might want to fuzzy-find |
Live dialogue slots | the host agent's session | the host's own context | this turn's variables | anything you expect to survive the session |
Rules of thumb:
If retrieval returning a similar but wrong record would be a bug, it is state — key it and fetch exactly (
brain_state_get type=task key=8f3c).Real-time slot values change every turn; do not put them in the vector store. Persist the ones worth keeping across sessions as state records.
Prose that a future question might phrase differently is knowledge —
brain_rememberit, and let ranking do the work.
State records are plain JSON, hand-editable, and deliberately not indexed into vectors: that is the boundary, not an omission.
Decision history
A decision note edited in place loses the fact that something replaced it. Two
frontmatter keys keep that visible, and loci history walks the chain:
---
supersedes: use-staging # the note this one replaces
effective: 2026-03-01 # when this one took effect
---loci history use-staging
# decision history, oldest first:
# 1. use-staging (effective 2026-01-05) → superseded by
# 2. staging-exception (effective 2026-03-01)
# current decision: staging-exception (effective 2026-03-01)loci ask marks excerpts from superseded notes in the context it sends to the
model, so an answer does not quote last quarter's decision as current policy —
and it tells you how many excerpts were affected.
Memory health
Every search or answer that uses a memory note is ledgered (citations.jsonl
in the instance directory). loci memory-health joins that with feedback
(loci feedback bad — which also sinks the rated chunks in later retrieval)
and age, and flags notes worth looking at:
$ loci memory-health
12 memory note(s), most-cited first
cited corr age(d) last-cited flags file
17 0 41.2 0.3 - 20260920-103000-deploy-policy.md
0 2 63.8 - corrected 20260830-090000-old-strategy.md
0 0 51.4 - never-cited 20260901-120000-random-idea.mdcorrected = rated bad after being used; never-cited = old and unused.
Both are candidates for brain_forget — with evidence, not vibes. loci sees
tool calls, not your conversation, so corrections reach it only through
explicit feedback; the report never silently rewrites retrieval.
Quick start
Try it first, with nothing configured
pip install loci-rag
loci demoloci demo copies six fictional notes into ./loci-demo-notes, chunks them and
answers three example questions — cited down to file > section — with no
config.toml, no API key and no network. It is keyword-only (BM25, the same
ranking hybrid search fuses with vector hits), which is exactly the point:
something runs before you commit a key. Add [embed] later and the same index
goes hybrid.

Actual loci demo output on the bundled sample notes; paths shortened, timings vary.
Index your own notes
Requires Python 3.11+. Start from source so the example configuration is available:
git clone https://github.com/IvenKooLab/loci.git
cd loci
python -m pip install -e .
cp config.example.toml config.tomlEdit config.toml: fill in [llm] and [embed], and change [[sources]].path to your notes directory. The embedding endpoint must support /embeddings; chat and embeddings may use different providers.
loci ingest
loci search "deployment decisions"
loci ask "What did we decide about deployment, and why?"Already have a configuration? Install the package with python -m pip install loci-rag and set LOCI_HOME to your instance directory. For optional document support, use python -m pip install 'loci-rag[pdf,docx]'.
API keys can be supplied through
BRAIN_LLM_API_KEYandBRAIN_EMBED_API_KEY. After changing the embedding model, rebuild withloci ingest --force.
Using Obsidian? See the vault setup, privacy and compatibility guide.
Web console
loci serve-httpOpen 127.0.0.1:8765/ui to browse harness memories, search, ask questions, edit shared notes and inspect indexing activity. Clicking a search result opens an evidence pane with the passage it was cut from — the file > section citation, checkable without leaving the console. The console includes Chinese/English and light/dark switches; no frontend build is required.
By default, anonymous loopback clients have admin access. Behind a reverse proxy or SSH tunnel, set [http] local_admin = false and configure role-based tokens. See access control.
For DeepSeek Harness, loci-dsh brings search, Q&A and memory capture into the Harness workbench through the same HTTP backend.
Connect your AI tools
Point each MCP client at the same LOCI_HOME so they share the same config, index and memory files:
{
"mcpServers": {
"loci": {
"command": "loci-mcp",
"env": { "LOCI_HOME": "/absolute/path/to/your/loci-instance" }
}
}
}Use an absolute executable path if your client cannot find loci-mcp. The instance directory must contain your config.toml.
MCP tools | Purpose |
| Retrieve excerpts or get cited answers |
| Store or retract durable memories |
| Exact-key structured state (task snapshots, entity records) |
| Which memory notes are cited, corrected, or dead weight |
| Explore note links and extracted relations |
| Consolidate knowledge and inspect agent memories |
| Lifecycle scan (superseded / duplicate / stale notes) and retrieval-quality drift |
| Inspect and refresh the index |
The server also exposes note resources and briefing, study-plan and contradiction-check prompts. See the MCP guide for details.

Actual loci-mcp output: initialize, tools/list and prompts/list on the real binary.
Native build (Rust)
The same retrieval pipeline and MCP surface, with no Python runtime to install — one binary, and the index is a single SQLite file instead of a database directory:
cargo build --release -p loci-cli # in native/
./target/release/loci-mcp --config ~/.loci/config.toml
./target/release/loci gui # the same console, served nativelyStatus: retrieval, a subset of MCP tools, harness discovery, migration and the
console are ported. Harness file browsing and digest generation remain
Python-only. See
native/ for what is ported and the fidelity tests that pin it
(chunking, the frozen default tokenizer, the CJK bigram decoy case, RRF, and
incremental ingest).
The two builds keep separate store formats (SQLite vs ChromaDB directory),
but they exchange data: export from Python with loci export, import in the
native build with loci import, which refuses to mix embedding spaces unless
you pass --force.
A small daily workflow
loci watch # keep changed documents indexed
loci remember "Use staging for demos" --title "Demo environment"
loci search "demo environment" --tag memory
loci ask "How should I prepare a demo?" --verify
loci harness # inspect detected agent memoriesIndexing is incremental. Notes stay readable as Markdown. For multiple machines, sync source files and memory notes, then rebuild each local index; keep credentials out of the repository.

The usage guide includes the original bilingual retrieval example and a small evaluation you can rerun against your own corpus.
Documentation
Guide | Covers |
Commands, filters, harness setup, access control and local models | |
Provider settings, source directories and runtime options | |
Modules and the retrieval pipeline | |
Released changes and planned work | |
Development conventions and offline testing |
loci uses the OpenAI-compatible SDK and ChromaDB, with no LangChain or LlamaIndex dependency. BM25, loaders and the MCP transport are implemented in the project.
python -m pip install -e '.[dev,pdf]'
pytest # offline tests; no API keys requiredFind loci on Glama, ModelScope and awesome-mcp-servers. Source: GitHub. Licensed under MIT.
Available Tools
17 toolsbrain_askA
Ask the knowledge base a question. Behavior: retrieves the most relevant excerpts, then an LLM synthesizes an answer grounded ONLY in them, ending with [source: path > section] citations. Usage: prefer this over brain_search whenever a question needs synthesis or an explanation; set verify=true to get a claim-by-claim audit (supported / partial / unsupported) when accuracy matters more than speed.
Inputs: question (required), verify.
brain_forgetA
Retract memories that are wrong or outdated. Behavior: memory notes matching the query move to a .trash folder (recoverable by hand) and their chunks leave the index immediately; nothing is permanently destroyed. Usage: use when a remembered fact was superseded or was a mistake; check with brain_search first if you are unsure what matches.
Inputs: query (required).
brain_governanceA
Read-only lifecycle scan of the configured sources. Reports notes whose frontmatter marks them superseded but which are still indexed, duplicate active notes sharing one title, supersedes: links pointing at missing notes, and old notes that were never cited. Nothing is changed; retire explicitly with brain_forget. Run this when answers look plausible but outdated.
Inputs: stale_days.
brain_graphA
Query the knowledge graph over memories and wiki pages. Behavior: with an entity, returns its outgoing/incoming relations (each cites its source file); without one, returns the top hub entities. The graph is built from loci graph build (LLM-extracted triples in graph.json). Usage: explore how concepts connect before asking questions; see the strongest entities for orientation.
Inputs: entity.
brain_harnessA
Harness memory hub: per-AI-tool (zcode, codex, ...) memory stats, or refresh each one's auto-summary note into the shared memory pool. Unchanged harnesses cost nothing.
Inputs: action (required), name, force.
brain_ingestA
Incrementally (re)index the configured source directories. Safe to call repeatedly; only changed files are re-embedded.
Inputs: force.
brain_linksA
Show the Obsidian-style [[wikilink]] graph around a note. Behavior: lists every note the given note links to (outbound) and every note that links back to it (inbound), based on the current index. Usage: use to explore how a topic connects to others before asking questions, or to find related notes when search keywords fail.
Inputs: note (required).
brain_memory_healthA
Report which memory notes are earning their keep: times cited by searches/answers, corrections (bad feedback), age, and flags for review (corrected, never-cited). Use it before brain_forget to prune dead weight with evidence instead of guessing.
Inputs: no named parameters.
brain_qualityA
Retrieval health from the query log: zero-hit rate, average hits and latency, bad-answer rate from feedback, plus drift against a pinned baseline. Use action=pin on a known-good day, then action=report to see whether quality slid.
Inputs: action (required), window.
brain_rememberA
Store a durable memory (decision, fact, preference, lesson learned) into the shared knowledge base. Behavior: writes a markdown note with frontmatter tags into the memories directory and indexes it immediately, so it is searchable within the same call. Memories persist across sessions and are shared by every MCP host that mounts loci — write from one IDE, recall from any other with brain_search or brain_ask. Usage: use for decisions, facts, preferences and lessons worth recording; do not use for ephemeral chit-chat.
Inputs: text (required), tags, title.
brain_searchA
Search the personal knowledge base with hybrid retrieval (vector similarity fused with BM25 keyword matching). Behavior: returns up to k ranked excerpts, each with file path, heading breadcrumb and similarity score; no LLM call is made. Usage: reach for this when you need source material to quote, verify a claim, or see what exists on a topic; use brain_ask when you want a synthesized answer instead. Results are limited to the indexed sources — run brain_ingest first if recent files are missing.
Inputs: query (required), k, in, tag.
brain_state_deleteC
Delete one structured record by exact type+key.
Inputs: key (required), type (required).
brain_state_getA
Fetch one structured record by exact type+key - no embedding, no ranking, no dilution by similar-but-irrelevant content. Use this to resume a task or read entity state saved with brain_state_save.
Inputs: key (required), type (required).
brain_state_listA
List saved structured records (newest first), optionally only those whose type starts with type_prefix. Use it to discover ids before an exact brain_state_get.
Inputs: type_prefix.
brain_state_saveA
Save structured state (task snapshot, entity record) under an exact key - retrieved later by key, never by semantic search. This is the right place for task state an agent must resume precisely; free-text knowledge belongs in brain_remember. data is stored verbatim as JSON (object or array, max 256 KiB); saving again with the same type+key overwrites.
Inputs: key (required), data (required), type (required).
brain_statsA
Report what the index currently contains. Behavior: returns the store path, total chunk count, chunk count per source file, the embedding and chat models in use, and retrieval settings (hybrid, rrf_k, top_k). Reads local metadata only — no LLM or embedding calls. Usage: call before searching to see what is indexed, after brain_ingest to confirm what changed, or whenever answers seem to be missing a file you expected to be there. Takes no parameters.
Inputs: no named parameters.
brain_wikiA
Generate a wiki page about a topic by distilling everything the index knows into one curated, cross-linked markdown page. Behavior: retrieves up to k source excerpts, an LLM synthesizes a structured page, and the page is written to the wiki directory and indexed immediately (loci's memory-consolidation layer). Requires a working LLM. Usage: use when scattered notes about a topic should become one stable, searchable page; regenerate the same topic to update it.
Inputs: topic (required), k.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 17 tools
Core operations (ask/search/remember/forget/ingest/wiki) are cleanly separated and the descriptions explicitly disambiguate ask-vs-search and remember-vs-state_save. However, the diagnostics cluster (brain_stats, brain_memory_health, brain_quality, brain_governance) overlaps—memory_health and governance both flag never-cited notes—and brain_links vs brain_graph both promise 'explore how concepts connect', which can cause misselection.
Every tool uses a uniform brain_ + snake_case pattern, which is highly predictable. The only deviation is grammatical: some are verbs (brain_ask, brain_search, brain_ingest) while others are bare nouns (brain_stats, brain_graph, brain_quality) or noun_verb (brain_state_save), but all remain readable and grouped by family.
17 tools is slightly heavy but justified by the scope: knowledge lifecycle, a full four-tool state CRUD family, and a rich diagnostic/governance layer. No tool looks obviously redundant enough to remove, though the four reporting tools could arguably be consolidated.
The domain is well covered end-to-end: ingest, hybrid search, synthesized answers, memory write/retract, consolidation via wiki, graph/link exploration, plus full save/get/list/delete state management and quality/governance diagnostics. The only minor gap is reading a raw note by path rather than via search, which is workable around.
Maintenance
Related MCP Connectors
Keeps your memory: WhatsApp, voice or any AI tool over MCP, Markdown you own, recall with sources
Your personal library, readable by AI agents: durable snapshots, hybrid search, 46 MCP tools.
Self-hosted AI workspace: semantic RAG document search, long-term memory, and AI chat via MCP.
Serve a folder of Markdown notes as an MCP server: hybrid search, reading, and sourced answers.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceMCP server for local RAG over personal notes, PDFs, and documents, enabling plain-English querying and hybrid search with multi-hop context expansion.MIT
- FlicenseNot gradedqualityAmaintenanceEnables MCP-compatible AI agents to search, ask, and retrieve section-level cited answers from a local hybrid index over scattered notes, documents, and chat logs.-
- FlicenseNot gradedqualityAmaintenanceEnables AI agents to query a local, hybrid-searchable second brain over scattered notes, documents, and chat logs with section-level citations. It exposes retrieval tools, resources, and prompts through MCP so hosts like Claude Desktop, Cursor, and Cline can use the indexed knowledge.-
- FlicenseNot gradedqualityBmaintenanceA local MCP server that lets AI hosts like Claude Desktop, Cursor, or Cline query a hybrid vector + BM25 index of your scattered notes, project docs, PDFs, and chat exports, returning answers with section-level citations. It exposes eight tools, resources, and prompts so agents can search, ask, and walk links across all your source directories at once.-