article
README
🚀 GitHub MCP 服务器
GitHub MCP 服务器是一个强大的工具,它提供了命令行接口,方便用户与 GitHub API 进行交互,可完成仓库搜索、问题管理和拉取请求等操作。
🚀 快速开始
你可以按照以下步骤快速使用 GitHub MCP 服务器:
- 安装服务器。
- 进行必要的配置。
- 依据需求使用相关命令。
📦 安装指南
方式一:使用 npm 安装
npm install -g github-mcp-server
方式二:从源码安装
- 克隆仓库:
git clone https://github.com/your-username/github-mcp-server.git
cd github-mcp-server
- 安装依赖:
npm install
- 构建并安装:
npm run build && npm install -g ./dist
🛠️ 配置
- 在环境中设置 GitHub 个人访问令牌:
export GITHUB_PERSONAL_ACCESS_TOKEN=your_token_here
- 更新配置文件
config.json,添加需要的仓库信息。
💻 使用示例
基本用法
github-mcp-server --owner your_owner --repo your_repo --token your_token
选项
--owner或-o:指定仓库的所有者。--repo或-r:指定仓库的名称。--token或-t:指定 GitHub 的个人访问令牌。
工具使用示例
搜索仓库
github-mcp-server search-repositories --query your_query
参数:
--query或-q:要搜索的关键词或主题。
获取仓库信息
github-mcp-server get-repository --owner owner_name --repo repo_name
参数:
--owner或-o:仓库的所有者。--repo或-r:仓库的名称。
搜索问题
github-mcp-server search-issues --owner owner_name --repo repo_name --query your_query
参数:
--owner或-o:仓库的所有者。--repo或-r:仓库的名称。--query或-q:要搜索的问题关键字。
获取问题详情
github-mcp-server get-issue --owner owner_name --repo repo_name --issue_number issue_id
参数:
--owner或-o:仓库的所有者。--repo或-r:仓库的名称。--issue_number或-i:问题的编号。
实际使用示例
- 搜索包含 "modelcontextprotocol" 的仓库:
github-mcp-server search-repositories --query modelcontextprotocol
- 获取模型上下文协议服务器仓库的问题 739 信息:
github-mcp-server get-issue --owner modelcontextprotocol --repo servers --issue_number 739
- 获取模型上下文协议服务器仓库的拉取请求 717 信息:
github-mcp-server get-pull-request --owner modelcontextprotocol --repo servers --pull_request_number 717
🛠️ 开发指南
安装依赖
npm install
配置 GitHub 令牌
将你的 GitHub 个人访问令牌添加到 .env 文件中:
GITHUB_PERSONAL_ACCESS_TOKEN=your_token_here
启动调试模式
npm run dev
构建项目
npm run build
使用调试工具
npm run debug
微信扫一扫