Skip to main content
Glama
piyushgIITian

GitHub Enterprise MCP Server

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
NameRequiredDescriptionDefault
commit_messageNoExtra detail to append to automatic commit message
commit_titleNoTitle for the automatic commit message
merge_methodNoMerge method to use
ownerYesRepository owner (username or organization)
pull_numberYesPull request number
repoYesRepository name

Implementation Reference

  • 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,
      },
  • Dispatch case in the tool handler switch statement that calls the mergePullRequest function.
    case 'merge-pull-request':
      result = await mergePullRequest(parsedArgs);
      break;
  • 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(),
    });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/piyushgIITian/github-enterprice-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server