English | 简体中文 | Deutsch | Español | Português (Brasil) | Français Search private documents from an MCP client or the terminal without sending them to an embedding API. mcp-local-rag indexes PDF, DOCX, Markdown, and text files on your machine.
$ npx -y skills add shinpr/mcp-local-rag --agent claude-code
Repo: shinpr/mcp-local-rag
What's inside
Search private documents from an MCP client or the terminal without sending them to an embedding API.
mcp-local-rag indexes PDF, DOCX, Markdown, and text files on your machine. Search combines semantic similarity with keyword matching, so queries can match both intent and exact technical terms such as API names, class names, and error codes.
No API key, Docker, Python, or external database is required.
Set BASE_DIR to that directory. It is also the security boundary for file operations. Replace
/absolute/path/to/your/documents below with the directory's absolute path.
mcp-local-rag uses the standard MCP protocol over a local stdio server, so it works with AI coding tools and other MCP hosts that support local MCP servers.
Use one of the examples below, or register npx -y mcp-local-rag and set BASE_DIR using your
client's MCP configuration format.
For Claude Code: Run this command:
claude mcp add local-rag --scope user --env BASE_DIR=/absolute/path/to/your/documents -- npx -y mcp-local-rag
For Codex: Add to ~/.codex/config.toml:
[mcp_servers.local-rag]
command = "npx"
args = ["-y", "mcp-local-rag"]
[mcp_servers.local-rag.env]
BASE_DIR = "/absolute/path/to/your/documents"
For OpenCode: Add to ~/.config/opencode/opencode.json (or opencode.jsonc):
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"local-rag": {
"type": "local",
"command": ["npx", "-y", "mcp-local-rag"],
"environment": {
"BASE_DIR": "/absolute/path/to/your/documents"
}
}
}
}
For Cursor: Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"local-rag": {
"command": "npx",
"args": ["-y", "mcp-local-rag"],
"env": {
"BASE_DIR": "/absolute/path/to/your/documents"
}
}
}
}
Restart the client, then ask it to build the index:
Sync all documents in the configured root and wait until it finishes.
The first sync downloads the default embedding model (about 90 MB) and may take 1–2 minutes before ingestion starts. Later runs use the local cache.
Once the sync completes:
What does the API documentation say about authentication?
To use the CLI without an MCP client:
npx mcp-local-rag ingest ./docs/
npx mcp-local-rag query "authentication API"
The CLI uses the current directory as its document root by default. Run both commands from the
same directory so they use the same default index, or set BASE_DIR and DB_PATH explicitly.
Some document sets cannot be sent to a hosted embedding service because of confidentiality or organizational policy. Keeping the index local makes them searchable without adding a per-query API cost.
Semantic search alone can miss exact identifiers that matter in technical documentation. Keyword reranking keeps those terms visible without giving up natural-language retrieval.
| Input | How to ingest |
|---|---|
| PDF, DOCX, TXT, Markdown | File ingestion or directory sync |
| HTML already fetched by the client | ingest_data; cleaned with Readability and converted to Markdown |
| Plain text or Markdown held in memory | ingest_data with a stable source identifier |
HTML fetching is not built into the server. An MCP client can fetch a page and pass its HTML to
ingest_data.
Excel, PowerPoint, standalone images, and source-code file extensions are not supported by file ingestion. PDFs can optionally use a local vision model to describe figures, but this is not OCR or image search.
| Tool | Purpose |
|---|---|
sync_start | Reconcile the index with all configured roots or one path |
sync_status | Poll a running sync job |
ingest_file | Ingest or replace one file |
ingest_data | Ingest text, Markdown, or HTML already held by the client |
query_documents | Search with semantic matching and keyword boost |
read_chunk_neighbors | Read surrounding chunks from a search result |
list_files | Show supported files and their ingestion state |
delete_file | Delete an indexed file or an ingest_data item |
status | Show index and search status |
sync_start ingests new and changed files, skips byte-identical files, and removes index entries
for files that no longer exist:
Sync everything under the configured document roots and wait for completion.
The tool returns a jobId immediately. Clients should poll sync_status until its state becomes
succeeded or failed. A changed PDF keeps the visual profile it was indexed with; sync_start
cannot change it. Set STORE_IMAGES=true in the MCP server environment to store supported PDF and
DOCX images for new or changed files selected by sync; unchanged files remain skipped.
Only one sync job is retained by the server process. A newer job replaces a finished record, and restarting the server discards it.
ingest_file accepts PDF, DOCX, TXT, and Markdown. MCP file paths must be absolute and must stay
inside a configured document root:
Ingest the document at /Users/me/docs/api-spec.pdf.
Re-ingesting the same path replaces its existing chunks.
What does the API documentation say about authentication?
Find the documented behavior of ERR_CONNECTION_REFUSED.
Results contain the text, source path, title, chunk index, relevance score, and any images stored
on that chunk. MCP returns each image as an image content block paired with its result identity;
CLI query includes an images array of { imageIndex, mimeType, data } on every result. Pass the
chunkIndex and either filePath or source from a result to read_chunk_neighbors when the
answer needs more context:
Read the surrounding chunks for that authentication result.
Both query_documents and list_files accept an optional absolute scope path prefix, or a
list of prefixes. A prefix matches the exact path and its descendants.
Use ingest_data after the MCP client fetches a page:
Fetch https://example.com/docs and ingest the HTML.
The server extracts the main article, converts it to Markdown, and stores it under the supplied source identifier. Reusing the same source updates the existing content.
Respect the source site's terms and copyright when indexing external content.
Visual mode adds a generated caption for figure-heavy PDF pages. It is opt-in and does not load a vision model during normal ingestion.
Ingest /Users/me/docs/research-paper.pdf with visual: true.
npx mcp-local-rag ingest ./docs/research-paper.pdf --visual
Image storage is independent of visual captions. Set STORE_IMAGES=true for the MCP server, or
pass --images to CLI ingestion and sync:
npx mcp-local-rag ingest ./docs/research-paper.pdf --images
npx mcp-local-rag sync ./docs/ --images
PDF storage uses detected figure/table regions. DOCX storage includes only PNG/JPEG images that
the existing Mammoth conversion emits as <img>; charts, SmartArt, and shapes are not separately
rendered. Stored images follow their surrounding text into the final semantic chunk and do not
alter ranking, scores, or result count.
visual / --visual | STORE_IMAGES / --images | PDF behavior |
|---|---|---|
| false | false | Text only; no visual captions or returned images. |
| true | false | Generated captions become searchable text; no images are stored or returned. |
| true | true | Generated captions become searchable text, and images from matched chunks are returned inline. |
| false | true | Images are attached to nearby retained PDF text and returned inline for matched chunks; the VLM is not imported, loaded, or run. |
| Profile | Model cache | Use case |
|---|---|---|
fast (default) | about 250 MB | Lightweight visual indexing |
quality | about 1.7 GB | Figures containing labels, annotations, or other in-image text |
Select the larger model with visualQuality: "quality" over MCP or
--visual-quality quality over CLI. Measured CPU inference was about three times as slow as
fast, though results depend on hardware and model updates.
quality CaptionsFrom 0.18.4 quality runs Qwen3.5-2B; earlier versions ran Qwen2.5-VL-3B. Captions already indexed
keep the wording the old model produced, and sync will not redo them, so re-ingest the files you
want refreshed:
npx mcp-local-rag ingest ./docs/research-paper.pdf --visual --visual-quality quality
Add --images if the file was ingested with it, because a run without it replaces the stored
images. The old model stays on disk. Once nothing else uses it, delete
onnx-community/Qwen2.5-VL-3B-Instruct-ONNX/ from the model cache directory — <cache-dir>, which
defaults to ./models/.
The profile a PDF was indexed with is recorded, and sync reuses it: a PDF indexed with fast or
quality is re-ingested with that same profile, and a PDF with no recorded profile is ingested as
text.
npx mcp-local-rag sync ./docs/ # keep each PDF's recorded profile
npx mcp-local-rag sync ./docs/ --visual # request fast for every PDF in scope
npx mcp-local-rag sync ./docs/ --visual --visual-quality quality
--visual overrides recorded profiles, so it also captions PDFs that were indexed as text.
Changing a profile re-ingests the PDF even when the file itself has not changed; running the same
command again does nothing and loads no model. Image settings are never recorded, so --images
and STORE_IMAGES never cause a re-ingest.
To turn captions off for a path, run ingest on it: a successful normal ingest clears the
recorded profile. To retry a page whose captioning failed, run ingest <path> --visual --visual-quality <profile> with the profile you want — a plain ingest clears it instead. If a
PDF's indexed rows disagree about the profile, sync stops before changing anything and names the
file; re-run it with --visual to settle the profile.
Claude Code can explore a codebase deeply. On non-trivial work, the harder problem is convergence.
FAQ
mcp-local-rag is a Claude Code plugin with 1 hand-picked skill for data work, indexed on Flowy. Install it with the command on its page. It includes mcp-local-rag. Its skills do not fire on their own yet. Request auto-invocation to have Flowy route them as you prompt. Free and open source.
Is this plugin yours?
Claim it with GitHubSubmit a pluginPromote it