docs/frameworks/LOCAL_CORPUS_CONTEXT.md
Source of truth:
src/lib/localCorpus/index.ts(bounded text index),src/lib/localCorpus/configured.ts(configured runtime),src/lib/db/localCorpus.ts(root-path persistence),open-sse/mcp-server/tools/localCorpusTools.ts(3 read-only MCP tools), andsrc/app/api/settings/local-corpus/route.ts(settings API).
Local Corpus lets an operator expose one explicitly approved directory of text files to OmniRoute's MCP server. Files stay in their original directory: OmniRoute stores only the canonical root path in SQLite and maintains an in-memory search index. It does not copy corpus content into the repository or database.
The index refresh is incremental. Unchanged files are reused based on size and modified time, changed files are reread and hashed with SHA-256, and deleted files are removed. Search refreshes an index older than 30 seconds; callers can also request an immediate refresh.
The settings route requires the same management authentication as other settings APIs. The submitted path must already exist and must be an absolute directory path.
# Connect an approved directory
curl -X POST http://localhost:20128/api/settings/local-corpus \
-H "Content-Type: application/json" \
-d '{"rootPath":"/absolute/path/to/approved-text"}'
# Check configuration and index status
curl http://localhost:20128/api/settings/local-corpus
# Disconnect without changing source files
curl -X DELETE http://localhost:20128/api/settings/local-corpus
All three tools require read:local-corpus. Tool responses expose relative paths and
the root directory's basename, never its absolute path.
| Tool | Description |
|---|---|
local_corpus_status | Report configuration state, index size, limits, and the last refresh time |
local_corpus_search | Search indexed text and return bounded, line-scoped snippets (up to 20 results) |
local_corpus_read | Read a bounded line range from one permitted corpus-relative file |
Example MCP inputs:
{ "query": "Red River monitoring", "limit": 10, "refresh": false }
{ "relativePath": "hydrology/stations.md", "startLine": 20, "endLine": 80 }
.cfg, .csv, .geojson, .htm, .html, .ini,
.js, .json, .jsonl, .jsx, .log, .md, .mjs, .ps1, .py, .sh,
.sql, .toml, .ts, .tsx, .txt, .xml, .yaml, and .yml..build, .codex, .env,
.git, .next, .omniroute, .ssh, coverage, dist, node_modules, and
secrets.Binary documents such as PDF, DOCX, images, and archives are intentionally unsupported. Convert them to an approved text format in the configured directory before indexing.
local_corpus_status does not force a scan. Use local_corpus_search with
refresh: true when an immediate rescan is required.