merge_pull_request
Merge a pull request on GitHub by specifying the repository owner, repo name, pull request number, commit details, and merge method.
Instructions
Merge a pull request
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| commit_message | No | Extra detail to append to automatic commit message | |
| commit_title | No | Title for the automatic commit message | |
| merge_method | No | Merge method to use | |
| owner | Yes | Repository owner (username or organization) | |
| pull_number | Yes | Pull request number | |
| repo | Yes | Repository name |
Implementation Reference
- operations/pulls.ts:225-238 (handler)Core handler function that executes the GitHub API PUT request to merge the specified pull request.export async function mergePullRequest( owner: string, repo: string, pullNumber: number, options: Omit<z.infer<typeof MergePullRequestSchema>, 'owner' | 'repo' | 'pull_number'> ): Promise<any> { return githubRequest( `https://api.github.com/repos/${owner}/${repo}/pulls/${pullNumber}/merge`, { method: 'PUT', body: options, } ); }
- operations/pulls.ts:122-129 (schema)Zod input schema defining parameters for the merge_pull_request tool.export const MergePullRequestSchema = z.object({ owner: z.string().describe("Repository owner (username or organization)"), repo: z.string().describe("Repository name"), pull_number: z.number().describe("Pull request number"), commit_title: z.string().optional().describe("Title for the automatic commit message"), commit_message: z.string().optional().describe("Extra detail to append to automatic commit message"), merge_method: z.enum(['merge', 'squash', 'rebase']).optional().describe("Merge method to use") });
- index.ts:170-174 (registration)Registration of the merge_pull_request tool in the MCP server's list of tools.{ name: "merge_pull_request", description: "Merge a pull request", inputSchema: zodToJsonSchema(pulls.MergePullRequestSchema) },
- index.ts:524-531 (handler)Dispatch handler in the main tool request switch statement that parses arguments and invokes the mergePullRequest function.case "merge_pull_request": { const args = pulls.MergePullRequestSchema.parse(request.params.arguments); const { owner, repo, pull_number, ...options } = args; const result = await pulls.mergePullRequest(owner, repo, pull_number, options); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }