MCP Docs RAG Server

by kazuph
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Allows cloning and pulling from Git repositories to store them as local documents for RAG queries

  • Enables retrieving repositories from GitHub to be used as document sources for RAG queries

  • Uses Google's Gemini API for document indexing and embedding generation for RAG functionality

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 功能的使用提示

发展

安装依赖项:

npm install

构建服务器:

npm run build

对于使用自动重建的开发:

npm run watch

设置

此服务器需要一个本地目录来存储文档。默认情况下,它使用~/docs ,但您可以使用DOCS_PATH环境变量配置其他位置。

文档结构

文档目录可以包含:

  • Git 存储库(克隆目录)
  • 纯文本文件(扩展名为 .txt)

每个文档都使用带有 Google Gemini 嵌入的 llama-index.ts 单独进行索引。

API 密钥

此服务器使用 Google 的 Gemini API 进行文档索引和查询。您需要将 Gemini API 密钥设置为环境变量:

export GEMINI_API_KEY=your-api-key-here

您可以从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

{ "mcpServers": { "docs-rag": { "command": "npx", "args": ["-y", "@kazuph/mcp-docs-rag"], "env": { "DOCS_PATH": "/Users/username/docs", "GEMINI_API_KEY": "your-api-key-here" } } } }

确保将/Users/username/docs替换为文档目录的实际路径。

调试

由于 MCP 服务器通过 stdio 进行通信,调试起来可能比较困难。我们推荐使用MCP Inspector ,它以包脚本的形式提供:

npm run inspector

检查器将提供一个 URL 来访问浏览器中的调试工具。

用法

配置完成后,您可以使用 Claude 服务器来执行以下操作:

  1. 添加文件
    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
  2. 查询文件
    What does the documentation say about X in the Y repository?
  3. 列出可用文件
    What documents do you have access to?

服务器将自动处理文档索引以实现高效检索。

-
security - not tested
F
license - not found
-
quality - not tested

TypeScript MCP 服务器允许通过 RAG(检索增强生成)系统使用具有上下文的 LLM 从本地存储的存储库和文本文件中查询文档。

  1. Features
    1. Resources
    2. Tools
    3. Prompts
  2. Development
    1. Setup
      1. Document Structure
      2. API Keys
    2. Installation
      1. Debugging
    3. Usage
      ID: sibd142gk0