$git clone https://github.com/shinpr/mcp-local-ragLocal RAG for developers via MCP or CLI. Semantic search with keyword boost for exact technical terms — fully private, zero setup.
| 1 | <p align="center"> |
| 2 | <img src="assets/banner.jpg" alt="MCP Local RAG — Search below the surface." width="600" /> |
| 3 | </p> |
| 4 | |
| 5 | # MCP Local RAG |
| 6 | |
| 7 | [](https://github.com/shinpr/mcp-local-rag) |
| 8 | [](https://www.npmjs.com/package/mcp-local-rag) |
| 9 | [](https://opensource.org/licenses/MIT) |
| 10 | [](https://www.typescriptlang.org/) |
| 11 | [](https://registry.modelcontextprotocol.io/) |
| 12 | |
| 13 | Local RAG for developers via MCP or CLI. |
| 14 | Semantic search with keyword boost for exact technical terms — fully private, zero setup. |
| 15 | |
| 16 | ## Features |
| 17 | |
| 18 | - **Semantic search with keyword boost** |
| 19 | Vector search first, then keyword matching boosts exact matches. Terms like `useEffect`, error codes, and class names rank higher—not just semantically guessed. |
| 20 | |
| 21 | - **Smart semantic chunking** |
| 22 | Chunks documents by meaning, not character count. Uses embedding similarity to find natural topic boundaries—keeping related content together and splitting where topics change. |
| 23 | |
| 24 | - **Quality-first result filtering** |
| 25 | Groups results by relevance gaps instead of arbitrary top-K cutoffs. Get fewer but more trustworthy chunks. |
| 26 | |
| 27 | - **Runs entirely locally** |
| 28 | No API keys, no cloud, no data leaving your machine. Works fully offline after the first model download. |
| 29 | |
| 30 | - **Zero-friction setup** |
| 31 | One `npx` command. No Docker, no Python, no servers to manage. |
| 32 | Use via MCP, CLI, or both. Optional [Agent Skills](#agent-skills) help AI assistants form better queries and interpret results. |
| 33 | |
| 34 | ## Quick Start |
| 35 | |
| 36 | Set `BASE_DIR` to the folder you want to search (or `BASE_DIRS` for multiple roots — see [Configuration](#configuration)). Documents must live under one of the configured roots. |
| 37 | |
| 38 | Add the MCP server to your AI coding tool: |
| 39 | |
| 40 | **For Cursor** — Add to `~/.cursor/mcp.json`: |
| 41 | ```json |
| 42 | { |
| 43 | "mcpServers": { |
| 44 | "local-rag": { |
| 45 | "command": "npx", |
| 46 | "args": ["-y", "mcp-local-rag"], |
| 47 | "env": { |
| 48 | "BASE_DIR": "/path/to/your/documents" |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | ``` |
| 54 | |
| 55 | **For Codex** — Add to `~/.codex/config.toml`: |
| 56 | ```toml |
| 57 | [mcp_servers.local-rag] |
| 58 | command = "npx" |
| 59 | args = ["-y", "mcp-local-rag"] |
| 60 | |
| 61 | [mcp_servers.local-rag.env] |
| 62 | BASE_DIR = "/path/to/your/documents" |
| 63 | ``` |
| 64 | |
| 65 | **For Claude Code** — Run this command: |
| 66 | ```bash |
| 67 | claude mcp add local-rag --scope user --env BASE_DIR=/path/to/your/documents -- npx -y mcp-local-rag |
| 68 | ``` |
| 69 | |
| 70 | Restart your tool, then start using it: |
| 71 | |
| 72 | ``` |
| 73 | You: "Ingest api-spec.pdf" |
| 74 | Assistant: Successfully ingested api-spec.pdf (47 chunks created) |
| 75 | |
| 76 | You: "What does the API documentation say about authentication?" |
| 77 | Assistant: Based on the documentation, authentication uses OAuth 2.0 with JWT tokens. |
| 78 | The flow is described in section 3.2... |
| 79 | ``` |
| 80 | |
| 81 | **Or use directly as CLI** — no MCP server needed: |
| 82 | |
| 83 | ```bash |
| 84 | npx mcp-local-rag ingest ./docs/ |
| 85 | npx mcp-local-rag query "authentication API" |
| 86 | ``` |
| 87 | |
| 88 | That's it. No Docker, no Python, no server setup. |
| 89 | |
| 90 | ## Why This Exists |
| 91 | |
| 92 | You want AI to search your documents—technical specs, research papers, internal docs. But most solutions send your files to external APIs. |
| 93 | |
| 94 | **Privacy.** Your documents might contain sensitive data. This runs entirely locally. |
| 95 | |
| 96 | **Cost.** External embedding APIs charge per use. This is free after the initial model download. |
| 97 | |
| 98 | **Offline.** Works without internet after setup. |
| 99 | |
| 100 | **Code search.** Pure semantic search misses exact terms like `useEffect` or `ERR_CONNECTION_REFUSED`. Keyword boost catches both meaning and exact matches. |
| 101 | |
| 102 | **Agent reality.** In practice, many AI environments mainly use tool calling. CLI support and Agent Skills make the same workflows available even without full MCP integration. |
| 103 | |
| 104 | ## Usage |
| 105 | |
| 106 | mcp-local-rag provides two interfaces: an **MCP server** for AI coding tools and a **CLI* |