Skip to main content
Glama

update_pull_request_branch

Synchronize a pull request branch with the latest changes from its base branch to resolve conflicts and maintain up-to-date code.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
expected_head_shaNoThe expected SHA of the pull request's HEAD ref
ownerYesRepository owner (username or organization)
pull_numberYesPull request number
repoYesRepository name

Implementation Reference

  • The core handler function that executes the GitHub API request to update the pull request branch with the latest changes.
    export async function updatePullRequestBranch( owner: string, repo: string, pullNumber: number, expectedHeadSha?: string ): Promise<void> { await githubRequest( `https://api.github.com/repos/${owner}/${repo}/pulls/${pullNumber}/update-branch`, { method: "PUT", body: expectedHeadSha ? { expected_head_sha: expectedHeadSha } : undefined, } ); }
  • Zod input schema defining parameters for the tool: owner, repo, pull_number, and optional expected_head_sha.
    export const UpdatePullRequestBranchSchema = 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"), expected_head_sha: z.string().optional().describe("The expected SHA of the pull request's HEAD ref") });
  • index.ts:185-189 (registration)
    Tool registration in the listTools response, including name, description, and input schema reference.
    { name: "update_pull_request_branch", description: "Update a pull request branch with the latest changes from the base branch", inputSchema: zodToJsonSchema(pulls.UpdatePullRequestBranchSchema) },
  • Dispatcher case in the central CallToolRequest handler that parses args and invokes the specific updatePullRequestBranch function.
    case "update_pull_request_branch": { const args = pulls.UpdatePullRequestBranchSchema.parse(request.params.arguments); const { owner, repo, pull_number, expected_head_sha } = args; await pulls.updatePullRequestBranch(owner, repo, pull_number, expected_head_sha); return { content: [{ type: "text", text: JSON.stringify({ success: true }, 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