Skip to main content
Glama
Arcia125

Git Workflow Automation MCP Server

by Arcia125

merge_pull_request

Merge GitHub pull requests using specified methods (merge, squash, rebase) with options to delete branches and preview changes before execution.

Instructions

Merge a GitHub pull request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
prNumberYesPull request number
mergeMethodNoMerge methodmerge
deleteBranchNoDelete branch after merge
workingDirNoWorking directory path
dryRunNoPreview without executing

Implementation Reference

  • Core handler function that implements the merge_pull_request tool logic. Constructs and executes the 'gh pr merge' command with specified merge method, optional branch deletion, working directory, and dry-run support. Uses executeWithClearedTokens for secure execution with cleared GitHub tokens.
    async function mergePullRequest(
      prNumber: string,
      mergeMethod: 'merge' | 'squash' | 'rebase' = 'merge',
      deleteBranch: boolean = true,
      workingDir?: string,
      dryRun: boolean = false
    ): Promise<WorkflowResult> {
      try {
        if (dryRun) {
          return {
            success: true,
            message: "Dry run: Would merge pull request",
            details: {
              prNumber,
              mergeMethod,
              deleteBranch
            }
          };
        }
    
        // Merge PR using GitHub CLI with cleared tokens
        const mergeFlag = mergeMethod === 'squash' ? '--squash' : mergeMethod === 'rebase' ? '--rebase' : '--merge';
        const deleteFlag = deleteBranch ? '--delete-branch' : '';
        const command = `gh pr merge ${prNumber} ${mergeFlag} ${deleteFlag}`.trim();
    
        const result = await executeWithClearedTokens(command, workingDir);
    
        return {
          success: true,
          message: "Successfully merged pull request",
          details: {
            prNumber,
            mergeMethod,
            output: result.stdout
          }
        };
      } catch (error: any) {
        return {
          success: false,
          message: "Failed to merge pull request",
          error: `Failed to merge pull request: ${error.message}`
        };
      }
    }
  • Input schema defining the parameters for the merge_pull_request tool, including required prNumber and optional mergeMethod, deleteBranch, workingDir, dryRun.
      inputSchema: {
        type: "object",
        properties: {
          prNumber: {
            type: "string",
            description: "Pull request number"
          },
          mergeMethod: {
            type: "string",
            enum: ["merge", "squash", "rebase"],
            description: "Merge method",
            default: "merge"
          },
          deleteBranch: {
            type: "boolean",
            description: "Delete branch after merge",
            default: true
          },
          workingDir: {
            type: "string",
            description: "Working directory path"
          },
          dryRun: {
            type: "boolean",
            description: "Preview without executing",
            default: false
          }
        },
        required: ["prNumber"]
      }
    },
  • src/index.ts:487-520 (registration)
    Tool registration in the ListTools response, defining name, description, and input schema for merge_pull_request.
    {
      name: "merge_pull_request",
      description: "Merge a GitHub pull request",
      inputSchema: {
        type: "object",
        properties: {
          prNumber: {
            type: "string",
            description: "Pull request number"
          },
          mergeMethod: {
            type: "string",
            enum: ["merge", "squash", "rebase"],
            description: "Merge method",
            default: "merge"
          },
          deleteBranch: {
            type: "boolean",
            description: "Delete branch after merge",
            default: true
          },
          workingDir: {
            type: "string",
            description: "Working directory path"
          },
          dryRun: {
            type: "boolean",
            description: "Preview without executing",
            default: false
          }
        },
        required: ["prNumber"]
      }
    },
  • src/index.ts:606-614 (registration)
    Dispatch logic in CallToolRequest handler that maps the tool name to the mergePullRequest function call with argument extraction and type casting.
    case "merge_pull_request":
      result = await mergePullRequest(
        args?.prNumber as string,
        (args?.mergeMethod as 'merge' | 'squash' | 'rebase') || 'merge',
        (args?.deleteBranch as boolean) ?? true,
        args?.workingDir as string,
        (args?.dryRun as boolean) || false
      );
      break;
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. While 'Merge' implies a write/mutation operation, the description doesn't mention important behavioral aspects: whether this requires specific permissions, what happens on failure, if it's reversible, or any rate limits. The description is minimal and doesn't compensate for the lack of annotations.

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

Conciseness5/5

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

The description is maximally concise - a single sentence that directly states the tool's purpose. There's zero wasted language or unnecessary elaboration. It's appropriately sized for a tool with a clear, singular function.

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?

For a mutation tool with 5 parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what happens after merging, what the tool returns, error conditions, or important behavioral constraints. The combination of being a write operation with multiple parameters and no structured safety information requires more descriptive context than provided.

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?

Schema description coverage is 100%, so all parameters are documented in the schema. The description adds no additional parameter information beyond what's already in the structured schema. This meets the baseline expectation when the schema does the heavy lifting, but doesn't provide extra context about parameter interactions or usage patterns.

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

Purpose4/5

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

The description 'Merge a GitHub pull request' clearly states the verb ('Merge') and resource ('GitHub pull request'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'complete_git_workflow' or 'create_pull_request' - it's clear what it does but not how it's distinct from related operations.

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?

The description provides no guidance on when to use this tool versus alternatives. There's no mention of prerequisites (like having a pull request ready to merge), when not to use it (e.g., if there are merge conflicts), or how it relates to sibling tools like 'complete_git_workflow' which might encompass merging as part of a larger workflow.

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/Arcia125/git-workflow-mcp-server'

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