Skip to main content
Glama
ennuiii

Azure DevOps MCP Server with PAT Authentication

by ennuiii

repo_create_pull_request

Create a pull request in Azure DevOps by specifying source and target branches, title, and optional details. Connects via PAT authentication to streamline repository collaboration.

Instructions

Create a new pull request.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionNoThe description of the pull request. Optional.
forkSourceRepositoryIdNoThe ID of the fork repository that the pull request originates from. Optional, used when creating a pull request from a fork.
isDraftNoIndicates whether the pull request is a draft. Defaults to false.
repositoryIdYesThe ID of the repository where the pull request will be created.
sourceRefNameYesThe source branch name for the pull request, e.g., 'refs/heads/feature-branch'.
targetRefNameYesThe target branch name for the pull request, e.g., 'refs/heads/main'.
titleYesThe title of the pull request.
workItemsNoWork item IDs to associate with the pull request, space-separated.

Implementation Reference

  • The handler function that creates the pull request. It uses the Azure DevOps Git API to call createPullRequest with the provided parameters, handles work items and fork source, and returns the created pull request as JSON.
    async ({ repositoryId, sourceRefName, targetRefName, title, description, isDraft, workItems, forkSourceRepositoryId }) => { const connection = await connectionProvider(); const gitApi = await connection.getGitApi(); const workItemRefs = workItems ? workItems.split(" ").map((id) => ({ id: id.trim() })) : []; const forkSource: GitForkRef | undefined = forkSourceRepositoryId ? { repository: { id: forkSourceRepositoryId, }, } : undefined; const pullRequest = await gitApi.createPullRequest( { sourceRefName, targetRefName, title, description, isDraft, workItemRefs: workItemRefs, forkSource, }, repositoryId ); return { content: [{ type: "text", text: JSON.stringify(pullRequest, null, 2) }], }; }
  • Zod input schema defining the parameters for creating a pull request, including repository ID, source and target refs, title, optional description, draft status, work items, and fork source.
    { repositoryId: z.string().describe("The ID of the repository where the pull request will be created."), sourceRefName: z.string().describe("The source branch name for the pull request, e.g., 'refs/heads/feature-branch'."), targetRefName: z.string().describe("The target branch name for the pull request, e.g., 'refs/heads/main'."), title: z.string().describe("The title of the pull request."), description: z.string().optional().describe("The description of the pull request. Optional."), isDraft: z.boolean().optional().default(false).describe("Indicates whether the pull request is a draft. Defaults to false."), workItems: z.string().optional().describe("Work item IDs to associate with the pull request, space-separated."), forkSourceRepositoryId: z.string().optional().describe("The ID of the fork repository that the pull request originates from. Optional, used when creating a pull request from a fork."), },
  • The server.tool registration for 'repo_create_pull_request', referencing the tool name from REPO_TOOLS, providing description, input schema, and inline handler function.
    server.tool( REPO_TOOLS.create_pull_request, "Create a new pull request.", { repositoryId: z.string().describe("The ID of the repository where the pull request will be created."), sourceRefName: z.string().describe("The source branch name for the pull request, e.g., 'refs/heads/feature-branch'."), targetRefName: z.string().describe("The target branch name for the pull request, e.g., 'refs/heads/main'."), title: z.string().describe("The title of the pull request."), description: z.string().optional().describe("The description of the pull request. Optional."), isDraft: z.boolean().optional().default(false).describe("Indicates whether the pull request is a draft. Defaults to false."), workItems: z.string().optional().describe("Work item IDs to associate with the pull request, space-separated."), forkSourceRepositoryId: z.string().optional().describe("The ID of the fork repository that the pull request originates from. Optional, used when creating a pull request from a fork."), }, async ({ repositoryId, sourceRefName, targetRefName, title, description, isDraft, workItems, forkSourceRepositoryId }) => { const connection = await connectionProvider(); const gitApi = await connection.getGitApi(); const workItemRefs = workItems ? workItems.split(" ").map((id) => ({ id: id.trim() })) : []; const forkSource: GitForkRef | undefined = forkSourceRepositoryId ? { repository: { id: forkSourceRepositoryId, }, } : undefined; const pullRequest = await gitApi.createPullRequest( { sourceRefName, targetRefName, title, description, isDraft, workItemRefs: workItemRefs, forkSource, }, repositoryId ); return { content: [{ type: "text", text: JSON.stringify(pullRequest, null, 2) }], }; } );
  • The REPO_TOOLS constant mapping the tool name 'repo_create_pull_request' for use in registration.
    create_pull_request: "repo_create_pull_request",

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/ennuiii/DevOpsMcpPAT'

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