GEI迁移MCP服务器
一个模型上下文协议(MCP)服务器,封装了GitHub Enterprise Importer(GEI)API,支持自然语言驱动的存储库迁移。
特性
- GitHub→ GitHub 迁移
- Azure DevOps→ GitHub 迁移
- 通过MCP的自然语言界面
- 库存和发现工具
- 迁移跟踪和历史
- 本地(stdio) 和 远程(HTTP+SSE) 运输支援
- Azure容器应用 部署就绪
快速入门(托管服务器)
MCP服务器已部署并准备就绪,无需安装。只需将其添加到您的VS代码设置中。
1.打开MCP设置
在VS Code中,按 Ctrl+Shift+P → 首选项:打开MCP配置 (或编辑您的 mcp.json 直接)。
2.添加服务器
将以下内容合并到您的 mcp.json:
{
"servers": {
"gei-migration": {
"type": "sse",
"url": "https://gei-migration-mcp.proudgrass-ef996862.eastus.azurecontainerapps.io/sse",
"headers": {
"X-GitHub-Source-PAT": "${input:gei_github_token}",
"X-GitHub-Target-PAT": "${input:gei_target_pat}",
"X-ADO-PAT": "${input:gei_ado_pat}"
}
}
},
"inputs": [
{
"id": "gei_github_token",
"type": "promptString",
"description": "GitHub PAT for source org (needs repo, read:org scopes)",
"password": true
},
{
"id": "gei_target_pat",
"type": "promptString",
"description": "GitHub PAT for target org (needs admin:org, repo, workflow scopes)",
"password": true
},
{
"id": "gei_ado_pat",
"type": "promptString",
"description": "Azure DevOps PAT (optional — press Enter to skip if not doing ADO migrations)",
"password": true
}
]
}3.创建您的PAT
| PAT | 需要范围 | 需要时 |
|---|---|---|
| 来源GitHub PAT | repo, read:org | 始终(读取源组织) |
| 目标GitHub PAT | admin:org, repo, workflow | 始终(写入目标组织) |
| 阿多·帕特 | Code (Read), Project and Team (Read) | 仅适用于ADO→ GitHub迁移 |
注: 当服务器连接时,VS Code将提示您输入PAT。它们通过HTTP标头按会话发送,从不存储在服务器上。
4.开始使用
在代理模式下打开Copilot Chat,然后尝试:
@gei-migration list repos in github org my-source-org
@gei-migration migrate repo my-repo from my-source-org to my-target-org
@gei-migration check migration status______________________________________________________________________
可用工具
| 工具 | 说明 |
|---|---|
check_prerequisites | 验证PAT是否已配置 |
list_source_repos | 从GitHub或ADO列出存储库 |
inventory_github_org | 完整的GitHub组织目录 |
inventory_ado_org | 完整的ADO组织清单 |
find_large_repos | 查找超过大小阈值的存储库 |
find_stale_repos | 查找非活动存储库 |
migrate_repo | 开始迁移 |
get_migration_status | 检查迁移进度 |
list_active_migrations | 显示正在运行的迁移 |
wait_for_migration | 等待完成 |
abort_migration | 取消迁移 |
get_migration_history | 查看已完成的迁移 |
grant_migrator_role | 授予迁移者权限 |
export_inventory_csv | 将库存导出为CSV |
本地设置(stdio)
- 安装依赖项:
npm install- 构建:
npm run build- 添加到VS代码
mcp.json:
{
"servers": {
"gei-migration": {
"type": "stdio",
"command": "node",
"args": ["path/to/gei-migration-mcp/dist/index.js"],
"env": {
"GITHUB_TOKEN": "your-source-pat",
"GH_PAT": "your-target-pat",
"ADO_PAT": "your-ado-pat"
}
}
}
}远程设置(HTTP+SSE)
使用HTTP在本地运行
npm run build
MCP_TRANSPORT=http PORT=3000 npm start码头工人
docker build -t gei-migration-mcp .
docker run -p 3000:3000 gei-migration-mcp部署到Azure容器应用程序
# Create resource group
az group create -n gei-migration-rg -l eastus
# Deploy with Bicep (no secrets needed - users provide their own)
az deployment group create \
-g gei-migration-rg \
-f infra/main.bicep将MCP客户端连接到远程服务器
推荐:HTTP标头(安全)
使用带有VS Code输入提示的HTTP标头进行安全凭据处理:
{
"servers": {
"gei-migration": {
"type": "sse",
"url": "https://your-app.azurecontainerapps.io/sse",
"headers": {
"X-GitHub-Source-PAT": "${input:ghSourcePat}",
"X-GitHub-Target-PAT": "${input:ghTargetPat}",
"X-ADO-PAT": "${input:adoPat}"
}
}
},
"inputs": [
{ "id": "ghSourcePat", "type": "promptString", "description": "GitHub PAT for source org", "password": true },
{ "id": "ghTargetPat", "type": "promptString", "description": "GitHub PAT for target org", "password": true },
{ "id": "adoPat", "type": "promptString", "description": "Azure DevOps PAT (optional, press Enter to skip)", "password": true }
]
}这种方法:
- 运行时提示输入凭据(不存储在配置文件中)
- 通过HTTP标头发送凭据(未登录URL)
- 屏蔽输入
password: true
备选方案:查询参数
为了快速测试,凭据也可以作为查询参数传递:
{
"servers": {
"gei-migration": {
"type": "sse",
"url": "https://your-app.azurecontainerapps.io/sse?gh_source_pat=YOUR_SOURCE_PAT&gh_pat=YOUR_TARGET_PAT"
}
}
}⚠️ 警告:查询参数可能会出现在日志和浏览器历史记录中。使用标头进行生产。
标题/查询参数:
| 标题 | 查询参数 | 描述 |
|---|---|---|
X-GitHub-Source-PAT | gh_source_pat | PAT阅读源代码GitHub org |
X-GitHub-Target-PAT | gh_pat | PAT用于写入目标GitHub组织 |
X-ADO-PAT | ado_pat | Azure DevOps的PAT(可选) |
多租户支持
服务器支持多个并发用户,每个用户都有自己的凭据:
- 每个SSE连接都会创建一个隔离的会话
- 凭据按会话存储,从不共享
- 连接关闭时,会话会自动清理
- 服务器上没有存储凭据-用户提供自己的凭据
使用示例
@gei-migration check prerequisites
@gei-migration inventory github org my-source-org
@gei-migration migrate repo my-repo to target org my-target-org
@gei-migration list active migrations环境变量(本地/stdio模式)
| 变量 | 描述 | 必填 |
|---|---|---|
GITHUB_TOKEN | 源代码GitHub组织的PAT | 是 |
GH_PAT | 目标GitHub组织的PAT | 是 |
ADO_PAT | Azure DevOps的PAT | 否 |
MCP_TRANSPORT | stdio (默认)或 http | 没有 |
PORT | HTTP端口(默认值:3000) | 否 |
需要PAT范围
- 来源PAT:
repo,read:org,workflow - 目标PAT:
admin:org,repo,workflow - 阿多·帕特:完全访问或
Code (Read)
建筑
┌─────────────────────────────────────────────────────────────┐
│ MCP Client (VS Code, Claude Desktop, etc.) │
└─────────────────────┬───────────────────────────────────────┘
│ MCP Protocol (stdio or HTTP+SSE)
▼
┌─────────────────────────────────────────────────────────────┐
│ GEI Migration MCP Server │
│ ├── Tools (migrate, inventory, status, etc.) │
│ ├── Resources (active migrations, history) │
│ └── Prompts (migration planning templates) │
└─────────────────────┬───────────────────────────────────────┘
│ GraphQL / REST APIs
▼
┌─────────────────────────────────────────────────────────────┐
│ GitHub API │ Azure DevOps API │
│ (GraphQL) │ (REST) │
└─────────────────────────────────────────────────────────────┘许可证
麻省理工学院
