Skip to main content
Glama
ennuiii

Azure DevOps MCP Server with PAT Authentication

by ennuiii

repo_list_pull_requests_by_commits

Find pull requests containing specific commits in an Azure DevOps repository. Query by commit IDs to accurately track and manage code changes across project branches.

Instructions

Lists pull requests by commit IDs to find which pull requests contain specific commits

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commitsYesArray of commit IDs to query for
projectYesProject name or ID
queryTypeNoType of query to performLastMergeCommit
repositoryYesRepository name or ID

Implementation Reference

  • The main handler function that constructs a GitPullRequestQuery from the input commits and calls the Azure DevOps Git API's getPullRequestQuery method to find pull requests containing those commits.
    async ({ project, repository, commits, queryType }) => { try { const connection = await connectionProvider(); const gitApi = await connection.getGitApi(); const query: GitPullRequestQuery = { queries: [ { items: commits, type: GitPullRequestQueryType[queryType as keyof typeof GitPullRequestQueryType], } as GitPullRequestQueryInput, ], }; const queryResult = await gitApi.getPullRequestQuery(query, repository, project); return { content: [{ type: "text", text: JSON.stringify(queryResult, null, 2) }], }; } catch (error) { return { content: [ { type: "text", text: `Error querying pull requests by commits: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }
  • Zod schema for input validation, defining parameters project, repository, commits (array of strings), and optional queryType.
    project: z.string().describe("Project name or ID"), repository: z.string().describe("Repository name or ID"), commits: z.array(z.string()).describe("Array of commit IDs to query for"), queryType: z .enum(pullRequestQueryTypesStrings as [string, ...string[]]) .optional() .default(GitPullRequestQueryType[GitPullRequestQueryType.LastMergeCommit]) .describe("Type of query to perform"), },
  • Registers the tool with the MCP server using server.tool, specifying the name from REPO_TOOLS, description, input schema, and handler function.
    server.tool( REPO_TOOLS.list_pull_requests_by_commits, "Lists pull requests by commit IDs to find which pull requests contain specific commits", { project: z.string().describe("Project name or ID"), repository: z.string().describe("Repository name or ID"), commits: z.array(z.string()).describe("Array of commit IDs to query for"), queryType: z .enum(pullRequestQueryTypesStrings as [string, ...string[]]) .optional() .default(GitPullRequestQueryType[GitPullRequestQueryType.LastMergeCommit]) .describe("Type of query to perform"), }, async ({ project, repository, commits, queryType }) => { try { const connection = await connectionProvider(); const gitApi = await connection.getGitApi(); const query: GitPullRequestQuery = { queries: [ { items: commits, type: GitPullRequestQueryType[queryType as keyof typeof GitPullRequestQueryType], } as GitPullRequestQueryInput, ], }; const queryResult = await gitApi.getPullRequestQuery(query, repository, project); return { content: [{ type: "text", text: JSON.stringify(queryResult, null, 2) }], }; } catch (error) { return { content: [ { type: "text", text: `Error querying pull requests by commits: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } } );
  • Defines the tool name mapping in the REPO_TOOLS constant object.
    list_pull_requests_by_commits: "repo_list_pull_requests_by_commits",

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