update_pull_request
Modify an existing pull request's title, description, state, base branch, or maintainer edit permission.
Instructions
Update an existing pull request in a GitHub repository.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | Repository owner | |
| repo | Yes | Repository name | |
| pullNumber | Yes | Pull request number to update | |
| title | No | New title | |
| body | No | New description | |
| state | No | New state | |
| base | No | New base branch name | |
| maintainer_can_modify | No | Allow maintainer edits |
Implementation Reference
- src/tools/pullrequests.ts:5-5 (registration)The function registerPullRequestTools is exported and registers all PR tools on the MCP server.
export function registerPullRequestTools(server: McpServer, octokit: Octokit) { - src/index.ts:5-5 (registration)Import of registerPullRequestTools from the pullrequests module.
import { registerPullRequestTools } from "./tools/pullrequests.js" - src/index.ts:18-18 (registration)Registration call to registerPullRequestTools which registers all PR tools including update_pull_request.
registerPullRequestTools(server, octokit) - src/tools/pullrequests.ts:47-95 (handler)Full implementation of the 'update_pull_request' tool: registers the tool with schema (owner, repo, pullNumber, optional title/body/state/base/maintainer_can_modify) and handler that calls octokit.rest.pulls.update.
// Tool: Update Pull Request server.tool( "update_pull_request", "Update an existing 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 to update"), title: z.string().optional().describe("New title"), body: z.string().optional().describe("New description"), state: z.enum(["open", "closed"]).optional().describe("New state"), base: z.string().optional().describe("New base branch name"), maintainer_can_modify: z .boolean() .optional() .describe("Allow maintainer edits"), }, async ({ owner, repo, pullNumber, title, body, state, base, maintainer_can_modify, }) => { try { const response = await octokit.rest.pulls.update({ owner, repo, pull_number: pullNumber, title, body, state, base, maintainer_can_modify, }) const pr = response.data return { content: [{ type: "text", text: `PR updated: **#${pr.number}: ${pr.title}**\nState: ${pr.state}\nURL: ${pr.html_url}\nUpdated: ${pr.updated_at}` }], } } catch (e: any) { return { content: [{ type: "text", text: `Error: ${e.message}` }], } } }, ) - src/tools/pullrequests.ts:51-63 (schema)Input schema for update_pull_request using Zod: owner (string), repo (string), pullNumber (number), title (optional string), body (optional string), state (optional enum open/closed), base (optional string), maintainer_can_modify (optional boolean).
{ owner: z.string().describe("Repository owner"), repo: z.string().describe("Repository name"), pullNumber: z.number().describe("Pull request number to update"), title: z.string().optional().describe("New title"), body: z.string().optional().describe("New description"), state: z.enum(["open", "closed"]).optional().describe("New state"), base: z.string().optional().describe("New base branch name"), maintainer_can_modify: z .boolean() .optional() .describe("Allow maintainer edits"), },