Skip to main content
Glama

merge_pull_request

Merge a pull request in a GitHub repository by specifying the owner, repository, and pull request number, with options for commit details and merge method.

Instructions

Merge a pull request in a GitHub repository.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYesRepository owner
repoYesRepository name
pullNumberYesPull request number
commit_titleNoTitle for merge commit
commit_messageNoExtra detail for merge commit
merge_methodNoMerge method

Implementation Reference

  • The main tool definition and handler for 'merge_pull_request'. Uses octokit.rest.pulls.merge() to merge a GitHub pull request. Accepts: owner, repo, pullNumber, commit_title, commit_message, and merge_method. Returns merged status, message, and SHA.
    // Tool: Merge Pull Request
    server.tool(
    	"merge_pull_request",
    	"Merge a pull request in a GitHub repository.",
    	{
    		owner: z.string().describe("Repository owner"),
    		repo: z.string().describe("Repository name"),
    		pullNumber: z.number().describe("Pull request number"),
    		commit_title: z.string().optional().describe("Title for merge commit"),
    		commit_message: z
    			.string()
    			.optional()
    			.describe("Extra detail for merge commit"),
    		merge_method: z
    			.enum(["merge", "squash", "rebase"])
    			.optional()
    			.describe("Merge method"),
    	},
    	async ({
    		owner,
    		repo,
    		pullNumber,
    		commit_title,
    		commit_message,
    		merge_method,
    	}) => {
    		try {
    			const response = await octokit.rest.pulls.merge({
    				owner,
    				repo,
    				pull_number: pullNumber,
    				commit_title,
    				commit_message,
    				merge_method,
    			})
    			const m = response.data
    			return {
    				content: [{ type: "text", text: `PR merged successfully.\nMerged: ${m.merged}\nMessage: ${m.message}\nSHA: ${m.sha}` }],
    			}
    		} catch (e: any) {
    			return {
    				content: [{ type: "text", text: `Error: ${e.message}` }],
    			}
    		}
    	},
    )
  • Zod schema defining the input parameters for merge_pull_request: owner (string), repo (string), pullNumber (number), commit_title (optional string), commit_message (optional string), merge_method (optional enum: merge/squash/rebase).
    {
    	owner: z.string().describe("Repository owner"),
    	repo: z.string().describe("Repository name"),
    	pullNumber: z.number().describe("Pull request number"),
    	commit_title: z.string().optional().describe("Title for merge commit"),
    	commit_message: z
    		.string()
    		.optional()
    		.describe("Extra detail for merge commit"),
    	merge_method: z
    		.enum(["merge", "squash", "rebase"])
    		.optional()
    		.describe("Merge method"),
    },
  • The function 'registerPullRequestTools' is exported and registered in src/index.ts via registerPullRequestTools(server, octokit), which adds all pull request tools (including merge_pull_request) to the MCP server.
    export function registerPullRequestTools(server: McpServer, octokit: Octokit) {
  • src/index.ts:14-18 (registration)
    The function registerAllToolsAndResources calls registerPullRequestTools(server, octokit) which registers merge_pull_request (and all other PR tools) on the MCP server.
    export function registerAllToolsAndResources(server: McpServer, octokit: Octokit): void {
    	registerSearchTools(server, octokit)
    	registerIssueTools(server, octokit)
    	registerRepositoryTools(server, octokit)
    	registerPullRequestTools(server, octokit)
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided. Description only says 'Merge' with no details on side effects (e.g., closes the PR, updates branch), permissions required, or failure modes. The agent lacks critical behavioral context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, no redundant words. However, for a potentially complex action, this is slightly under-specified, but the sentence is efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With 6 parameters, 3 required, and no output schema, the description is minimal. Missing crucial information like conflict handling, mergeability checks, and result feedback.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% (all 6 parameters have descriptions). The description adds no extra meaning beyond the schema. Baseline 3 applies; no improvement or decrement.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description states 'Merge a pull request in a GitHub repository.' This is a specific action on a clear resource (pull request) that distinguishes itself from siblings like create_pull_request and update_pull_request.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool, nor any mention of prerequisites (e.g., PR must be mergeable, no pending reviews). No alternatives or exclusions are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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

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