Skip to content
Skillpedia
● Free and open sourceπŸ’» LocalπŸ”“ No API keyData and databases

MCP Local RAG

Lets your AI agent search your own PDF, Word, Markdown and text files locally, without sending them to an embedding API.

429 stars on GitHubby shinprLicense MITUpdated 19 days ago

How to install

This MCP is local: it runs on your computer.

It works in apps installed on your PC (Claude Desktop, Claude Code, Cursor, VS Code…). Choose your app:

Paste in the terminal:

claude mcp add local-rag -- npx -y mcp-local-rag

What to fill in

NameWhat it isRequired
BASE_DIRBase directory for document storage (defaults to current working directory). Ignored when BASE_DIRS is set.No
BASE_DIRSJSON array of base directories (e.g. '["/a","/b"]'). Takes precedence over BASE_DIR.No
IGNORE_PATHSJSON array of glob patterns for files to keep out of the index, each matched against the file's path relative to its root (e.g. '["plugs/**","**/*.draft.md"]').No
DB_PATHPath to LanceDB database directory (defaults to ./lancedb/)No
CACHE_DIRDirectory where Transformers.js models are cached (defaults to ./models/)No
HF_ENDPOINTHugging Face model download endpoint. Set this to a mirror URL when direct downloads are blocked (defaults to https://huggingface.co).No
MODEL_NAMEEmbedding model name (defaults to Xenova/all-MiniLM-L6-v2)No
MAX_FILE_SIZEMaximum file size in bytes (defaults to 104857600 / 100MB)No
RAG_MAX_DISTANCEMaximum distance threshold for filtering search results. Results with distance greater than this value will be excluded. Lower values mean stricter filtering (e.g., 0.5 for high relevance only)No
RAG_GROUPINGGrouping mode for quality filtering. 'similar' returns only the most similar group (stops at first distance jump). 'related' includes related groups (stops at second distance jump). Unset means no grouping filterNo
RAG_MAX_FILESMaximum number of files to keep in search results. Results are filtered to include only chunks from the top N best-scoring files. For example, 1 returns only the single best-matching file's chunks. Unset means no file filtering.No
CHUNK_MIN_LENGTHMinimum chunk length in characters (1-10000, defaults to 50). Chunks shorter than this threshold are filtered out during ingestion.No
STORE_IMAGESStore supported PDF and DOCX images during ingestion and return them with matched chunks (defaults to false).No
EMBED_TITLE_PREFIXEmbed each chunk together with its document title, which can help when passages don't restate the topic the title names (defaults to false). After changing it, use a new DB_PATH or delete the index and re-ingest.No
EMBED_HEADING_PREFIXAdd section headings to chunk embeddings when they fit (defaults to false). Independent of EMBED_TITLE_PREFIX. Re-ingest documents after changing it.No
RAG_DEVICEExecution device for the embedder (defaults to cpu). Passed straight to ONNX Runtime; see the Transformers.js device source for the supported backend names. If the requested device fails to initialize, the server throws an error.No
RAG_DTYPEEmbedding quantization dtype for the embedder (defaults to fp32). Opt-in and pass-through; accepts any dtype the chosen model provides (fp32, fp16, q8, int8, ...). If the model has no variant for the requested dtype, the server throws an error. Changing this changes the embedding space β€” re-ingest existing data.No
RAG_HYBRID_WEIGHTKeyword boost factor for hybrid search (0.0-1.0, defaults to 0.6). 0 means semantic similarity only; higher values increase the keyword-match contribution to the final score.No
RAG_RERANK_CMDExternal reranker command template. Use {query} and {top} for query text and result count; unset disables reranking.No
RAG_RERANK_TIMEOUT_MSTime budget per rerank call in milliseconds (100-600000, defaults to 10000). On timeout the spawned command is killed and the pre-rerank ordering is returned.No

Ready! Now test it

Restart the app and paste one of these requests in the chat:

Sync all documents in the configured folder and tell me when it finishes.
What does the API documentation say about authentication?

What it is

This server indexes documents on your machine and searches them by meaning and by exact keywords. Results include the source passage and, where available, headings, line numbers or page numbers. After the first model download, indexing and search work offline.

What it can do

  • sync_start: bring the index up to date with your folder
  • sync_status: check a running sync
  • ingest_file: add or replace one file
  • ingest_data: add text, Markdown or HTML held by the client
  • query_documents: search with meaning and keyword matching
  • read_chunk_neighbors: read text around a result
  • list_files: show files and their index state
  • delete_file: remove an indexed file

When to use

  • β€ΊWhen you want to ask questions about a folder of private documents
  • β€ΊWhen you need exact matches such as error codes or API names as well as meaning-based search
  • β€ΊWhen you want answers with page or line references so you can check the source

What you need

Node.js 22.20 or later and a folder of documents set as BASE_DIR. Internet is needed the first time to download the package and an embedding model of about 90 MB. No API key, Docker or Python.

Skills that pair well

⭐ Skillpedia MCP Β· freeYour agent finds the right skill on its ownInstall our MCP and your agent searches 15,000+ skills whenever it needs one.Install for free β†’

Frequently asked questions

Is my data sent to the cloud?

No. It does not use an embedding API, and after the model download it works offline.

Which files are supported?

PDF, DOCX, TXT and Markdown, plus HTML or text passed in by the client. Excel, PowerPoint, images and source code files are not supported.

Do I need an API key?

No. No API key, Docker, Python or external database is needed.

Is there a command line?

Yes. You can use npx mcp-local-rag ingest, query, sync, list, status and delete.

How does it limit file access?

BASE_DIR is the security boundary for file operations, and MCP file paths must be absolute and inside a configured root.

Can I change the model?

Yes, with MODEL_NAME. When you change models, build a fresh index at a new DB_PATH.

If it does not work

  • β€ΊSet BASE_DIR, DB_PATH and CACHE_DIR to absolute paths so every project does not create its own index.
  • β€ΊThe first sync can take 1 to 2 minutes while the model downloads.
  • β€ΊIf Hugging Face downloads are blocked, set HF_ENDPOINT to a mirror URL.

5 new skills a week. 1 minute to read.