article
README
🚀 GitHub MCP 服务器
这是一个模型上下文协议 (MCP) 服务器,为用户提供了与 GitHub API 交互的实用工具。目前,它支持依据描述、主题以及网站 URL 来创建仓库,极大地提升了仓库创建与管理的效率。
🚀 快速开始
此服务器可助力你便捷地与 GitHub API 交互,实现仓库的创建与管理。
✨ 主要特性
- 能够根据描述自动生成名称,快速创建 GitHub 仓库。
- 可轻松为仓库添加主题或标签,便于分类管理。
- 支持设置仓库主页,展示项目相关信息。
- 会自动初始化仓库,并生成 README 文件,为项目提供基础说明。
📦 安装指南
- 克隆代码库:
git clone https://github.com/your-repository.git - 安装依赖项:
npm install - 构建服务器:
npm run build
📚 详细文档
配置
该服务器需要一个具备仓库创建权限的 GitHub 个人访问令牌。请将以下内容添加到您的 MCP 设置文件中:
{
"mcpServers": {
"github": {
"command": "node",
"args": ["path/to/github-server/build/index.js"],
"env": {
"GITHUB_TOKEN": "your-github-token"
}
}
}
}
可用工具
create_repo
此工具可借助自然语言命令来创建或更新 GitHub 仓库。
命令格式
该工具支持多种自然语言命令,以执行不同操作:
- 创建仓库:
Create a repository for [描述] with tags [标签1 标签2 标签3] website [url]
或者
Make a new repository called [描述] tagged with [标签1, 标签2, 标签3]
- 更新仓库描述:
Update [owner/repo] description to [新描述]
或者
Change [repo-name] description as [新描述]
- 更新仓库标签:
Update [owner/repo] tags to [标签1 标签2 标签3]
或者
Set [repo-name] topics as [标签1, 标签2, 标签3]
- 更新仓库主页:
Update [owner/repo] website to [url]
或者
Set [repo-name] homepage as [url]
示例用法
💻 使用示例
基础用法
创建新仓库:
const result = await use_mcp_tool({
server_name: "github",
tool_name: "create_repo",
arguments: {
command: "Create a repository for my machine learning image classifier with tags python tensorflow computer-vision website https://example.com/docs"
}
});
此命令将完成以下操作:
- 创建名为 "my-machine-learning-image-classifier" 的仓库。
- 设置描述为 "my machine learning image classifier"。
- 添加 "python", "tensorflow" 和 "computer-vision" 作为仓库主题。
- 设置网站为 "https://example.com/docs"。
- 初始化并创建 README 文件。
高级用法
更新仓库描述:
const result = await use_mcp_tool({
server_name: "github",
tool_name: "create_repo",
arguments: {
command: "Update username/existing-repo description to Updated ML project for image classification"
}
});
更新仓库标签:
const result = await use_mcp_tool({
server_name: "github",
tool_name: "create_repo",
// 此处原文档未完整,推测后续为 arguments 相关内容
});
微信扫一扫