Λογότυπο Loci

Loci

Κοινότητα
IvenKooLab

A queryable second brain over your scattered notes and docs - hybrid retrieval (vector + BM25), section-level citations, and an MCP server so AI agents can use it. ~300 lines, no LangChain.

ΕκδότηςIvenKooLab
Αποθετήριοloci
ΓλώσσαPython
Forks
0
Αστέρια
98
Διαθέσιμα εργαλεία
0
Τύπος μεταφοράςstdio
Κατηγορίες
Άδεια χρήσηςMIT
Σύνδεσμοι
  • Συνδέστε εργαλεία σε ροές εργασίας AI

    Το Loci παρέχει δυνατότητες MCP που μπορούν να χρησιμοποιηθούν από συμβατές εφαρμογές-πελάτες AI και πράκτορες AI.

  • 0 διαθέσιμα εργαλεία

    Περιηγηθείτε παρακάτω στις ενέργειες που μπορούν να κληθούν, μαζί με τα ονόματα και τις περιγραφές τους, όταν παρέχονται από τον διακομιστή.

  • Ρυθμίσεις έτοιμες για αντιγραφή

    Χρησιμοποιήστε τα αποσπάσματα εγκατάστασης για να ρυθμίσετε αυτόν τον διακομιστή στην εφαρμογή-πελάτη MCP που προτιμάτε.

  • Δείκτες ενδιαφέροντος για τον ανοιχτό κώδικα

    98 αστέρια και 0 διακλαδώσεις στο συνδεδεμένο αποθετήριο.

loci 🧠

English 简体中文 繁體中文 日本語 Gitee Stars 한국어

CI License Python loci MCP server — quality and maintenance score on Glama ModelScope MCP Square

Two thousand years ago, orators stored their speeches in the rooms of a palace and walked through them to remember. loci does the same for your files.

Loci is the method behind every memory palace: place knowledge in locations, recall it by walking the path.

loci demo

A queryable "second brain" for the project docs, notes, and chat logs scattered across a dozen directories — and an MCP server so your AI agents can use it too.

Local files → heading-aware chunking → embeddings → hybrid retrieval (vector + BM25) → LLM answer with section-level citations. The index lives entirely on your machine; only embedding/chat calls go out, to any OpenAI-compatible API (Zhipu / DeepSeek / Kimi / OpenAI / …).

The thesis (from studying the 90k-star platforms and the graveyard of dead lightweight tools — see our competitive landscape study): don't build another chat app. Build the memory layer that every chat app can mount. Claude Desktop, Cursor, Cline, or any MCP host becomes this project's UI, for free.

Demo

Real session, indexed against the docs of minimax-h3-turing (paths shortened for display):

$ python main.py search "what the 22G card can and cannot do" -k 3

[1] minimax-h3-turing/docs/en/01-hardware-limits.md > 01 · What a 2080Ti 22G Can and Cannot Do    (similarity 0.562)
[2] minimax-h3-turing/docs/en/02-w4a8-vs-w4a4.md > 02 · Quantization Measured > You Can Try Without 22G  (similarity 0.446)
[3] minimax-h3-turing/docs/en/01-hardware-limits.md > ... > 3. VRAM is just barely enough — manage it  (similarity 0.504)

$ python main.py ask "How should I choose between T8 aggressive mode and the final-render mode, and why?"

Answer:
* Drafts / preview / shot selection: use T8 aggressive mode — a 43% speedup
  (2.7 min/clip), and "a different picture of equal quality" is fine for picking shots.
* Final shots: use final-render mode (no T8). T8 makes the numerical trajectory
  fork, so re-running with the same seed produces a different clip — which breaks
  the reproducibility final outputs need.

[source: docs/en/08-t8-blockcache-4step.md > Practical Advice (4-step Turbo route)]
[source: docs/en/06-faq.md > 12. Cache-style accelerators break "same-seed re-runs"]

Hybrid retrieval means a Chinese query still finds the English doc (and vice versa) — keyword evidence (BM25) catches what embeddings miss, and every citation points at a section, not just a file.

Does hybrid actually help? (mini-eval, 10 bilingual queries)

$ python scripts/eval_retrieval.py scripts/eval_cases.example.jsonl
vector-only: 9/10  →  hybrid: 10/10

Hybrid also fixed the #1 ranking on keyword-ish queries (e.g. "T8 block cache threshold speedup": vector put an FAQ first, hybrid puts the actual T8 writeup first). Run it against your own corpus with your own cases file.

Reranking: two providers

--rerank reorders the fused candidates for precision:

ProviderHowCost
llm (default)pointwise 0–3 relevance scoring by your chat modelone extra LLM call
localcross-encoder, via pip install 'loci[rerank]'~30–70 ms for 5 pairs on GPU — offline, free
bash
python main.py search "T8 speedup" --rerank          # provider from config
python main.py search "T8 speedup" --rerank local    # cross-encoder (BAAI/bge-reranker-base)

The local model downloads on first use (~1.1 GB; set HF_ENDPOINT=https://hf-mirror.com if HuggingFace is slow in your region). Measured on a 2080 Ti, bilingual query.

Office documents, PDF tables, web pages, org files, chat logs

  • PDFs: with the [pdf] extra, PyMuPDF4LLM extracts pages as markdown — tables come through as pipe rows (plain pypdf text is the fallback)
  • Word: with the [docx] extra, .docx paragraphs and table rows are indexed
  • HTML: .html / .htm pages become text with headings preserved (stdlib html.parser, zero dependencies — <meta charset> honored, script/style skipped)
  • org-mode: .org notes convert faithfully — #+TITLE becomes the h1 with *-sections nested under it, #+FILETAGS become searchable tags
  • Chat exports: drop a ChatGPT or Claude conversations.json into any source directory — it becomes one searchable document per conversation, tagged chatlog (search --tag chatlog scopes to chat history)

How it relates to Obsidian / your note app

It doesn't compete — the two layer up. Obsidian (or any editor) is the note-taking frontend; this is the cross-vault search engine: point sources at any directories (Obsidian vaults, project docs, chat exports) and query all of them at once — from your terminal, your scripts, or your AI agent via MCP. Obsidian-native details are understood: frontmatter tags: (filter with search --tag), [[wikilinks]] (walk the graph with links), code blocks are never cut mid-block, and one-line notes stay searchable.

How it works

The write path in one line: loaders → chunker (heading-aware split) → embedder → store (ChromaDB, persistent) — incremental, deduplicated by content hash.

Install & quick start

Requires Python 3.11+ (uses the stdlib tomllib).

bash
# option A: install from PyPI (adds `loci` and `loci-mcp` commands)
pip install "loci-rag[pdf,docx]"   # optional extras: PDF w/ tables, Word documents

# option B: zero-install quickstart
pip install -r requirements.txt

# 1. Configure: copy the example and fill in your values
cp config.example.toml config.toml

# 2. Ingest (incremental — deduplicated by content hash, safe to re-run)
loci ingest            # or: python main.py ingest

# 3. Ask
loci ask "what did I write about X?"

The workflow

Commands

CommandWhat it does
ingestscan sources, index new/changed files, prune deleted ones (--force re-embeds everything)
search "query"retrieval only — ranked excerpts with path > section breadcrumbs
ask "question"retrieval + LLM answer with [source: path > section] citations
ask "…" --verifyadditionally audit the answer claim-by-claim against the sources (✓ supported, ~ partial, ✗ unsupported)

Filter operators (combine freely, on search and ask):

FlagFilters to
--tag foofiles whose frontmatter tags contain foo
--in docs/enfiles whose path contains the substring
--since 2026-08 / --since 2026-08-15files modified on/after that date
-e "exact phrase"chunks containing the exact phrase
-k Nreturn N hits (default 5)
links "note"show the [[wikilink]] graph around a note — outbound and inbound
chatmulti-turn Q&A loop with conversation memory (/clear, /exit)
watchkeep the index current by polling sources (interval in [watch])
ask "…" --rewriteLLM-rewrite the query (keyword + cross-language variants) before retrieval
feedback good|badrate the chunks used in the last ask; bad-rated chunks sink in future results
wiki --suggestsuggest wiki-worthy topics that don't have a page yet
bench cases.jsonlretrieval benchmark: hit@k, vector-only vs hybrid
sync push|pullsync memories/wiki across machines via git ([sync] remote)
serve-httpHTTP REST API (search/ask/remember/stats) with Bearer auth
graph build / graph show ENTITYknowledge graph over memories/wiki (LLM-extracted triples in graph.json)
statswhat's in the index: chunks per source, models, retrieval settings
doctorhealth check: config, source dirs, embed/LLM endpoints, store (exit code 1 on failure — CI-friendly)
python mcp_server.pyMCP server over stdio (see below)

One memory, every IDE

Because every MCP host mounts the same loci server (same config.toml, same index), memory written from one tool is recalled from every other:

bash
# Claude Code
claude mcp add loci -- loci-mcp
jsonc
// Cursor / Cline / Qoder / Trae (mcpServers JSON — same shape everywhere)
{ "mcpServers": { "loci": { "command": "loci-mcp" } } }

Then, from any of them: "remember that the staging password rotates on Mondays" → brain_remember → later, from a different IDE: "when does the staging password rotate?" → answered, with the memory cited. Memories live as plain markdown in the memories directory (git-friendly, no lock-in) and are tagged memory, so loci search --tag memory scopes to them.

Cross-IDE tip: the default store / memories paths are relative to the directory loci is launched from. If your IDEs start in different project folders, point both at one absolute location in config.toml — e.g. store.path = "~/.loci/store" and memories.path = "~/.loci/memories" — and every IDE shares the exact same memory store.

Ecosystem

  • loci-dsh — visual plugin for DeepSeek Harness: search, ask, quick-capture memories and watch index stats from a sidebar in the dsh web UI, talking to loci serve-http over local REST.

Mount it in any MCP host

Add to claude_desktop_config.json (Claude Desktop) or your MCP client's config:

json
{
  "mcpServers": {
    "loci": {
      "command": "python",
      "args": ["/path/to/loci/mcp_server.py"]
    }
  }
}

The server exposes three tools (zero dependencies beyond the core):

ToolPurpose
brain_search(query, k?, tag?, in?)ranked excerpts with breadcrumbs
brain_ask(question, verify?)grounded answer with citations; verify=true adds a claim-by-claim audit
brain_links(note)outbound/inbound [[wikilink]] graph around a note
brain_stats()index overview (chunks per source)
brain_graph(entity?)knowledge-graph relations for an entity (omit for hub entities)
brain_remember(text, title?, tags?)write a memory — durable, shared across sessions and IDEs
brain_forget(query)soft-delete matching memories (they go to a .trash folder)
brain_wiki(topic)memory consolidation — distill the index into a curated wiki page about a topic
brain_ingest(force?)incremental re-index

Beyond tools, the server speaks the full protocol:

  • Resources — resources/list exposes brain://stats plus one brain://note/… resource per indexed file (raw markdown via resources/read)
  • Prompts — three ready-made templates: brain-briefing, study-plan, contradiction-check; hosts render them with your topic pre-filled

Fully offline with Ollama

The index is local by design — and the embedding/chat calls can be too. Any OpenAI-compatible server works; Ollama is verified end-to-end:

toml
[llm]
base_url = "http://localhost:11434/v1"
api_key = "ollama"          # any non-empty placeholder
model = "qwen2.5:0.5b"

[embed]
base_url = "http://localhost:11434/v1"
api_key = "ollama"
model = "all-minilm"

With this config, ingest / search / ask make zero cloud calls. Swap in a bigger local chat model for better answers — the pipeline is model-agnostic.

Configuration

KeyMeaning
[llm]base_url / api_key / model — any OpenAI-compatible endpoint
[embed]same; the model must be an embedding model (e.g. embedding-3)
[[sources]]document directories, scanned recursively for .md / .txt / .html / .org (plus .pdf/.docx/images with the matching extras)
[[sources]] chunk_size / chunk_overlapoptional per-directory chunking override — wins over the global [chunk] block
[chunk]chunking params (default 800 chars / 100 overlap)
[top_k]number of hits per search (default 5)
[retrieval]hybrid (vector+BM25 fusion, default on), rrf_k, rerank (LLM reranking, default off)
[watch]poll interval seconds

API keys can also come from the environment variables BRAIN_LLM_API_KEY / BRAIN_EMBED_API_KEY (these override the config file).

Development

bash
git clone https://github.com/IvenKooLab/loci && cd loci
pip install -e ".[pdf,docx]"        # editable install for hacking on loci
pip install -r requirements-dev.txt
pytest                              # fully offline, no API keys needed

See CONTRIBUTING.md for the ground rules (no frameworks, tests stay offline, citations are sacred).

Design decisions

  • ~300 lines of core, no LangChain — every stage is readable, hackable, and learnable. The whole engine fits in one sitting.
  • MCP-first — the agent ecosystem is the UI layer. No web app to maintain.
  • Hybrid retrieval on by default — vector search fused with a native ~60-line BM25 (CJK-aware tokenizer) via Reciprocal Rank Fusion.
  • Citations always, with breadcrumbs — path > section, so claims are verifiable at a glance.
  • Robust, inspectable indexing — defensive loaders (skip what can't be parsed, never hang), content-hash incrementality, real pruning, stats and doctor so the index is never a black box.
  • Tiny notes stay searchable — no minimum-chunk filter; a one-line note is still indexed (a lesson from watching other tools drop or choke on them).
  • Keys never in code — config.toml (gitignored) or env vars.

Where it sits

lociAnythingLLM (65k★)Khoj (37k★)RAGFlow (90k★)
Positioningpersonal retrieval backend + MCPall-in-one chat platformself-hosted AI assistantenterprise RAG engine
Footprint2 runtime deps, no Dockerdesktop app / DockerDjango server + workersDocker, DeepDoc models
UIyour terminal & your agentsbuilt-in web/desktopweb + Obsidian/Emacsweb
MCP server✅ nativeconsumer——
Hackable core✅ ~300 lines❌❌❌
Multi-userby design, no✅✅✅

(Full data and reasoning: competitive landscape study.)

Roadmap

See docs/roadmap.md — reranking, GraphRAG experiments, more loaders.

License

MIT

Εγκατάσταση

TypingMind
{
  "mcpServers": {
    "loci": {
      "command": "python",
      "args": [
        "-m",
        "loci.mcp_server"
      ]
    }
  }
}

Χρησιμοποιήστε το MCP Loci με πολλά μοντέλα AI

Το TypingMind συνδέει τα εργαλεία MCP σε επίπεδο χώρου εργασίας. Έτσι, μόλις συνδεθεί το Loci, μπορείτε να το χρησιμοποιείτε με διαφορετικά μοντέλα AI στο TypingMind, αντί να το ρυθμίζετε ξεχωριστά για κάθε μοντέλο. Αυτή η ενσωμάτωση MCP εκτελείται τοπικά στη συσκευή σας μέσω του συνδέσμου MCP του TypingMind.

Οδηγός ρύθμισης για τη χρήση του τοπικού συνδέσμου

Επιλέξτε αυτή τη μέθοδο όταν ο διακομιστής MCP χρειάζεται πρόσβαση σε τοπικά αρχεία, εφαρμογές ή ιδιωτικούς πόρους στον υπολογιστή σας.

1

Ανοίξτε τις ρυθμίσεις MCP

Στο TypingMind, μεταβείτε στις «Ρυθμίσεις», έπειτα στις «Σύνθετες ρυθμίσεις» και στο «Model Context Protocol» και επιλέξτε «Ρύθμιση συνδέσμου».

  1. Ανοίξτε το TypingMind στο πρόγραμμα περιήγησής σας.
  2. Κάντε κλικ στο εικονίδιο «Ρυθμίσεις».
  3. Μεταβείτε στις «Σύνθετες ρυθμίσεις».
  4. Ανοίξτε την ενότητα Model Context Protocol.
  5. Κάντε κλικ στην επιλογή «Ρύθμιση συνδέσμου» και επιλέξτε «Αυτή η συσκευή».
Οθόνη ρύθμισης συνδέσμου MCP του TypingMind με επιλεγμένη την επιλογή «Αυτή η συσκευή»
2

Εκτελέστε την εντολή του συνδέσμου

Επιλέξτε «Αυτή η συσκευή», αντιγράψτε την εντολή από το TypingMind και εκτελέστε την στο Τερματικό. Διατηρήστε τη διεργασία σε λειτουργία όσο χρησιμοποιείτε το MCP.

  1. Αντιγράψτε την εντολή ρύθμισης που εμφανίζεται στο TypingMind.
  2. Ανοίξτε το Τερματικό στο macOS ή το Windows Terminal στα Windows.
  3. Επικολλήστε και εκτελέστε την εντολή.
  4. Εγκρίνετε την εγκατάσταση του πακέτου, αν το Τερματικό σάς ζητήσει επιβεβαίωση για να συνεχίσει.
  5. Διατηρήστε ανοιχτό το παράθυρο του Τερματικού και τη διεργασία σε λειτουργία όσο χρησιμοποιείτε εργαλεία MCP.
3

Προσθέστε το Loci ως διακομιστή

Όταν η κατάσταση του συνδέσμου είναι «Έτοιμος», κάντε κλικ στο «Αλλαγή servers» και επικολλήστε τις ρυθμίσεις του διακομιστή MCP.

  1. Περιμένετε μέχρι η κατάσταση του συνδέσμου να εμφανιστεί ως «Έτοιμος».
  2. Κάντε κλικ στο «Αλλαγή servers».
  3. Επικολλήστε τις ρυθμίσεις του διακομιστή MCP Loci.
  4. Αποθηκεύστε τη λίστα διακομιστών.
  5. Κάντε ανανέωση αν θέλετε να επιβεβαιώσετε ότι ο σύνδεσμος παραμένει έτοιμος για χρήση.
Ρυθμίσεις MCP του TypingMind με ενεργό διακομιστή και το κουμπί «Αλλαγή servers»
{
  "mcpServers": {
    "loci": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Χρησιμοποιήστε τη σύνδεση με διαφορετικά μοντέλα

Αποθηκεύστε τη λίστα διακομιστών, ανοίξτε τα «Πρόσθετα», ενεργοποιήστε τα εργαλεία MCP του Loci και έπειτα επιλέξτε οποιοδήποτε υποστηριζόμενο μοντέλο AI στο TypingMind. Χρησιμοποιήστε τα εργαλεία στη συνομιλία ή αναθέστε τα σε έναν πράκτορα AI.

  1. Ανοίξτε τη σελίδα «Πρόσθετα» στο TypingMind.
  2. Ενεργοποιήστε τα εργαλεία MCP του Loci.
  3. Ξεκινήστε μια συνομιλία και επιλέξτε το μοντέλο AI που θέλετε να χρησιμοποιήσετε.
  4. Χρησιμοποιήστε τα εργαλεία MCP στη συνομιλία ή αντιστοιχίστε τα σε έναν πράκτορα AI.
  5. Μεταβείτε σε άλλο μοντέλο AI όποτε χρειάζεται, χωρίς να συνδέσετε ξανά το MCP.
Συνομιλία στο TypingMind με ενεργοποιημένα εργαλεία MCP και επιλεγμένο μοντέλο AI
Θα με βοηθήσετε σε αυτό μέσω Loci;
Loci
Βεβαίως. Το διάβασα.
Δείτε τι βρήκα μέσω του Loci.

Συχνές ερωτήσεις

Σε τι χρησιμεύει ο διακομιστής MCP Loci;

Το Loci είναι ένας διακομιστής MCP που επιτρέπει σε συμβατές εφαρμογές AI να συνδέονται με εξωτερικά εργαλεία και πληροφορίες πλαισίου. Στο TypingMind, μπορείτε να προσθέσετε αυτόν τον διακομιστή MCP μία φορά και να κάνετε τα εργαλεία του διαθέσιμα στον χώρο εργασίας AI σας.

Μπορώ να χρησιμοποιήσω το Loci MCP με πολλά μοντέλα AI στο TypingMind;

Ναι. Το TypingMind συνδέει τα εργαλεία MCP σε επίπεδο χώρου εργασίας, ώστε να μπορείτε να χρησιμοποιείτε το Loci με διαφορετικά μοντέλα AI, όπως τα Claude, ChatGPT, Gemini ή άλλα μοντέλα που έχετε ρυθμίσει στο TypingMind, χωρίς να ρυθμίζετε τον διακομιστή MCP ξεχωριστά για κάθε μοντέλο.

Γιατί να χρησιμοποιήσετε τον σύνδεσμο MCP Loci με το TypingMind;

Το TypingMind είναι ένα από τα καλύτερα περιβάλλοντα συνομιλίας με μεγάλα γλωσσικά μοντέλα, καθώς συγκεντρώνει πολλά μοντέλα AI, προτροπές, πρόσθετα, πράκτορες AI, κλειδιά API και εργαλεία MCP σε έναν χώρο εργασίας. Συνδέοντας το Loci, μπορείτε να χρησιμοποιείτε τα εργαλεία MCP του με τα μοντέλα που προτιμάτε, διατηρώντας οργανωμένη τη ροή εργασίας των συνομιλιών σας στο TypingMind.

Πώς συνδέω το Loci MCP στο TypingMind;

Το Loci λειτουργεί μέσω του τοπικού συνδέσμου MCP του TypingMind. Αυτή είναι η καλύτερη επιλογή όταν ο διακομιστής MCP χρειάζεται πρόσβαση σε τοπικά αρχεία, εφαρμογές υπολογιστή, εργαλεία γραμμής εντολών ή ιδιωτικούς πόρους στον υπολογιστή σας.

Ποια εργαλεία παρέχει το Loci MCP στο TypingMind;

Το Loci διαθέτει δυνατότητες MCP που μπορείτε να ενεργοποιήσετε από τη σελίδα Πρόσθετα του TypingMind και να χρησιμοποιήσετε σε συνομιλίες ή να αναθέσετε σε πράκτορες AI.

Χρειάζεται να κοινοποιήσω τα κλειδιά API μου στο TypingMind για να χρησιμοποιήσω το Loci MCP;

Όχι. Το TypingMind δίνει προτεραιότητα στην τοπική λειτουργία και σας επιτρέπει να διατηρείτε τον έλεγχο των παρόχων μοντέλων, των κλειδιών API, των προτροπών και των ρυθμίσεων MCP σας. Αν το Loci απαιτεί έλεγχο ταυτότητας, προσθέστε τις απαιτούμενες κεφαλίδες, τις ρυθμίσεις OAuth ή τις τοπικές ρυθμίσεις για τον συγκεκριμένο διακομιστή MCP κατά τη δημιουργία της σύνδεσης.

Σχετικοί διακομιστές MCP

Προβολή όλων

Στήστε δικό σας χώρο εργασίας AI τώρα

Εγγραφείτε στο ενημερωτικό μας δελτίο για να ενημερώνεστε για νέες λειτουργίες και μελλοντικές κληρώσεις δώρων 👇