@devilsdev/rag-mcp-server

中文文档
3.9.1发布于 2026/11/11MITCommonJS构建来源已验证近 30 天下载 2426

An MCP server for your documents: npx @devilsdev/rag-mcp-server ./docs indexes a folder offline and serves search_documents and check_answer over stdio.

原始使用文档
文档目录7 节
  1. Connect a client
  2. Tools
  3. search_documents
  4. check_answer
  5. Files
  6. Options
  7. Build your own

@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

InputTypeDescription
querystring, requiredWhat to look for, in natural language (at most 10,000 characters, or --max-question-chars)
topKinteger, 1–20Passages 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

InputTypeDescription
answerstring, requiredThe answer to check (at most 50,000 characters)
questionstringThe question it answers; improves retrieval when sources is omitted (at most 10,000 characters)
sourcesarray of strings or { id, text }Passages to check against, at most 100, each at most 200,000 characters; omit to search the indexed documents
topKinteger, 1–20Passages 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] [--max-answer-chars <n>]
               [--max-source-chars <n>] [--max-question-chars <n>] [--max-sources <n>]
               [--max-clause-pairs <n>] [--max-sentence-source-chars <n>] [--check-timeout-ms <n>]
               [--max-concurrent-checks <n>]
OptionDefaultMeaning
--top-k <n>4Passages per call when the client doesn't pass topK
--embedder <name>localThe embedder; local (TF-IDF, offline) is the only one
--max-answer-chars <n>50000Longest answer check_answer accepts (env RAG_MCP_MAX_ANSWER_CHARS)
--max-source-chars <n>200000Longest source passage check_answer accepts (env RAG_MCP_MAX_SOURCE_CHARS)
--max-question-chars <n>10000Longest question or query (env RAG_MCP_MAX_QUESTION_CHARS)
--max-sources <n>100Most sources per check_answer call (env RAG_MCP_MAX_SOURCES)
--max-clause-pairs <n>2000000Most answer words × source clauses check_answer compares (env RAG_MCP_MAX_CLAUSE_PAIRS)
--max-sentence-source-chars <n>3000000Most answer sentences × source characters check_answer compares (env RAG_MCP_MAX_SENTENCE_SOURCE_CHARS)
--check-timeout-ms <n>10000Longest a check_answer check may run before it is stopped (env RAG_MCP_CHECK_TIMEOUT_MS)
--max-concurrent-checks <n>2Most check_answer checks run at once; up to 8 more wait (env RAG_MCP_MAX_CONCURRENT_CHECKS)

A tool call over a limit is rejected with an error that names the flag to raise it. A flag wins over its environment variable; each must be a whole number of at least 1. When you build the server in code, createServer(index, { maxAnswerChars, maxSourceChars, maxQuestionChars, maxSources, maxClausePairs, maxSentenceSourceChars, checkTimeoutMs, maxConcurrentChecks }) takes the same limits. maxClausePairs and maxSentenceSourceChars refuse input that would take long to check before checking it. Every check also runs in a worker thread, with at most 512 MB of heap, and is stopped when it runs past checkTimeoutMs; the server keeps answering other calls meanwhile. At most maxConcurrentChecks checks run at once; up to 8 more wait, and time spent waiting doesn't count toward checkTimeoutMs. A call beyond that is refused with "Too many check_answer calls waiting; try again shortly."

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/

版本与发布记录

@devilsdev/rag-mcp-server 共发布 12 个版本,首次发布于 2026/11/04;过去 12 个月发布了 12 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.9.1latest2026/11/112 天前
3.9.02026/11/103 天前
3.8.32026/11/094 天前
3.8.22026/11/094 天前
3.8.12026/11/076 天前
3.8.02026/11/067 天前

关于 @devilsdev/rag-mcp-server 的常见问题

@devilsdev/rag-mcp-server 是什么?

An MCP server for your documents: npx @devilsdev/rag-mcp-server ./docs indexes a folder offline and serves search_documents and check_answer over stdio.

如何安装 @devilsdev/rag-mcp-server?

在项目目录运行 npm install @devilsdev/rag-mcp-server,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 rag-mcp-server,可以用 npx rag-mcp-server 直接运行。

@devilsdev/rag-mcp-server 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/devilsdev__rag-mcp-server 是否存在。

@devilsdev/rag-mcp-server 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@devilsdev/rag-mcp-server 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@devilsdev/rag-mcp-server 可以商用吗?

@devilsdev/rag-mcp-server 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@devilsdev/rag-mcp-server 的下载量有多少?

根据 npm 官方下载统计,@devilsdev/rag-mcp-server 在 2026/10/12 – 2026/11/10 这 30 天内被下载 2,426 次,日均约 81 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@devilsdev/rag-mcp-server 还在维护吗?

最新版本 3.9.1 发布于 2026/11/11(2 天前);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2026/11/04。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。