merge-pull-request
Merge a GitHub pull request using specified merge method (merge, squash, or rebase) with customizable commit messages for repository integration.
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
- src/tools/pull-requests.ts:243-263 (handler)The handler function that executes the merge-pull-request tool. Parses arguments using schema, calls GitHub API to merge the PR, and returns result.export async function mergePullRequest(args: unknown): Promise<any> { const { owner, repo, pull_number, commit_title, commit_message, merge_method } = MergePullRequestSchema.parse(args); const github = getGitHubApi(); return tryCatchAsync(async () => { const { data } = await github.getOctokit().pulls.merge({ owner, repo, pull_number, commit_title, commit_message, merge_method, }); return { merged: data.merged, message: data.message, sha: data.sha, }; }, 'Failed to merge pull request'); }
- src/server.ts:868-902 (registration)Tool registration in the MCP server, defining name, description, and input schema.{ name: 'merge-pull-request', description: 'Merge a pull request', inputSchema: { type: 'object', properties: { owner: { type: 'string', description: 'Repository owner (username or organization)', }, repo: { type: 'string', description: 'Repository name', }, pull_number: { type: 'number', description: 'Pull request number', }, commit_title: { type: 'string', description: 'Title for the automatic commit message', }, commit_message: { type: 'string', description: 'Extra detail to append to automatic commit message', }, merge_method: { type: 'string', enum: ['merge', 'squash', 'rebase'], description: 'Merge method to use', }, }, required: ['owner', 'repo', 'pull_number'], additionalProperties: false, },
- src/server.ts:1238-1240 (registration)Dispatch case in the tool handler switch statement that calls the mergePullRequest function.case 'merge-pull-request': result = await mergePullRequest(parsedArgs); break;
- src/utils/validation.ts:154-159 (schema)Zod schema definition for validating inputs to the merge-pull-request tool, extended from OwnerRepoSchema.export const MergePullRequestSchema = OwnerRepoSchema.extend({ pull_number: z.number().int().positive(), commit_title: z.string().optional(), commit_message: z.string().optional(), merge_method: z.enum(['merge', 'squash', 'rebase']).optional(), });