Skip to main content
Glama

github_create_pr

Create a pull request on GitHub with title, body, base, and head branches. Optionally specify the repository path.

Instructions

Create a pull request on GitHub

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesPull request title
bodyYesPull request body
baseYesBase branch
headYesHead branch
pathNoRepository path (optional, defaults to current directory)

Implementation Reference

  • Main handler for github_create_pr tool. Calls gitService.createPullRequest with title, body, base, head args and returns JSON result.
    protected async executeCommand(context: CommandContext): Promise<CommandResult> {
      try {
        const gitService = context.container.getService<GitService>('gitService');
        const pr = await gitService.createPullRequest({
          title: context.args.title as string,
          body: context.args.body as string,
          base: context.args.base as string,
          head: context.args.head as string,
          ...context.args
        });
    
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              message: 'Pull request created successfully',
              result: pr
            }, null, 2)
          }]
        };
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `Failed to create pull request: ${error instanceof Error ? error.message : String(error)}`
          }]
        };
      }
    }
  • Alternative legacy handler for github_create_pr tool. Uses GitIntegration directly via gh CLI to create a pull request.
    export class GitHubCreatePRCommand extends Command {
      readonly name = 'github_create_pr';
      readonly description = 'Create a pull request';
      readonly inputSchema: Tool['inputSchema'] = {
        type: 'object',
        properties: {
          title: { type: 'string', description: 'PR title' },
          body: { type: 'string', description: 'PR description' },
          base: { type: 'string', description: 'Base branch (optional)' },
          path: { type: 'string', description: 'Repository path (optional, defaults to current directory)' }
        },
        required: ['title']
      };
    
      protected validateArgs(args: Record<string, any>): void {
        this.assertString(args.title, 'title');
        if (args.body !== undefined) {
          this.assertString(args.body, 'body');
        }
        if (args.base !== undefined) {
          this.assertString(args.base, 'base');
        }
        if (args.path !== undefined) {
          this.assertString(args.path, 'path');
        }
      }
    
      protected async executeCommand(context: CommandContext): Promise<CommandResult> {
        const { title, body, base, path } = context.args;
        const git = new GitIntegration(path);
        
        if (!await git.hasGitHubCLI()) {
          throw new Error('GitHub CLI (gh) is not installed. Please install it first: https://cli.github.com');
        }
        
        const prUrl = await git.createPullRequest(title, body, base);
        
        return {
          content: [{
            type: 'text',
            text: `Pull request created: ${prUrl}`
          }]
        };
      }
    }
  • PullRequest interface definition and GitHubIntegration.createPullRequest method that builds and executes gh pr create command.
    export interface PullRequest {
      title: string;
      body?: string;
      base?: string;
      head?: string;
    }
    
    export class GitHubIntegration {
      private async executeCommand(command: string): Promise<string> {
        try {
          const { stdout } = await execAsync(command);
          return stdout.trim();
        } catch (error: any) {
          throw new Error(`GitHub CLI command failed: ${error.message}`);
        }
      }
    
      async createPullRequest(options: PullRequest): Promise<string> {
        let command = `gh pr create --title "${options.title}"`;
        
        if (options.body) {
          command += ` --body "${options.body}"`;
        }
        
        if (options.base) {
          command += ` --base ${options.base}`;
        }
        
        if (options.head) {
          command += ` --head ${options.head}`;
        }
        
        return this.executeCommand(command);
  • GitService.createPullRequest delegates to GitHubIntegration.createPullRequest, the service-layer implementation.
    async createPullRequest(options: PullRequest): Promise<string> {
      if (!this.github) {
        throw new Error('GitHub integration not available');
      }
      return this.github.createPullRequest(options);
  • Registration of GitHubCreatePRCommand in the core command registry via registerMany.
    new GitHubCreatePRCommand(),
    new GitCloneCommand()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, and the description does not disclose behavioral traits such as what happens if a PR already exists, whether it requires authentication, or side effects like triggering CI checks.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence with no unnecessary words, but it could be slightly expanded without losing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description lacks information about return values (e.g., PR URL), does not explain the optional path parameter's meaning, and misses context compared to sibling tools like git_push and git_commit.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% coverage with clear descriptions for each parameter. The description adds no additional semantic value beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create') and the resource ('a pull request on GitHub'), making it distinct from sibling tools like git_push or git_commit.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives such as git_push or git_commit, nor any prerequisites like having a remote or branch existence.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/proofmath-owner/ai-filesystem-mcp'

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