Skip to main content
Glama
ennuiii

Azure DevOps MCP Server with PAT Authentication

by ennuiii

repo_list_pull_requests_by_project

Retrieve a list of pull requests for a specific Azure DevOps project, filtered by status, creator, or reviewer. Use this tool to efficiently manage and track pull requests within your project.

Instructions

Retrieve a list of pull requests for a given project Id or Name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
created_by_meNoFilter pull requests created by the current user.
i_am_reviewerNoFilter pull requests where the current user is a reviewer.
projectYesThe name or ID of the Azure DevOps project.
skipNoThe number of pull requests to skip.
statusNoFilter pull requests by status. Defaults to 'Active'.Active
topNoThe maximum number of pull requests to return.

Implementation Reference

  • Registration of the tool name mapping from internal handler 'list_pull_requests_by_project' to the public tool name 'repo_list_pull_requests_by_project' in the REPO_TOOLS constant.
    list_pull_requests_by_project: "repo_list_pull_requests_by_project",
  • Zod schema defining the input parameters for the tool, including project, pagination options, user filters, and status.
    { project: z.string().describe("The name or ID of the Azure DevOps project."), top: z.number().default(100).describe("The maximum number of pull requests to return."), skip: z.number().default(0).describe("The number of pull requests to skip."), created_by_me: z.boolean().default(false).describe("Filter pull requests created by the current user."), i_am_reviewer: z.boolean().default(false).describe("Filter pull requests where the current user is a reviewer."), status: z .enum(getEnumKeys(PullRequestStatus) as [string, ...string[]]) .default("Active") .describe("Filter pull requests by status. Defaults to 'Active'."), },
  • The core handler function that fetches pull requests for a project using the Azure DevOps Git API, applies filters based on user and status, trims the response data, and returns it as JSON text.
    async ({ project, top, skip, created_by_me, i_am_reviewer, status }) => { const connection = await connectionProvider(); const gitApi = await connection.getGitApi(); // Build the search criteria const gitPullRequestSearchCriteria: { status: number; creatorId?: string; reviewerId?: string; } = { status: pullRequestStatusStringToInt(status), }; if (created_by_me || i_am_reviewer) { const data = await getCurrentUserDetails(tokenProvider, connectionProvider, userAgentProvider); const userId = data.authenticatedUser.id; if (created_by_me) { gitPullRequestSearchCriteria.creatorId = userId; } if (i_am_reviewer) { gitPullRequestSearchCriteria.reviewerId = userId; } } const pullRequests = await gitApi.getPullRequestsByProject( project, gitPullRequestSearchCriteria, undefined, // maxCommentLength skip, top ); // Filter out the irrelevant properties const filteredPullRequests = pullRequests?.map((pr) => ({ pullRequestId: pr.pullRequestId, codeReviewId: pr.codeReviewId, repository: pr.repository?.name, status: pr.status, createdBy: { displayName: pr.createdBy?.displayName, uniqueName: pr.createdBy?.uniqueName, }, creationDate: pr.creationDate, title: pr.title, isDraft: pr.isDraft, sourceRefName: pr.sourceRefName, targetRefName: pr.targetRefName, })); return { content: [{ type: "text", text: JSON.stringify(filteredPullRequests, null, 2) }], }; }
  • Helper function to convert a pull request status string to the corresponding integer value from PullRequestStatus enum, used in the handler to set the status filter.
    function pullRequestStatusStringToInt(status: string): number { switch (status) { case "Abandoned": return PullRequestStatus.Abandoned.valueOf(); case "Active": return PullRequestStatus.Active.valueOf(); case "All": return PullRequestStatus.All.valueOf(); case "Completed": return PullRequestStatus.Completed.valueOf(); case "NotSet": return PullRequestStatus.NotSet.valueOf(); default: throw new Error(`Unknown pull request status: ${status}`); } }
  • src/tools.ts:23-23 (registration)
    High-level registration call to configureRepoTools, which registers all repository tools including repo_list_pull_requests_by_project.
    configureRepoTools(server, tokenProvider, connectionProvider, userAgentProvider);

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