LexiconLocal
This server exposes two MCP tools that let agents search a local knowledge base and read matching documents.
Search the Lexicon: query curated project notes, in-place repo docs, and archived Claude Code / Codex / ChatGPT session transcripts.
Hybrid retrieval: combine exact lexical matching (FTS5) with semantic vector search, and see which leg matched (
fts,vector, or both).Confidence scoring: each result includes an absolute
confidencescore so you can tell whether the corpus truly covers the topic or not.Filter results: restrict by project (old/alias names resolve to current project), source type (
lexicon,repo-doc,transcript,codex-memory,claude-memory,claude-project,archive-doc), and date range (before/after).Control result count: request 1–50 results per search.
Read documents: open the full indexed document by its path, or centre on one chunk with configurable surrounding context.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@LexiconLocal search past sessions and repo docs for how we fixed the flaky test suite"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Lexicon Local
A local, offline second brain for your coding agents.
Every session you have with a coding AI — Claude Code, Codex, ChatGPT, Claude web — and every Markdown file across every repo you work on, captured automatically, indexed locally, and searchable by the next agent before it starts guessing.
"It's a second brain for my AI coding assistants — everything they and I have ever figured out gets captured automatically, and any new session can search all of it before it starts guessing."
Nothing leaves your machine. The only network call is to Ollama on localhost.
What it does
Captures — a Claude Code
SessionEndhook archives each transcript the moment a session ends; a nightly job sweeps up Codex sessions; account exports from ChatGPT and Claude web are dropped in and parsed. Your repos' own.mdfiles are indexed in place, never copied.Indexes — one SQLite file holding two search engines: FTS5 for exact words,
sqlite-vecfor meaning. Chunked, deduplicated by content hash, credentials redacted on the way in.Searches — hybrid lexical + semantic retrieval fused with reciprocal rank fusion, curated notes boosted over raw transcripts, and an absolute confidence score so an agent can tell "we have this" from "we have nothing" instead of bluffing with the least-bad match.
Serves — an MCP server any agent can call (
lexicon_search,lexicon_read), a CLI, and a read-only local web UI for you.Distils — raw transcripts are searchable from day one; curated
overview.md/decisions.md/log.mdnotes are written per project when it is worth the pass.lexicon distillranks the backlog.Watches itself — preflight proves the embedder works by actually embedding something; a weekly golden-query suite asserts search quality against the live index; a watchdog notices when the nightly job has stopped.
Related MCP server: semantic-code-intelligence
The two-repo model
This repository is the code. Your knowledge lives in a separate repo — ~/Lexicon by default — that the code manages but never owns, and that you never publish.
~/Lexicon/ # your data — a git repo with no remote
├── INDEX.md # every project: one-liner, aliases, repo path
├── config.yaml # what gets indexed
├── projects/<name>/ # curated notes: overview.md, decisions.md, log.md
├── topics/ # cross-project learnings
├── private/ # never indexed
├── archive/ # raw transcripts and exports — non-destructive, gitignored
└── index/ # the SQLite index — disposable, gitignoredThe index is derived. Delete it and lexicon index --full rebuilds it from the files. The files are the truth.
Install
Requirements: macOS or Linux, Python 3.12+, uv, and Ollama running locally.
git clone https://github.com/alexeymohr/LexiconLocal.git
cd LexiconLocal
uv sync
ollama pull nomic-embed-textFirst run
uv run lexicon init # scaffolds ~/Lexicon; prints the next steps
# edit ~/Lexicon/config.yaml: point source_roots at the directory that CONTAINS your repos
uv run lexicon preflight # proves Ollama, the model, the DB, and the registrations
uv run lexicon index --full # first index; later runs are incremental
uv run lexicon report # what got indexed, and whether the importer is healthy
uv run lexicon search "how did we handle X"Then wire up the agents:
uv run python scripts/register_mcp.py # Claude Code, Codex, Claude Desktop
./scripts/install_agents.sh # macOS: nightly capture + weekly quality guardand add the SessionEnd hook so transcripts are captured without anyone remembering to — lexicon init prints the exact JSON to paste into ~/.claude/settings.json. Finally, paste the convention block from ~/Lexicon/CONVENTION.md into each repo's CLAUDE.md or AGENTS.md so agents know to look before they leap.
Three doors
Door | For | Command |
MCP server | agents, in any repo | registered once; tools |
CLI | you, in a terminal |
|
Web UI | you, in a browser |
|
Platform honesty
The indexer, search, MCP server and web UI are portable Python and should run anywhere SQLite and Ollama do. The unattended automation is macOS-specific: the nightly and weekly jobs use launchd, notifications use osascript, and the launch-agent health check reads Background Task Management. On Linux you still get capture through the SessionEnd hook; the scheduled jobs need a cron equivalent nobody has written yet.
This has been run on exactly one machine. The first install on a second one will find something. Please open an issue when it does.
Calibration honesty
Several constants were measured, not derived — the static ranking boosts, the L2 confidence bounds, the absent-topic median threshold, the exact-scan cutoff for project-scoped vector search. They are right for the corpus they were measured on and are starting points for yours. docs/OPERATIONS.md says which ones and how to re-measure. The golden-query suite (scripts/golden_queries.py) is how you find out whether they still hold; its corpus-specific half is a YAML file you own.
Privacy
Everything local. No cloud APIs, no telemetry.
What "local" is enforced to mean. The embedding host must be loopback and is refused before a request is made; Ollama traffic sets
trust_env=False, so aHTTP_PROXYorALL_PROXYin your environment cannot route it elsewhere; and models whose tag marks them as hosted (model:cloud,model:120b-cloud) are refused. Note what that does not prove: loopback addressing means the request reaches Ollama on this machine, not that Ollama performed the inference here. For assurance beyond LexiconLocal's reach, Ollama's ownOLLAMA_NO_CLOUD=1disables its cloud features server-wide. LexiconLocal will not set it for you — your Ollama configuration is yours.private/,.envfiles, keys, and the PII files inside account exports are never indexed. Credential-shaped strings are redacted on ingest.Your data repo has no remote. This code repo is public — and ships with a leak guard (
scripts/leak_guard.py, wired in byscripts/install_hooks.sh) that derives the names of your projects from your Lexicon at commit time and refuses to let them into a commit or a push. If you contribute, install the hooks first.
Documentation
docs/ARCHITECTURE.md— the design and the reasoning behind itdocs/CONFIGURATION.md— every key inconfig.yamldocs/OPERATIONS.md— what runs unattended, what each failure means, what was calibrated
Changes
CHANGELOG.md — what changed in each release, and which changes
are breaking.
License
MIT. See LICENSE.
Available Tools
2 toolslexicon_readA
Read an indexed document, or one chunk of it with surrounding context. Use after lexicon_search to expand a promising result: pass that result's path and chunk_ord.
Inputs: path (required), chunk_ord, context_chunks. Returns: result
lexicon_searchA
Search the Lexicon: curated project notes, in-place repo documentation, and archived Claude Code / Codex / ChatGPT session transcripts. Hybrid lexical (FTS5) plus semantic (local embeddings) search. Use before re-solving a nontrivial problem to find prior work, past decisions, and approaches that already failed.
Reading the results: score is ordinal and only orders one result set against another in the same query -- it says nothing about whether the Lexicon actually covers the topic. confidence does: it is absolute, runs 0.15-1.00, and is comparable across queries. At or above 0.80 the corpus genuinely covers the point; between 0.60 and 0.80 treat the result as partial or tangential and verify before relying on it. If most results sit below that, the honest answer is that the Lexicon does not cover this -- say so instead of stretching a weak hit. matched_by shows which leg found it: fts is an exact lexical match, vector a semantic one, and both together is the strongest signal.
Inputs: query (required), after, limit, before, +2 more. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
lexicon_search and lexicon_read have clearly distinct roles: one finds relevant results across the corpus, the other expands a specific indexed document. There is no overlap or ambiguity between the two.
Both tools follow the same lexicon_ prefix with an action verb in snake_case: lexicon_search and lexicon_read. This creates a clean, predictable naming pattern.
Two tools is minimal, but for a read-only local knowledge retrieval server, search-and-read is the core interaction loop. It is slightly thin compared to typical server scopes, but each tool earns its place.
The search-to-read workflow is complete for consuming the Lexicon, including clear guidance on interpreting result confidence. Missing are corpus-level operations like listing indexed documents or ingesting new content, but those appear outside this server's stated purpose.
Maintenance
Related MCP Connectors
Private, multimodal knowledge store for agents: hybrid search with cited, provenance-backed results.
Token-efficient search for coding agents over public and private documentation.
Shared memory for coding agents. Stop re-explaining your codebase every session.
Persistent memory for AI agents. Search, store, and recall across sessions.
Related MCP Servers
- AlicenseBqualityCmaintenanceProvides local, agentic semantic recall over Claude Code session history, enabling the agent to search past discussions semantically, expand turns, and grep transcripts.513MIT
- FlicenseBqualityBmaintenanceEnables coding agents to search locally indexed repositories with hybrid semantic and lexical retrieval, returning exact source citations with file paths and line ranges.4-
- AlicenseNot gradedqualityCmaintenanceEnables searching, indexing, and recovering past AI chat sessions and agent actions from local AI coding tools, with optional vector database semantic search and direct filesystem access.-
- AlicenseNot gradedqualityDmaintenanceProvides coding agents with persistent local memory by exposing tools to save, search, and retrieve decisions, bugs, and context as Markdown with hybrid keyword and semantic search.4MIT