Skip to main content
Glama

create_pull_request

Automates GitHub pull request creation by specifying repository owner, repo name, title, branch details, and optional draft or maintainer permissions. Simplifies code collaboration workflows.

Instructions

Create a new pull request in a GitHub repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
baseYesThe name of the branch you want the changes pulled into
bodyNoPull request body/description
draftNoWhether to create the pull request as a draft
headYesThe name of the branch where your changes are implemented
maintainer_can_modifyNoWhether maintainers can modify the pull request
ownerYesRepository owner (username or organization)
repoYesRepository name
titleYesPull request title

Implementation Reference

  • Handler for the create_pull_request tool: parses input arguments using the schema and delegates to the createPullRequest function in pulls module, returning the result as text content.
    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) }], }; }
  • Zod schema defining the input parameters for creating a pull request, used for validation in both registration and handler.
    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:100-104 (registration)
    Tool registration in the ListTools handler, specifying name, description, and input schema.
    { name: "create_pull_request", description: "Create a new pull request in a GitHub repository", inputSchema: zodToJsonSchema(pulls.CreatePullRequestSchema), },
  • Core implementation function that makes the GitHub API POST request to create the pull request and parses the response.
    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); }

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