Skip to main content
Glama
piyushgIITian

GitHub Enterprise MCP Server

create-pull-request

Create a new pull request in a GitHub repository by specifying the source and target branches, title, and description to propose code changes for review.

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

  • The core handler function that parses the input arguments using CreatePullRequestSchema, calls the GitHub Octokit API to create the pull request, processes the response, and handles errors with tryCatchAsync.
    export async function createPullRequest(args: unknown): Promise<any> { const { owner, repo, title, head, base, body, draft, maintainer_can_modify } = CreatePullRequestSchema.parse(args); const github = getGitHubApi(); return tryCatchAsync(async () => { const { data } = await github.getOctokit().pulls.create({ owner, repo, title, head, base, body, draft, maintainer_can_modify, }); return { id: data.id, number: data.number, title: data.title, state: data.state, user: data.user ? { login: data.user.login, id: data.user.id, } : null, created_at: data.created_at, updated_at: data.updated_at, head: { ref: data.head.ref, sha: data.head.sha, repo: data.head.repo ? { name: data.head.repo.name, full_name: data.head.repo.full_name, } : null, }, base: { ref: data.base.ref, sha: data.base.sha, repo: data.base.repo ? { name: data.base.repo.name, full_name: data.base.repo.full_name, } : null, }, body: data.body, draft: data.draft, url: data.html_url, }; }, 'Failed to create pull request'); }
  • Zod schema used for input validation in the createPullRequest handler. Extends OwnerRepoSchema with PR-specific fields.
    export const CreatePullRequestSchema = OwnerRepoSchema.extend({ title: z.string().min(1, 'Pull request title is required'), head: z.string().min(1, 'Head branch is required'), base: z.string().min(1, 'Base branch is required'), body: z.string().optional(), draft: z.boolean().optional(), maintainer_can_modify: z.boolean().optional(), });
  • src/server.ts:766-808 (registration)
    Tool registration entry in the listTools handler, defining the tool's name, description, and input schema for MCP protocol compliance.
    { name: 'create-pull-request', description: 'Create a new pull request in a GitHub repository', inputSchema: { type: 'object', properties: { owner: { type: 'string', description: 'Repository owner (username or organization)', }, repo: { type: 'string', description: 'Repository name', }, title: { type: 'string', description: 'Pull request title', }, body: { type: 'string', description: 'Pull request body/description', }, head: { type: 'string', description: 'The name of the branch where your changes are implemented', }, base: { type: 'string', description: 'The name of the branch you want the changes pulled into', }, draft: { type: 'boolean', description: 'Whether to create the pull request as a draft', }, maintainer_can_modify: { type: 'boolean', description: 'Whether maintainers can modify the pull request', }, }, required: ['owner', 'repo', 'title', 'head', 'base'], additionalProperties: false, }, },
  • Dispatch case in the CallToolRequest handler switch statement that invokes the createPullRequest function.
    case 'create-pull-request': result = await createPullRequest(parsedArgs); break;

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/piyushgIITian/github-enterprice-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server