RAG for your documents
LocalAbout RAG for your documents
@devilsdev/rag-mcp-server indexes a local document folder for offline search and answer checking. It is for MCP clients that need source passages and a lexical check of whether an answer is supported, without an API key, database, or network access.
Key features
- 01Index local document folders
- 02Search passages with natural-language queries
- 03Check answers against retrieved sources
- 04Support Markdown, HTML, CSV, and text
- 05Rebuild the in-memory index at startup
Use cases
- 01Find passages in a local documentation folder
- 02Check whether an answer is supported by files
- 03Search documents without network access
MCP support
Exposes `search_documents` to retrieve passages and `check_answer` to assess whether an answer is supported by indexed documents or supplied sources. The server communicates over stdio and makes no model calls.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
Tools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project README@devilsdev/rag-mcp-server
An MCP server for your documents. Point it at a folder and Claude, or any other MCP client, can search the documents and check answers against them:
npx @devilsdev/rag-mcp-server ./docs
It indexes the folder when it starts, with the offline TF-IDF embedder and an in-memory retriever from @devilsdev/rag-pipeline-utils. It needs no API key, no database and no network. The assistant is the language model, so the server never calls one.
Requires Node.js 22 or later.
Connect a client
The server speaks MCP over stdio, so the client starts it. Use an absolute path to your folder.
Claude Code:
claude mcp add docs -- npx -y @devilsdev/rag-mcp-server /absolute/path/to/docs
Claude Desktop, Cursor and other clients that use an mcpServers config (for Claude Desktop: Settings → Developer → Edit Config, then restart):
{
"mcpServers": {
"docs": {
"command": "npx",
"args": ["-y", "@devilsdev/rag-mcp-server", "/absolute/path/to/docs"]
}
}
}
Then ask something your documents answer, such as "How many vacation days do employees get?".
Tools
search_documents
| Input | Type | Description |
|---|---|---|
query | string, required | What to look for, in natural language |
topK | integer, 1–20 | Passages to return (default 4, or --top-k) |
Returns { passages: [{ id, source, score, text }] }, best first, as structured content and as JSON text. source is the file relative to the folder and id is <source>#<chunk number>. Passages that share no terms with the query are left out.
check_answer
| Input | Type | Description |
|---|---|---|
answer | string, required | The answer to check |
question | string | The question it answers; improves retrieval when sources is omitted |
sources | array of strings or { id, text } | Passages to check against; omit to search the indexed documents |
topK | integer, 1–20 | Passages to retrieve when sources is omitted |
Runs the library's checkAnswer and returns { grounded, groundedness, unsupported, citations, sources }: whether every sentence is supported, the share of supported sentences (0 to 1), the unsupported sentences, the ids of the sources supporting each sentence, and the sources that were checked. The check is lexical and makes no model calls, so a correct paraphrase can come back unsupported; treat it as a flag to look again, not a verdict.
Both tools are read-only. Passage text is content from your files, and the tool descriptions tell the client to treat it as data, not instructions. A file can still contain text written to manipulate an assistant, so index folders you trust.
Files
Markdown (.md, .markdown), HTML (.html, .htm, visible text only), CSV (.csv, one passage per row) and text (.txt) files, in the folder and its subfolders, handled the way the library's loaders handle them; prose is split into sentence chunks of up to 500 characters. Other files, node_modules and .git are skipped. The index lives in memory and is rebuilt each time the server starts, so restart the client's server after changing the documents.
Options
rag-mcp-server <folder> [--top-k <n>] [--embedder local]
| Option | Default | Meaning |
|---|---|---|
--top-k <n> | 4 | Passages per call when the client doesn't pass topK |
--embedder <name> | local | The embedder; local (TF-IDF, offline) is the only one |
Everything the server logs goes to stderr; stdout carries the protocol.
Build your own
For other embedders (OpenAI, Ollama), a persistent index or a vector database, start from the MCP server example, which builds the same kind of server from the library in about 100 lines.
Documentation: https://devilsdev.github.io/rag-pipeline-utils/
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.