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
| Name | Required | Description | Default |
|---|---|---|---|
| created_by_me | No | Filter pull requests created by the current user. | |
| i_am_reviewer | No | Filter pull requests where the current user is a reviewer. | |
| project | Yes | The name or ID of the Azure DevOps project. | |
| skip | No | The number of pull requests to skip. | |
| status | No | Filter pull requests by status. Defaults to 'Active'. | Active |
| top | No | The maximum number of pull requests to return. |
Implementation Reference
- src/tools/repos.ts:28-28 (registration)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",
- src/tools/repos.ts:339-349 (schema)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'."), },
- src/tools/repos.ts:350-402 (handler)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) }], }; }
- src/tools/repos.ts:76-91 (helper)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);