Skip to main content
Glama
Tiberriver256

Azure DevOps MCP Server

create_pull_request

Create pull requests in Azure DevOps with reviewers, linked work items, and optional tags to manage code changes and collaboration.

Instructions

Create a new pull request, including reviewers, linked work items, and optional tags

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdNoThe ID or name of the project (Default: MyProject)
organizationIdNoThe ID or name of the organization (Default: mycompany)
repositoryIdYesThe ID or name of the repository
titleYesThe title of the pull request
descriptionNoThe description of the pull request (markdown is supported)
sourceRefNameYesThe source branch name (e.g., refs/heads/feature-branch)
targetRefNameYesThe target branch name (e.g., refs/heads/main)
reviewersNoList of reviewer email addresses or IDs
isDraftNoWhether the pull request should be created as a draft
workItemRefsNoList of work item IDs to link to the pull request
tagsNoList of tags to apply to the pull request
additionalPropertiesNoAdditional properties to set on the pull request

Implementation Reference

  • Core handler function that executes the create pull request logic using Azure DevOps Git API, including input validation, tag normalization, PR creation, and label application.
    export async function createPullRequest(
      connection: WebApi,
      projectId: string,
      repositoryId: string,
      options: CreatePullRequestOptions,
    ): Promise<PullRequest> {
      try {
        if (!options.title) {
          throw new Error('Title is required');
        }
    
        if (!options.sourceRefName) {
          throw new Error('Source branch is required');
        }
    
        if (!options.targetRefName) {
          throw new Error('Target branch is required');
        }
    
        const gitApi = await connection.getGitApi();
    
        const normalizedTags = normalizeTags(options.tags);
    
        // Create the pull request object
        const pullRequest: PullRequest = {
          title: options.title,
          description: options.description,
          sourceRefName: options.sourceRefName,
          targetRefName: options.targetRefName,
          isDraft: options.isDraft || false,
          workItemRefs: options.workItemRefs?.map((id) => ({
            id: id.toString(),
          })),
          reviewers: options.reviewers?.map((reviewer) => ({
            id: reviewer,
            isRequired: true,
          })),
        };
    
        if (options.additionalProperties) {
          Object.assign(pullRequest, options.additionalProperties);
        }
    
        if (normalizedTags.length > 0) {
          pullRequest.labels = normalizedTags.map((tag) => ({ name: tag }));
        }
    
        // Create the pull request
        const createdPullRequest = await gitApi.createPullRequest(
          pullRequest,
          repositoryId,
          projectId,
        );
    
        if (!createdPullRequest) {
          throw new Error('Failed to create pull request');
        }
    
        if (normalizedTags.length > 0) {
          const pullRequestId = createdPullRequest.pullRequestId;
    
          if (!pullRequestId) {
            throw new Error('Pull request created without identifier for tagging');
          }
    
          const existing = new Set(
            (createdPullRequest.labels ?? [])
              .map((label) => label.name?.toLowerCase())
              .filter((name): name is string => Boolean(name)),
          );
    
          const tagsToCreate = normalizedTags.filter(
            (tag) => !existing.has(tag.toLowerCase()),
          );
    
          if (tagsToCreate.length > 0) {
            const createdLabels = await Promise.all(
              tagsToCreate.map((tag) =>
                gitApi.createPullRequestLabel(
                  { name: tag },
                  repositoryId,
                  pullRequestId,
                  projectId,
                ),
              ),
            );
    
            createdPullRequest.labels = [
              ...(createdPullRequest.labels ?? []),
              ...createdLabels,
            ];
          }
        }
    
        return createdPullRequest;
      } catch (error) {
        if (error instanceof AzureDevOpsError) {
          throw error;
        }
        throw new Error(
          `Failed to create pull request: ${error instanceof Error ? error.message : String(error)}`,
        );
      }
    }
  • Request handler registration that routes 'create_pull_request' tool calls, parses arguments with schema, invokes the handler, and formats the response.
    case 'create_pull_request': {
      const args = CreatePullRequestSchema.parse(request.params.arguments);
      const result = await createPullRequest(
        connection,
        args.projectId ?? defaultProject,
        args.repositoryId,
        args,
      );
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
  • Zod schema defining the input parameters and validation for the create_pull_request tool.
    export const CreatePullRequestSchema = z.object({
      projectId: z
        .string()
        .optional()
        .describe(`The ID or name of the project (Default: ${defaultProject})`),
      organizationId: z
        .string()
        .optional()
        .describe(`The ID or name of the organization (Default: ${defaultOrg})`),
      repositoryId: z.string().describe('The ID or name of the repository'),
      title: z.string().describe('The title of the pull request'),
      description: z
        .string()
        .optional()
        .describe('The description of the pull request (markdown is supported)'),
      sourceRefName: z
        .string()
        .describe('The source branch name (e.g., refs/heads/feature-branch)'),
      targetRefName: z
        .string()
        .describe('The target branch name (e.g., refs/heads/main)'),
      reviewers: z
        .array(z.string())
        .optional()
        .describe('List of reviewer email addresses or IDs'),
      isDraft: z
        .boolean()
        .optional()
        .describe('Whether the pull request should be created as a draft'),
      workItemRefs: z
        .array(z.number())
        .optional()
        .describe('List of work item IDs to link to the pull request'),
      tags: z
        .array(z.string().trim().min(1))
        .optional()
        .describe('List of tags to apply to the pull request'),
      additionalProperties: z
        .record(z.string(), z.any())
        .optional()
        .describe('Additional properties to set on the pull request'),
    });
  • ToolDefinition registration for 'create_pull_request' including name, description, and input schema.
    {
      name: 'create_pull_request',
      description:
        'Create a new pull request, including reviewers, linked work items, and optional tags',
      inputSchema: zodToJsonSchema(CreatePullRequestSchema),
    },
  • Helper function to normalize and deduplicate tags for the pull request.
    function normalizeTags(tags?: string[]): string[] {
      if (!tags) {
        return [];
      }
    
      const seen = new Set<string>();
      const normalized: string[] = [];
    
      for (const rawTag of tags) {
        const trimmed = rawTag.trim();
        if (!trimmed) {
          continue;
        }
    
        const key = trimmed.toLowerCase();
        if (seen.has(key)) {
          continue;
        }
    
        seen.add(key);
        normalized.push(trimmed);
      }
    
      return normalized;
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions the tool creates a pull request with specific features, but lacks critical behavioral details: required permissions, whether it's idempotent, error handling, rate limits, or what happens on success/failure. For a mutation tool with 12 parameters, this is a significant gap in transparency.

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, efficient sentence that front-loads the core action and key features. It avoids redundancy and wastes no words, though it could be slightly more structured (e.g., separating required vs. optional aspects).

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 (12 parameters, mutation operation, no annotations, no output schema), the description is incomplete. It doesn't address behavioral aspects like side effects, authentication needs, or response format. For a tool that creates a significant resource, more context is needed to guide an agent effectively.

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 the schema fully documents all 12 parameters. The description adds minimal value beyond the schema by mentioning reviewers, work items, and tags, but doesn't explain parameter interactions, defaults beyond schema, or semantic nuances. Baseline 3 is appropriate as the schema does the heavy lifting.

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 clearly states the action ('Create a new pull request') and specifies key components like reviewers, linked work items, and optional tags. It distinguishes from siblings like 'update_pull_request' by focusing on creation, but doesn't explicitly differentiate from other creation tools like 'create_branch' or 'create_work_item' beyond the resource type.

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), when not to use it (e.g., for updates), or direct alternatives among siblings like 'update_pull_request' for modifications. Usage is implied by the name but not explicitly stated.

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/Tiberriver256/mcp-server-azure-devops'

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