Skip to main content
Glama

update_pull_request_branch

Update a pull request branch to include the latest commits from its base branch, keeping the PR current.

Instructions

Update the branch of a pull request with the latest changes from the base branch

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYesRepository owner
repoYesRepository name
pullNumberYesPull request number
expectedHeadShaNoThe expected SHA of the pull request's HEAD ref

Implementation Reference

  • The async handler function that executes the 'update_pull_request_branch' tool logic. It calls octokit.rest.pulls.updateBranch with owner, repo, pull_number, and optional expected_head_sha, then returns a success message or error.
    async ({ owner, repo, pullNumber, expectedHeadSha }) => {
    	try {
    		const response = await octokit.rest.pulls.updateBranch({
    			owner,
    			repo,
    			pull_number: pullNumber,
    			...(expectedHeadSha ? { expected_head_sha: expectedHeadSha } : {}),
    		})
    
    		return {
    			content: [
    				{
    					type: "text",
    					text: `Branch updated successfully.\n\nMessage: ${response.data.message}\nURL: ${response.data.url}`,
    				},
    			],
    		}
    	} catch (e: any) {
    		return {
    			content: [{ type: "text", text: `Error: ${e.message}` }],
    		}
    	}
    },
  • Zod schema definitions for the 'update_pull_request_branch' tool's input parameters: owner (string), repo (string), pullNumber (number), and optional expectedHeadSha (string).
    {
    	owner: z.string().describe("Repository owner"),
    	repo: z.string().describe("Repository name"),
    	pullNumber: z.number().describe("Pull request number"),
    	expectedHeadSha: z
    		.string()
    		.optional()
    		.describe("The expected SHA of the pull request's HEAD ref"),
    },
  • Registration of the tool via server.tool('update_pull_request_branch', ...) within registerPullRequestTools function.
    server.tool(
    	"update_pull_request_branch",
    	"Update the branch of a pull request with the latest changes from the base branch",
    	{
    		owner: z.string().describe("Repository owner"),
    		repo: z.string().describe("Repository name"),
    		pullNumber: z.number().describe("Pull request number"),
    		expectedHeadSha: z
    			.string()
    			.optional()
    			.describe("The expected SHA of the pull request's HEAD ref"),
    	},
    	async ({ owner, repo, pullNumber, expectedHeadSha }) => {
    		try {
    			const response = await octokit.rest.pulls.updateBranch({
    				owner,
    				repo,
    				pull_number: pullNumber,
    				...(expectedHeadSha ? { expected_head_sha: expectedHeadSha } : {}),
    			})
    
    			return {
    				content: [
    					{
    						type: "text",
    						text: `Branch updated successfully.\n\nMessage: ${response.data.message}\nURL: ${response.data.url}`,
    					},
    				],
    			}
    		} catch (e: any) {
    			return {
    				content: [{ type: "text", text: `Error: ${e.message}` }],
    			}
    		}
    	},
    )
  • src/index.ts:18-18 (registration)
    Top-level registration: registerPullRequestTools(server, octokit) is called from registerAllToolsAndResources to register all pull request tools including 'update_pull_request_branch'.
    registerPullRequestTools(server, octokit)
Behavior3/5

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

No annotations are provided, so the description carries the burden. It mentions updating with latest changes but does not disclose potential issues like merge conflicts, permissions, or whether the operation is reversible. Some transparency but insufficient.

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?

The description is a single sentence with no unnecessary words. It is concise, though it could be slightly expanded for clarity without losing conciseness.

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?

The description lacks details about return values, side effects, or error conditions. For a mutation tool with no output schema, more context is needed, such as what happens on conflict or whether the PR is rebased.

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%, so baseline is 3. The description does not add meaning beyond the schema; for example, 'expectedHeadSha' remains unexplained in the description.

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?

The description clearly states the verb 'Update' and the resource 'branch of a pull request', specifying 'with the latest changes from the base branch'. It distinguishes from siblings like 'merge_pull_request' and 'create_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 explicit guidance on when to use this tool versus alternatives like 'merge_pull_request' or 'create_pull_request'. The description only states the action without context.

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