Skip to main content
Glama
mmruesch12
by mmruesch12

create_pull_request

Generate a pull request by specifying title, description, source and target branches, and reviewers. Integrates with the azure-devops MCP Server for streamlined code collaboration.

Instructions

Create a new pull request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYesDescription of the pull request
reviewersNoArray of reviewer email addresses
sourceBranchYesSource branch name
targetBranchYesTarget branch name
titleYesTitle of the pull request

Implementation Reference

  • The core handler function for the 'create_pull_request' tool. It validates input using createPullRequestSchema, formats branch refs, calls gitClient.createPullRequest with project/repo details, and returns the created PR as JSON.
    export async function createPullRequest(rawParams: any) {
      // Parse arguments with defaults from environment variables
      const params = createPullRequestSchema.parse({
        title: rawParams.title,
        description: rawParams.description,
        sourceBranch: rawParams.sourceBranch,
        targetBranch: rawParams.targetBranch,
        reviewers: rawParams.reviewers,
        workItemIds: rawParams.workItemIds,
        isDraft: rawParams.isDraft,
      });
    
      console.error(
        "[API] Creating pull request:",
        JSON.stringify(params, null, 2)
      );
    
      try {
        // Get the Git API client
        const gitClient = await getGitClient();
    
        // Format branch names if they don't have refs/heads/ prefix
        const sourceBranch = params.sourceBranch.startsWith("refs/")
          ? params.sourceBranch
          : `refs/heads/${params.sourceBranch}`;
    
        const targetBranch = params.targetBranch.startsWith("refs/")
          ? params.targetBranch
          : `refs/heads/${params.targetBranch}`;
    
        // Create pull request
        if (!DEFAULT_PROJECT || !DEFAULT_REPOSITORY) {
          throw new Error("Default project and repository must be configured");
        }
    
        const pullRequest = await gitClient.createPullRequest(
          {
            sourceRefName: sourceBranch,
            targetRefName: targetBranch,
            title: params.title,
            description: params.description,
            reviewers: params.reviewers
              ? params.reviewers.map((email: string) => ({ id: email })) // Assuming email maps to user ID/descriptor
              : undefined,
            // Link work items if provided
            workItemRefs: params.workItemIds
              ? params.workItemIds.map((id: number) => ({
                  id: id.toString(),
                  url: `${ORG_URL}/_apis/wit/workItems/${id}`, // Construct work item URL
                }))
              : undefined,
          },
          DEFAULT_REPOSITORY,
          DEFAULT_PROJECT
        );
    
        console.error(`[API] Created pull request: ${pullRequest.pullRequestId}`);
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(pullRequest, null, 2),
            },
          ],
        };
      } catch (error) {
        logError("Error creating pull request", error);
        throw error;
      }
    }
  • Zod schema used for input validation in the createPullRequest handler. Defines required fields like title, description, branches, and optional reviewers, workItemIds.
    export const createPullRequestSchema = z.object({
      title: z.string(),
      description: z.string(),
      sourceBranch: z.string(),
      targetBranch: z.string(),
      reviewers: z.array(z.string()).optional(),
      workItemIds: z
        .array(z.number())
        .optional()
        .describe("Array of work item IDs to link"),
      isDraft: z.boolean().optional(),
    });
  • src/index.ts:81-82 (registration)
    Registration in the main MCP server request handler switch statement. Dispatches calls to the createPullRequest function.
    case "create_pull_request":
      return await createPullRequest(request.params.arguments || {});
  • Tool registration in the pullRequestTools array, providing name, description, and JSON inputSchema for the MCP listTools response.
    {
      name: "create_pull_request",
      description: "Create a new pull request",
      inputSchema: {
        type: "object",
        properties: {
          title: {
            type: "string",
            description: "Title of the pull request",
          },
          description: {
            type: "string",
            description: "Description of the pull request",
          },
          sourceBranch: {
            type: "string",
            description: "Source branch name",
          },
          targetBranch: {
            type: "string",
            description: "Target branch name",
          },
          reviewers: {
            type: "array",
            items: { type: "string" },
            description: "Array of reviewer email addresses",
          },
          workItemIds: {
            type: "array",
            items: { type: "number" },
            description: "Array of work item IDs to link",
          },
        },
        required: ["title", "description", "sourceBranch", "targetBranch"],
      },
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. 'Create a new pull request' implies a write operation, but it doesn't cover permissions needed, whether it's idempotent, error handling, or what happens on success (e.g., PR creation confirmation). This is a significant gap for a mutation tool with zero annotation coverage.

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 a single, efficient sentence with zero waste—'Create a new pull request' is front-loaded and appropriately sized for its purpose, earning full marks for conciseness and structure.

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?

Given the complexity of creating a pull request (a mutation with 5 parameters), no annotations, and no output schema, the description is incomplete. It lacks details on behavioral aspects, return values, or error cases, making it inadequate for guiding an agent effectively in this context.

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%, with all parameters documented in the schema (e.g., 'title', 'description', 'sourceBranch', 'targetBranch', 'reviewers'). The description adds no additional meaning beyond the schema, such as format examples or constraints, so it meets the baseline for high schema coverage without compensation.

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

Purpose3/5

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

The description 'Create a new pull request' clearly states the action (create) and resource (pull request), which is better than a tautology. However, it doesn't differentiate from sibling tools like 'create_pull_request_comment' or 'create_work_item' beyond the resource name, making it somewhat vague about its specific domain within the system.

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. It doesn't mention prerequisites (e.g., existing branches), exclusions, or comparisons to siblings like 'create_pull_request_comment' for adding comments or 'get_pull_request' for retrieval, leaving the agent without context for tool selection.

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

Related 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/mmruesch12/azdo-mcp'

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