zhineng.dev 工具介绍

[简体中文] | English

MCP Gitee Pull Request 服务器

一个支持多实例的 Gitee Pull Request 创建 MCP 服务器,支持自动审查、测试和合并工作流。

功能特性

安装

全局安装(推荐)

npm install -g @liangshanli/mcp-server-gitee-pull-request

本地安装

npm install @liangshanli/mcp-server-gitee-pull-request

从源码安装

git clone https://github.com/liliangshan/mcp-server-gitee-pull-request.git
cd mcp-server-gitee-pull-request
npm install

配置

设置环境变量:

# 必需:Gitee 账号凭证(使用 scope_ 前缀避免与系统环境变量冲突)
export scope_username="your-email@example.com"
export scope_password="your-password"

# 必需:OAuth 应用凭证
# 在以下地址创建 OAuth 应用:https://gitee.com/oauth/applications
export scope_client_id="your_client_id"
export scope_client_secret="your_client_secret"

# 注意:OAuth 权限范围已硬编码为 "user_info pull_requests enterprises"

# 必需:仓库所属空间地址(企业、组织或个人的地址path)
export owner="your-username-or-org"

# 必需:仓库路径(path)
export repo="your-repo-name"

# 必需:Pull Request 提交的源分支(要合并的分支)
export head="dev"

# 必需:Pull Request 提交目标分支的名称(合并到的分支)
export base="main"

# 可选:审查人员username,可多个,半角逗号分隔
export assignees="username1,username2"

# 可选:测试人员username,可多个,半角逗号分隔
export testers="tester1,tester2"

# 可选:默认标签(用逗号分开的标签)
export labels="bug,performance"

# 可选:项目名称(用于多实例支持)
export PROJECT_NAME="custom-mgit"

# 可选:自动化工作流开关
export AUTO_REVIEW="false"
export AUTO_TEST="false"
export AUTO_MERGE="false"

获取 OAuth 应用凭证

  1. 访问 Gitee OAuth 应用 创建您的应用
  2. 点击"创建应用"
  3. 填写应用信息并创建
  4. 获取 client_idclient_secret

注意:访问令牌会在需要时通过 OAuth 自动获取。

使用方法

1. 直接运行(全局安装)

mcp-server-gitee-pull-request

2. 使用 npx(推荐)

npx @liangshanli/mcp-server-gitee-pull-request

3. 直接启动(源码安装)

npm start

4. 托管启动(生产环境推荐)

npm run start-managed

编辑器集成

Cursor 编辑器配置

在项目根目录创建 .cursor/mcp.json 文件:

{
  "mcpServers": {
    "gitee-pr": {
      "command": "npx",
      "args": ["-y", "@liangshanli/mcp-server-gitee-pull-request"],
      "env": {
        "scope_username": "your-email@example.com",
        "scope_password": "your-password",
        "scope_client_id": "your_client_id",
        "scope_client_secret": "your_client_secret",
        "owner": "your-username-or-org",
        "repo": "your-repo-name",
        "head": "dev",
        "base": "main",
        "assignees": "username1,username2",
        "testers": "tester1,tester2",
        "labels": "bug,performance",
        "PROJECT_NAME": "custom-mgit",
        "AUTO_REVIEW": "false",
        "AUTO_TEST": "false",
        "AUTO_MERGE": "false"
      }
    }
  }
}

VS Code 编辑器配置

创建 .vscode/mcp.json 文件:

{
  "servers": {
    "gitee-pr": {
      "command": "npx",
      "args": ["-y", "@liangshanli/mcp-server-gitee-pull-request"],
      "env": {
        "scope_username": "your-email@example.com",
        "scope_password": "your-password",
        "scope_client_id": "your_client_id",
        "scope_client_secret": "your_client_secret",
        "owner": "your-username-or-org",
        "repo": "your-repo-name",
        "head": "dev",
        "base": "main",
        "assignees": "username1,username2",
        "testers": "tester1,tester2",
        "labels": "bug,performance",
        "PROJECT_NAME": "custom-mgit",
        "AUTO_REVIEW": "false",
        "AUTO_TEST": "false",
        "AUTO_MERGE": "false"
      }
    }
  }
}

多实例配置

您可以为不同的仓库运行多个实例。工具名称会以仓库名称作为前缀,避免冲突。

Cursor 编辑器配置

{
  "mcpServers": {
    "gitee-pr-repo1": {
      "command": "npx",
      "args": ["-y", "@liangshanli/mcp-server-gitee-pull-request"],
      "env": {
        "scope_username": "your-email@example.com",
        "scope_password": "your-password",
        "scope_client_id": "your_client_id",
        "scope_client_secret": "your_client_secret",
        "owner": "org1",
        "repo": "repo1",
        "head": "dev",
        "base": "main",
        "PROJECT_NAME": "custom-mgit",
        "AUTO_REVIEW": "true",
        "AUTO_TEST": "true",
        "AUTO_MERGE": "true"
      }
    },
    "gitee-pr-repo2": {
      "command": "npx",
      "args": ["-y", "@liangshanli/mcp-server-gitee-pull-request"],
      "env": {
        "scope_username": "your-email@example.com",
        "scope_password": "your-password",
        "scope_client_id": "your_client_id",
        "scope_client_secret": "your_client_secret",
        "owner": "org2",
        "repo": "repo2",
        "head": "dev",
        "base": "master",
        "PROJECT_NAME": "custom-mgit"
      }
    }
  }
}

VS Code 编辑器配置

{
  "servers": {
    "gitee-pr-repo1": {
      "command": "npx",
      "args": ["-y", "@liangshanli/mcp-server-gitee-pull-request"],
      "env": {
        "scope_username": "your-email@example.com",
        "scope_password": "your-password",
        "scope_client_id": "your_client_id",
        "scope_client_secret": "your_client_secret",
        "owner": "org1",
        "repo": "repo1",
        "head": "dev",
        "base": "main",
        "PROJECT_NAME": "custom-mgit",
        "AUTO_REVIEW": "true",
        "AUTO_TEST": "true",
        "AUTO_MERGE": "true"
      }
    },
    "gitee-pr-repo2": {
      "command": "npx",
      "args": ["-y", "@liangshanli/mcp-server-gitee-pull-request"],
      "env": {
        "scope_username": "your-email@example.com",
        "scope_password": "your-password",
        "scope_client_id": "your_client_id",
        "scope_client_secret": "your_client_secret",
        "owner": "org2",
        "repo": "repo2",
        "head": "dev",
        "base": "master",
        "PROJECT_NAME": "custom-mgit"
      }
    }
  }
}

可用工具

pr

在 Gitee 上创建 Pull Request。

参数:

自动化工作流:

logs

获取操作日志用于调试和监控。

参数:

日志记录

所有操作都会记录到文件中:

API 参考

此服务器使用 Gitee API v5:

更多信息,请参阅 Gitee API 文档

故障排除

常见问题

相关工具