create_pull_request
Create Pull Requests in Gitee repositories by specifying source and target branches, title, content, reviewers, labels, and related issues.
Instructions
在 Gitee 仓库中创建 Pull Request
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| assignees | No | Reviewers | |
| base | Yes | Target branch name | |
| body | No | Pull Request content | |
| head | Yes | Source branch name | |
| issue | No | Related issue, format: #xxx | |
| labels | No | Labels | |
| milestone_number | No | Milestone number | |
| owner | Yes | Repository owner path (enterprise, organization, or personal path) | |
| prune_source_branch | No | Whether to delete the source branch after merging | |
| repo | Yes | Repository path | |
| testers | No | Testers | |
| title | Yes | Pull Request title |
Implementation Reference
- operations/pulls.ts:107-124 (handler)The core function that implements the createPullRequest tool by validating inputs and making a POST request to the Gitee API to create a pull request.export async function createPullRequest(options: CreatePullRequestOptions) { const { owner, repo, ...rest } = options; const validatedOwner = validateOwnerName(owner); const validatedRepo = validateRepositoryName(repo); const validatedHead = validateBranchName(rest.head); const validatedBase = validateBranchName(rest.base); const url = `/repos/${validatedOwner}/${validatedRepo}/pulls`; const body = { ...rest, head: validatedHead, base: validatedBase, }; const response = await giteeRequest(url, "POST", body); return GiteePullRequestSchema.parse(response); }
- operations/pulls.ts:6-31 (schema)Zod schema defining the input parameters for creating a pull request.export const CreatePullRequestSchema = z.object({ // 仓库所属空间地址 (企业、组织或个人的地址 path) owner: z.string().describe("Repository owner path (enterprise, organization, or personal path)"), // 仓库路径 (path) repo: z.string().describe("Repository path"), // Pull Request 标题 title: z.string().describe("Pull Request title"), // 源分支的名称 head: z.string().describe("Source branch name"), // 目标分支的名称 base: z.string().describe("Target branch name"), // Pull Request 内容 body: z.string().optional().describe("Pull Request content"), // 里程碑序号 milestone_number: z.number().optional().describe("Milestone number"), // 标签 labels: z.array(z.string()).optional().describe("Labels"), // 相关的 Issue,格式为 #xxx issue: z.string().optional().describe("Related issue, format: #xxx"), // 审查人员 assignees: z.array(z.string()).optional().describe("Reviewers"), // 测试人员 testers: z.array(z.string()).optional().describe("Testers"), // 合并后是否删除源分支 prune_source_branch: z.boolean().optional().describe("Whether to delete the source branch after merging"), });
- index.ts:190-202 (registration)Registration of the 'create_pull_request' tool in the MCP server, including schema reference and handler wrapper that delegates to the pulls module.server.registerTool({ name: "create_pull_request", description: "在 Gitee 仓库中创建 Pull Request", schema: pullOperations.CreatePullRequestSchema, handler: async (params: any) => { const { owner, repo, ...rest } = params; // 确保 owner 和 repo 参数存在 if (!owner || !repo) { throw new Error("owner 和 repo 参数是必需的"); } return await pullOperations.createPullRequest({ owner, repo, ...rest }); }, });