技术文档搜索服务

DevDocs MCP Server 是一个通过HTTP协议访问本地DevDocs实例的模型上下文协议(MCP)stdio进程,为AI助手如Claude提供无缝搜索和检索数百种编程语言、框架和工具的技术文档。

  • by emaland
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 emaland/devdocs-mcp

使用说明

DevDocs MCP服务器

一个模型上下文协议(MCP)stdio进程,使像Claude这样的人工智能助手能够通过HTTP访问您的本地DevDocs实例,为数百种编程语言、框架和工具的技术文档提供无缝搜索和检索。

快速开始

# Install via Homebrew
brew tap emaland/devdocs-mcp
brew install devdocs-mcp

# Start DevDocs
devdocs-mcp-start

# Configure Claude
claude mcp add --env DEVDOCS_URL=http://localhost:9292 devdocs /usr/local/bin/devdocs-mcp

# Restart Claude and start using!

建筑:这不是HTTP服务器,它是一个基于stdio的进程,使用MCP协议与Claude通信。MCP服务器连接到单独运行的DevDocs实例(通常在http://localhost:9292)获取文档。

示例用法(Claude)

在精简文档中搜索如何管理状态,并向我描述它所说的内容

⏺ 我将在Svelte文档中搜索有关状态管理的信息,并描述其内容。

⏺ devdocs-search_docs(MCP)(slug:“瘦”,query:“状态管理”) 在精简文档中找不到“状态管理”的匹配项

⏺ devdocs-search_docs(MCP)(slug:“瘦”,query:“状态”) Γ搜索“state”的结果:

 • $state [Runes] - path: `$state`
 … +1 line (ctrl+r to expand)

⏺ devdocs-get_doc_content(MCP)(slug:“svelte”,路径:“$state”,格式:“text”) Γ$state在此页面上$state$state.raw$state.snapshot将状态传递给函数跨模块传递状态$state rune允许您创建反应式st ate,这意味着你的UI在发生变化时会做出反应。 <按钮点击={()=>计数++}>点击次数:{计数} 不像 e您可能遇到的其他框架,没有API用于与状态交互-计数只是一个数字,而不是一个对象或函数 …+46行(ctrl+r可展开)

⏺ 根据Svelte文档,以下是它对状态管理的描述:

使用$State Rune进行Svelte州管理

[...]

先决条件

  1. DevDocs 在端口9292上本地运行(请参阅下面的选项)
  2. Pandoc 用于高质量的HTML到Markdown转换:
    brew install pandoc
    

DevDocs安装选项

选项1:快速启动预构建映像(多GB下载)

docker run --name devdocs -d -p 9292:9292 ghcr.io/freecodecamp/devdocs:latest

注: 这会拉取包含所有文档集(数GB)的官方DevDocs映像。

选项2:使用所选文档构建自定义图像(通过Homebrew)

如果您是通过Homebrew安装的,则可以仅使用所需的文档构建自定义DevDocs映像:

# List available documentation sets
devdocs-mcp-build --list

# Build with specific docs only
devdocs-mcp-build svelte tailwindcss react

# Or use preset collections
devdocs-mcp-build --minimal     # Just essential docs
devdocs-mcp-build --popular     # Common documentation
devdocs-mcp-build --frontend    # Frontend-focused

这种方法只使用您需要的文档集创建了一个更小的图像。

选项3:手动构建最小的DevDocs

只需您需要的文档,即可实现更小、更快的设置:

  1. 克隆DevDocs存储库:

    git clone https://github.com/freeCodeCamp/devdocs.git
    cd devdocs
    
  2. 修改DevDocs Docker文件,使其仅包含特定文档:

    # Edit the DevDocs Dockerfile and change this line:
    - RUN thor docs:download --all && \
    + RUN thor docs:download svelte tailwindcss vite && \
    

    您可以指定所需的任何文档集。热门选项包括:

    • react vue angular svelte (前端框架)
    • python javascript typescript go rust (语言)
    • django rails express fastapi (后端框架)
    • postgresql mongodb redis (数据库)
    • docker kubernetes terraform (DevOps)

    跑 thor docs:list 在DevDocs目录中查看所有可用选项。

  3. 构建自定义映像:

    # For most systems:
    docker buildx build -t devdocs:latest --load .
    
  4. 运行您的自定义DevDocs:

    docker run --name devdocs -d -p 9292:9292 devdocs:latest
    

安装

使用Homebrew(推荐)

# Install the MCP server
brew tap emaland/devdocs-mcp
brew install devdocs-mcp

# Configure Claude
claude mcp add --env DEVDOCS_URL=http://localhost:9292 devdocs /usr/local/bin/devdocs-mcp

# Test the connection (optional)
devdocs-mcp-cli list

来源

  1. 安装紫外线:

    curl -LsSf https://astral.sh/uv/install.sh | sh
    
  2. 克隆并设置项目:

    git clone https://github.com/emaland/devdocs-mcp.git
    cd devdocs-mcp
    uv sync
    
  3. 确保DevDocs正在运行 (见上述先决条件)

  4. 将MCP服务器添加到Claude:

    claude mcp add --env DEVDOCS_URL=http://localhost:9292 devdocs /path/to/devdocs-mcp/devdocs_mcp_server.py
    

可用命令(Homebrew安装)

通过Homebrew安装后,您会得到以下命令:

命令 目的
devdocs-mcp MCP服务器(由Claude自动调用)
devdocs-mcp-cli 用于测试和探索DevDocs的CLI工具
devdocs-mcp-start 启动DevDocs Docker容器
devdocs-mcp-stop 停止DevDocs Docker容器
devdocs-mcp-build 使用所选文档构建自定义DevDocs

使用Docker Compose

在Docker中运行DevDocs(MCP服务器通过Claude作为stdio进程运行):

docker-compose up -d

备注:这将在容器中启动DevDocs。MCP服务器本身作为Claude的子进程运行,而不是在Docker中运行。

CLI工具

提供了一个命令行界面,用于测试和探索MCP端点:

# If installed via Homebrew
devdocs-mcp-cli list
devdocs-mcp-cli search svelte component
devdocs-mcp-cli interactive

# Or if running from source
uv run python scripts/cli.py list

# Search in a specific documentation set
uv run python scripts/cli.py search svelte component
uv run python scripts/cli.py search tailwindcss color

# Get content from a documentation page
uv run python scripts/cli.py get svelte introduction
uv run python scripts/cli.py get tailwindcss installation

# Interactive mode for exploration
uv run python scripts/cli.py interactive

# Use different output formats
uv run python scripts/cli.py list --format json
uv run python scripts/cli.py get svelte introduction --format html

# Connect to a different DevDocs instance
uv run python scripts/cli.py --url http://localhost:3000 list

交互模式

交互模式提供了一个类似REPL的界面:

devdocs> list                    # List all documentation sets
devdocs> slugs                   # Show just the slugs for easy copying
devdocs> search svelte state     # Search for 'state' in Svelte docs
devdocs> get svelte introduction # Get content from a page
devdocs> help                    # Show available commands
devdocs> quit                    # Exit

发展

安装开发依赖项:

uv sync --group dev

运行测试:

# Run all pytest tests
uv run pytest

# Run tests with verbose output
uv run pytest -v

# Run integration tests only
uv run python tests/test_integration.py

# Run all tests including linting
uv run python scripts/test.py

代码格式:

uv run black .
uv run ruff check .

可用工具

list_docs

列出DevDocs实例中的所有可用文档集。

输出示例:

• Svelte (v5.33.11) - slug: `svelte`
• Tailwind CSS (v4.1.11) - slug: `tailwindcss`
• React - slug: `react`

search_docs

在特定文档集中搜索条目。

参数:

  • slug:文档集标识符(例如,“瘦”、“尾风css”)
  • query:搜索词以查找匹配的条目

例子:

search_docs(slug="svelte", query="component")

get_doc_content

检索特定文档页面的完整内容。

参数:

  • slug:文档集标识符
  • path:文档页面的路径
  • format:返回格式(“text”或“html”,默认为“text”)

例子:

get_doc_content(slug="svelte", path="introduction", format="text")

使用Claude Desktop

快速设置

  1. 确保DevDocs正在运行 (有关选项,请参阅上面的先决条件部分)

  2. 配置Claude桌面:

    使用Claude CLI(推荐):

    # If running from source:
    claude mcp add --env DEVDOCS_URL=http://localhost:9292 devdocs /path/to/mcp/devdocs_mcp_server.py
    
    # If installed via Homebrew:
    claude mcp add --env DEVDOCS_URL=http://localhost:9292 devdocs /usr/local/bin/devdocs-mcp
    

    或者手动编辑Claude的配置文件:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • 窗户: %APPDATA%\Claude\claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
    {
      "mcpServers": {
        "devdocs": {
          "command": "uv",
          "args": ["run", "python", "devdocs_mcp_server.py"],
          "cwd": "/path/to/devdocs/mcp",
          "env": {
            "DEVDOCS_URL": "http://localhost:9292"
          }
        }
      }
    }
    
  3. 重新启动克劳德桌面 加载MCP服务器。

看 CLAUDE_SETUP.md 有关详细的设置说明和故障排除。

环境变量

  • DEVDOCS_URL:DevDocs实例的URL(默认值:http://localhost:9292)

快速开始

# Quick setup with automatic configuration
./scripts/quick-setup.sh

# Or use the install script for more options
./scripts/install.sh

脚本

所有脚本都位于 scripts/ 目录:

  • scripts/quick-setup.sh -使用uv和Docker快速设置
  • scripts/install.sh -具有多个选项的安装向导
  • scripts/build-devdocs.sh -使用所选文档构建自定义DevDocs
  • scripts/cli.py -用于测试MCP端点的交互式CLI
  • scripts/test.py -运行所有测试,包括linting
  • scripts/dev.py -开发辅助脚本
  • scripts/update-homebrew-sha.sh -更新Homebrew配方的SHA256哈希值
  • scripts/run_mcp_server.sh -使用Docker运行MCP服务器

这 devdocs CLI包装器仍然保留,以方便访问CLI:

  • ./devdocs list -列出可用文件
  • ./devdocs search svelte component -搜索文档
  • ./devdocs interactive -交互模式

构建自定义DevDocs

您可以仅使用所需的文档构建自定义映像,而不是下载完整的多GB DevDocs映像:

# Build with specific docs
./scripts/build-devdocs.sh svelte tailwindcss react

# Build with popular documentation sets
./scripts/build-devdocs.sh --popular

# Build with frontend-focused docs
./scripts/build-devdocs.sh --frontend

# List all available documentation sets
./scripts/build-devdocs.sh --list

# Build for specific platform
./scripts/build-devdocs.sh --platform linux/arm64 python django

构建后,脚本将:

  1. 创建自定义Docker镜像(例如。, devdocs:custom)
  2. 可选更新 docker-compose.yml 使用自定义图像
  3. 允许您使用 devdocs-mcp-start 和 devdocs-mcp-stop 使用您的自定义版本

这对于以下情况特别有用:

  • 减少磁盘空间(自定义构建要小得多)
  • 更快的启动时间
  • 仅包括项目的相关文档