文档问答服务

一个基于TypeScript的MCP服务器,能够抓取网站内容并将其索引到Qdrant向量数据库中,提供对索引内容的自然语言问答功能。

  • by kazuph
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 kazuph/mcp-qdrant-docs

使用说明

mcp qdrant文档mcp服务器

模型上下文协议服务器

这是一个基于TypeScript的MCP服务器,它抓取网站内容,将其索引到Qdrant向量数据库中,并提供一个工具来回答有关索引内容的问题。

使用例

ask_hono_docs: Hono.devのドキュメント内容について質問できます
ask_reactrouter_docs: ReactRouter.comのドキュメント内容について質問できます
ask_gradio_docs: Gradio.appのLLMsドキュメントについて質問できます

特性

工具: ask_<doc name>_docs

  • 姓名: 基于以下内容动态生成 DOCS_URL 或 --start-url (例如。, ask_reactrouter_docs).
  • 功能: 允许用户就从指定网站抓取的内容提出自然语言问题。
  • 流程:
    1. 启动时(或如果 force-reindex 指定),服务器抓取目标网站。
    2. 使用句子转换模型对抓取的内容进行处理、分块和嵌入。
    3. 这些嵌入和内容块存储在特定于网站的Qdrant集合中。
    4. 当使用查询调用该工具时,服务器嵌入查询,在Qdrant中搜索相关块,并将找到的内容作为答案返回。
  • 输入: 自然语言查询(字符串)。
  • 输出: 包含在Qdrant索引中找到的相关内容块的文本。

安装

要与Claude Desktop一起使用,请添加服务器配置:

在MacOS上: ~/Library/Application Support/Claude/claude_desktop_config.json 在Windows上: %APPDATA%/Claude/claude_desktop_config.json

npm i -g @kazuph/mcp-qdrant-docs

使用 npx

运行此服务器的推荐方法是使用 npx 在您的MCP客户端配置中(例如,Claude Desktop的 claude_desktop_config.json).这避免了全局安装的需要。

示例 claude_desktop_config.json 使用 npx:

{
  "mcpServers": {
    "react-router-docs": { // A unique name for this server instance
      "command": "npx",
      "args": [
        "@kazuph/mcp-qdrant-docs", // The command registered in package.json bin
        // Optional: Add command-line arguments here if needed
        // "--start-url", "https://some-default-url.com/",
        // "--debug"
      ],
      // Optional: Set environment variables for configuration
      "env": {
        "DOCS_URL": "https://reactrouter.com/",
        "QDRANT_URL": "http://your-qdrant-instance:6333",
        "COLLECTION_NAME": "react-router-docs", // Base name for the collection
        "EMBEDDING_MODEL": "sentence-transformers/all-MiniLM-L6-v2"
        // "DEBUG": "true" // Alternative way to enable debug logging
      }
    }
    // You can add more server instances for different documentation sites here
  }
}

命令行选项

直接运行服务器时(例如,使用 npx mcp-qdrant-docs 或 npm run dev --),您可以使用以下命令行选项。如果同时设置了这两个选项,则这些选项将覆盖相应的环境变量。

  • --start-url <url> 或 -s <url>:
    • 必需(如果 DOCS_URL env-var未设置)。
    • 要抓取的网站的起始URL。
    • 覆盖 DOCS_URL 环境变量。
  • --limit <number> 或 -l <number>:
    • 要抓取的最大页数。
    • 违约: 300.
  • --match <pattern> 或 -m <pattern>:
    • URL路径模式(前缀匹配)以限制抓取。可以多次指定。
    • 例子: --match /docs/ --match /api/
    • 默认值:清除下的所有页面 start-url 域。
  • --force-reindex:
    • 强制重新抓取和重新索引,即使Qdrant集合已经存在。
    • 违约: false.
  • --collection-name <name> 或 -c <name>:
    • Qdrant集合的基名称。最终的收藏名称将是 <base_name>-<sanitized_hostname>.
    • 覆盖 COLLECTION_NAME 环境变量。
    • 违约: docs-collection.
  • --qdrant-url <url>:
    • Qdrant实例的URL。
    • 覆盖 QDRANT_URL 环境变量。
    • 违约: http://localhost:6333.
  • --embedding-model <model_name>:
    • 用于嵌入的句子转换器模型的名称(来自拥抱脸或本地)。
    • 覆盖 EMBEDDING_MODEL 环境变量。
    • 违约: Xenova/all-MiniLM-L6-v2.
  • --debug:
    • 启用详细的调试日志记录。
    • 覆盖 DEBUG 环境变量(如果设置为 true).
    • 违约: false.
  • --help 或 -h:
    • 显示列出所有选项的帮助消息。

使用命令行选项的示例:

npx @kazuph/mcp-qdrant-docs --start-url https://example-docs.com/ --collection-name my-docs --limit 50 --debug

配置优先级:

服务器使用以下优先级进行设置:

  1. 命令行参数: (例如。, --start-url, --collection-name)-最高优先级。
  2. 环境变量: (例如。, DOCS_URL, COLLECTION_NAME)-如果未提供命令行参数,则使用。
  3. 默认值: (在代码中定义)-最低优先级。

示例:添加React Router文档

要添加专门用于查询React Router文档的服务器实例,请将以下条目添加到您的 mcpServers 配置(例如 claude_desktop_config.json):

{
  "mcpServers": {
    // ... other servers ...
    "react-router-docs": {
      "command": "npx", // Or the direct path if not installed globally
      "args": [
        "@kazuph/mcp-qdrant-docs"
        // No need to specify --start-url etc. if using env vars
      ],
      "env": {
        "DOCS_URL": "https://reactrouter.com/",
        "QDRANT_URL": "http://your-qdrant-instance:6333", // Replace with your Qdrant URL
        "COLLECTION_NAME": "react-router-docs", // Base name, will become 'react-router-docs-reactrouter_com'
        "EMBEDDING_MODEL": "sentence-transformers/all-MiniLM-L6-v2" // Or your preferred model
        // "DEBUG": "true" // Enable debug logs if needed
      }
    }
    // ... other servers ...
  }
}

生成工具:

一旦此服务器实例运行并连接到您的MCP客户端,它将提供一个名为的工具,类似于 ask_reactrouter_docs (不是 ask_reactrouter_com_docs).

  • 工具名称: ask_<doc name>_docs (例如。, ask_reactrouter_docs)
  • 说明: 询问有关指定网站内容的问题 DOCS_URL (或 --start-url).
  • 输入: 关于文档的自然语言查询。

服务器将自动抓取网站(如果集合不存在或 --force-reindex 使用),将内容索引到指定的Qdrant集合中(react-router-docs-reactrouter_com 在本例中),然后使用索引通过提供的工具回答您的查询(ask_reactrouter_docs).