Skip to main content
Glama

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
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

  • 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,
        }
      );
    }
  • 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)
    },
  • 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) }],
      };
    }

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/tuanle96/mcp-github'

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