mcp-docs-rag MCP 服务器
本地目录中文档的 RAG(检索增强生成)
这是一个基于 TypeScript 的 MCP 服务器,它为存储在本地目录中的文档实现了 RAG 系统。它允许用户使用 LLM 查询本地存储库和文本文件中的文档。
特征
资源
通过
docs://URI 列出并访问文档文档可以是 Git 存储库或文本文件
用于内容访问的纯文本 MIME 类型
工具
list_documents- 列出 DOCS_PATH 目录中所有可用的文档返回所有文档的格式化列表
显示可用文档总数
rag_query- 使用 RAG 查询文档以 document_id 和 query 作为参数
返回 AI 生成的包含文档上下文的响应
add_git_repository- 使用可选的稀疏检出将 Git 存储库克隆到 docs 目录以 repository_url 作为参数
可选的 document_name 参数用于自定义文档的名称(使用不带“-docs”后缀的简单描述性名称)
用于稀疏检出特定目录的可选子目录参数
如果存储库已存在,则自动提取最新更改
add_text_file- 下载文本文件到文档目录以 file_url 作为参数
使用 wget 下载文件
提示
guide_documents_usage- 有关如何使用文档和 RAG 功能的指南包括可用文件列表
提供 RAG 功能的使用提示
发展
安装依赖项:
构建服务器:
对于使用自动重建的开发:
设置
此服务器需要一个本地目录来存储文档。默认情况下,它使用~/docs ,但您可以使用DOCS_PATH环境变量配置其他位置。
文档结构
文档目录可以包含:
Git 存储库(克隆目录)
纯文本文件(扩展名为 .txt)
每个文档都使用带有 Google Gemini 嵌入的 llama-index.ts 单独进行索引。
API 密钥
此服务器使用 Google 的 Gemini API 进行文档索引和查询。您需要将 Gemini API 密钥设置为环境变量:
您可以从Google AI Studio网站获取 Gemini API 密钥。将此密钥添加到您的 Shell 配置文件中,或将其包含在 Claude Desktop 的环境配置中。
安装
要与 Claude Desktop 一起使用,请添加服务器配置:
在 MacOS 上: ~/Library/Application Support/Claude/claude_desktop_config.json在 Windows 上: %APPDATA%/Claude/claude_desktop_config.json在 Linux 上: ~/.config/Claude/claude_desktop_config.json
确保将/Users/username/docs替换为文档目录的实际路径。
调试
由于 MCP 服务器通过 stdio 进行通信,调试起来可能比较困难。我们推荐使用MCP Inspector ,它以包脚本的形式提供:
检查器将提供一个 URL 来访问浏览器中的调试工具。
用法
配置完成后,您可以使用 Claude 服务器来执行以下操作:
添加文件:
Add a new document from GitHub: https://github.com/username/repository或使用自定义文档名称:
Add GitHub repository https://github.com/username/repository-name and name it 'framework'或者对特定目录进行稀疏检出:
Add only the 'src/components' directory from https://github.com/username/repository或者结合自定义名称和稀疏结帐:
Add the 'examples/demo' directory from https://github.com/username/large-repo and name it 'demo-app'或添加文本文件:
Add this text file: https://example.com/document.txt查询文件:
What does the documentation say about X in the Y repository?列出可用文件:
What documents do you have access to?
服务器将自动处理文档索引以实现高效检索。
Related MCP Servers
- -security-license-qualityA Model Context Protocol (MCP) server that enables LLMs to interact directly the documents that they have on-disk through agentic RAG and hybrid search in LanceDB. Ask LLMs questions about the dataset as a whole or about specific documents.Last updated -572MIT License
- Asecurity-licenseAqualityA template for creating Model Context Protocol (MCP) servers in TypeScript, offering features like container-based dependency injection, a service-based architecture, and integration with the LLM CLI for architectural design feedback through natural language.Last updated -117
- -security-license-qualityA TypeScript-based MCP server that enables users to manage text notes and generate summaries, showcasing key MCP concepts like resource representation and LLM integration.Last updated -3,063
- -security-license-qualityA customized MCP server that enables integration between LLM applications and documentation sources, providing AI-assisted access to LangGraph and Model Context Protocol documentation.Last updated -1
Appeared in Searches
- A server for searching and retrieving information using keyword, semantic, or hybrid search methods
- Semantic search, RAG, and memory systems
- Information about RAG (Retrieval-Augmented Generation) or rag-related topics
- Search for 'aperag' - unclear term or possible misspelling
- RAG MCP servers with quality validation