Local Corpus Context Source
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).
What it is
Section titled “What it is”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.
Configure the source
Section titled “Configure the source”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 directorycurl -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 statuscurl http://localhost:20128/api/settings/local-corpus
# Disconnect without changing source filescurl -X DELETE http://localhost:20128/api/settings/local-corpusMCP tools
Section titled “MCP tools”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 }Safety boundaries
Section titled “Safety boundaries”- The allowlist is text-oriented:
.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. - Symlinks are skipped. Read paths are canonicalized and must remain inside the configured root; absolute paths and traversal attempts are rejected.
- Sensitive and generated directory names are excluded:
.build,.codex,.env,.git,.next,.omniroute,.ssh,coverage,dist,node_modules, andsecrets. - Default limits are 5,000 files, 1 MiB per file, 64 MiB total indexed content, approximately 4,000 characters per search chunk, and 400 lines per read.
- NUL-containing files are treated as non-text and skipped or rejected.
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.
Operational notes
Section titled “Operational notes”- Changing or deleting the configured root clears the shared in-memory index.
- A process restart discards the index; the next search rebuilds it from the configured source.
local_corpus_statusdoes not force a scan. Uselocal_corpus_searchwithrefresh: truewhen an immediate rescan is required.- Scan and read failures are counted or returned as sanitized errors; source files are never modified.
HagiCode
HagiCode is an agentic coding workspace. Rich, convenient UI interactions make planning, agent execution, and project work approachable and easy to navigate, creating an engaging development experience.
Explore an engaging development experience through rich, convenient UI interactions.
- SmartOpenSpec workflows turn intent into an executable path, from proposal to design, tasks, and a shipped change.
- EfficientMulti-agent execution keeps research, implementation, and review moving in parallel, across several repositories and the Agent CLIs you already use.
- InterestingRich, convenient UI interactions make planning, agent execution, and project work approachable and easy to navigate.
Download for Windows
Share HagiCode
Turn ideas into shipped software.
HagiCode is an agentic coding workspace. OpenSpec workflows plan the change, multi-agent execution carries it out, and Hero Scenario makes the long run visible, so ideas become shipped software.
- Smart
- OpenSpec workflows turn intent into a path from proposal to shipped change.
- Efficient
- Multi-agent execution runs research, build, and review in parallel.
- Fun
- Rich UI interactions make planning, agent work, and projects easier to follow.
© 2026 HagiCode | Powered By hagilight-starlight@0.21.0 | Branch: main | Commit: de60bcd | Built:

