使用说明

项目简介

本项目是一个 MCP (Model Context Protocol) 服务器,它允许 Claude 等支持 MCP 协议的 LLM 应用访问 GitHub 代码仓库的内容。通过集成 Pera1 服务,该服务器能够从指定的 GitHub 仓库中检索代码,并将其作为上下文信息提供给 LLM,从而增强 LLM 在处理代码相关问题时的能力。

主要功能点

  • GitHub 代码检索: 可以根据 GitHub 仓库 URL 获取仓库的代码内容。
  • 文件过滤: 支持按目录路径、文件扩展名过滤检索的文件。
  • 指定分支: 可以指定要检索代码的分支。
  • 单一文件检索: 支持检索仓库中的单个文件。
  • 目录结构展示: 可以展示仓库的目录结构,仅包含目录和 README 文件。

安装步骤

由于该服务器以 npm 包的形式发布,你可以直接通过 'npx' 命令运行,无需手动安装。

服务器配置

要让 Claude 等 MCP 客户端连接到此服务器,你需要编辑 MCP 客户端的配置文件(例如 Claude Desktop 应用的 'claude_desktop_config.json')。在 'mcpServers' 中添加一个新的服务器配置,配置信息如下:

{
  "mcpServers": {
    "github": {  // 服务器名称,可以自定义,例如 "github"
      "command": "npx",  // 启动服务器的命令,这里使用 npx
      "args": ["-y", "@kazuph/mcp-github-pera1"] // 启动服务器的参数,指定要运行的 npm 包
    }
  }
}

配置参数说明:

  • 'server name': 服务器名称,例如 "github",用于在 MCP 客户端中标识和调用该服务器。
  • 'command': 启动服务器的命令,通常是 'npx' 或 'node'。
  • 'args': 传递给 'command' 的参数,用于指定要运行的服务器程序。对于 npm 包,通常使用 '["-y", "@package-name"]' 的形式。

基本使用方法

配置完成后,你就可以在 Claude 等 LLM 应用中通过提及服务器名称 (例如 "github") 并加上工具名称 (github_get_code) 来使用该 GitHub 代码检索工具。

使用示例:

  1. 查询 GitHub 仓库的实现:

    Tell me about the implementation of GitHub repository github:github_get_code?url=https://github.com/username/repository
  2. 查询特定目录下的组件:

    Explain the components in github:github_get_code?url=https://github.com/username/repository&dir=src/components
  3. 显示特定文件的内容:

    Show me the Button component from github:github_get_code?url=https://github.com/username/repository&file=src/components/Button.tsx
  4. 显示仓库的目录结构:

    Show me the structure of github:github_get_code?url=https://github.com/username/repository&mode=tree
  5. 分析特定分支的代码:

    Analyze the develop branch of github:github_get_code?url=https://github.com/username/repository&branch=develop

请将示例中的 'github' 替换为你配置的服务器名称,并根据实际需求修改 URL 和参数。

信息

分类

开发者工具