Skip to main content
Glama
nikydobrev

Azure DevOps Multi-Organization MCP Server

by nikydobrev

git_create_pull_request

Create a new pull request in an Azure DevOps repository to merge code changes from a source branch to a target branch, facilitating code review and collaboration.

Instructions

Creates a new pull request in a repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
organizationYesThe name of the Azure DevOps organization
projectYesProject ID or name
repositoryIdYesThe repository ID or name
sourceRefNameYesSource branch name (e.g. refs/heads/feature/my-feature)
targetRefNameYesTarget branch name (e.g. refs/heads/main)
titleYesTitle of the pull request
descriptionNoDescription of the pull request
isDraftNoCreate as a draft PR

Implementation Reference

  • The handler function that creates a pull request by calling the Azure DevOps Git API's createPullRequest method and returns the created PR as JSON.
    async ({ organization, project, repositoryId, sourceRefName, targetRefName, title, description, isDraft }) => {
      const connection = await connectionManager.getConnection(organization);
      const gitApi = await connection.getGitApi();
      
      const prToCreate = {
        sourceRefName,
        targetRefName,
        title,
        description,
        isDraft
      };
    
      const pr = await gitApi.createPullRequest(prToCreate, repositoryId, project);
      
      return {
        content: [{ type: "text", text: JSON.stringify(pr, null, 2) }],
      };
    }
  • Zod schema defining the input parameters for the git_create_pull_request tool.
    {
      organization: z.string().describe("The name of the Azure DevOps organization"),
      project: z.string().describe("Project ID or name"),
      repositoryId: z.string().describe("The repository ID or name"),
      sourceRefName: z.string().describe("Source branch name (e.g. refs/heads/feature/my-feature)"),
      targetRefName: z.string().describe("Target branch name (e.g. refs/heads/main)"),
      title: z.string().describe("Title of the pull request"),
      description: z.string().optional().describe("Description of the pull request"),
      isDraft: z.boolean().optional().describe("Create as a draft PR"),
    },
  • Registration of the git_create_pull_request tool using server.tool, including name, description, input schema, and handler.
    server.tool(
      "git_create_pull_request",
      "Creates a new pull request in a repository",
      {
        organization: z.string().describe("The name of the Azure DevOps organization"),
        project: z.string().describe("Project ID or name"),
        repositoryId: z.string().describe("The repository ID or name"),
        sourceRefName: z.string().describe("Source branch name (e.g. refs/heads/feature/my-feature)"),
        targetRefName: z.string().describe("Target branch name (e.g. refs/heads/main)"),
        title: z.string().describe("Title of the pull request"),
        description: z.string().optional().describe("Description of the pull request"),
        isDraft: z.boolean().optional().describe("Create as a draft PR"),
      },
      async ({ organization, project, repositoryId, sourceRefName, targetRefName, title, description, isDraft }) => {
        const connection = await connectionManager.getConnection(organization);
        const gitApi = await connection.getGitApi();
        
        const prToCreate = {
          sourceRefName,
          targetRefName,
          title,
          description,
          isDraft
        };
    
        const pr = await gitApi.createPullRequest(prToCreate, repositoryId, project);
        
        return {
          content: [{ type: "text", text: JSON.stringify(pr, null, 2) }],
        };
      }
    );

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

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