create_pull_request
Create a new pull request in a GitHub repository to propose and merge code changes between branches.
Instructions
Create a new pull request in a GitHub repository
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| owner | Yes | Repository owner (username or organization) | |
| repo | Yes | Repository name | |
| title | Yes | Pull request title | |
| body | No | Pull request body/description | |
| head | Yes | The name of the branch where your changes are implemented | |
| base | Yes | The name of the branch you want the changes pulled into | |
| draft | No | Whether to create the pull request as a draft | |
| maintainer_can_modify | No | Whether maintainers can modify the pull request |
Implementation Reference
- operations/pulls.ts:163-177 (handler)The core handler function that executes the create_pull_request tool by making a POST request to the GitHub API to create a pull request.export async function createPullRequest( params: z.infer<typeof CreatePullRequestSchema> ): Promise<z.infer<typeof GitHubPullRequestSchema>> { const { owner, repo, ...options } = CreatePullRequestSchema.parse(params); const response = await githubRequest( `https://api.github.com/repos/${owner}/${repo}/pulls`, { method: "POST", body: options, } ); return GitHubPullRequestSchema.parse(response); }
- operations/pulls.ts:79-88 (schema)Zod schema defining the input parameters for the create_pull_request tool, used for validation.export const CreatePullRequestSchema = z.object({ owner: z.string().describe("Repository owner (username or organization)"), repo: z.string().describe("Repository name"), title: z.string().describe("Pull request title"), body: z.string().optional().describe("Pull request body/description"), head: z.string().describe("The name of the branch where your changes are implemented"), base: z.string().describe("The name of the branch you want the changes pulled into"), draft: z.boolean().optional().describe("Whether to create the pull request as a draft"), maintainer_can_modify: z.boolean().optional().describe("Whether maintainers can modify the pull request") });
- index.ts:103-107 (registration)Registration of the create_pull_request tool in the list returned by ListToolsRequestHandler, including name, description, and input schema reference.{ name: "create_pull_request", description: "Create a new pull request in a GitHub repository", inputSchema: zodToJsonSchema(pulls.CreatePullRequestSchema), },
- index.ts:276-282 (handler)Dispatch handler in the main CallToolRequestHandler switch that parses arguments and delegates to the pulls.createPullRequest implementation.case "create_pull_request": { const args = pulls.CreatePullRequestSchema.parse(request.params.arguments); const pullRequest = await pulls.createPullRequest(args); return { content: [{ type: "text", text: JSON.stringify(pullRequest, null, 2) }], }; }