git_get_pull_requests
Retrieve and filter pull requests from Azure DevOps repositories by status, creator, reviewer, or branch to track code review progress across organizations.
Instructions
Gets a list of pull requests in a repository with filtering options
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| organization | Yes | The name of the Azure DevOps organization | |
| project | Yes | Project ID or name | |
| repositoryId | Yes | The repository ID or name | |
| status | No | Filter by PR status (Active, Abandoned, Completed, All) | |
| creatorId | No | Filter by creator ID | |
| reviewerId | No | Filter by reviewer ID | |
| sourceRefName | No | Filter by source branch name (e.g. refs/heads/feature/1) | |
| targetRefName | No | Filter by target branch name (e.g. refs/heads/main) | |
| top | No | Number of results to return |
Implementation Reference
- src/tools/repositories.ts:54-90 (handler)The asynchronous handler function that executes the core logic of the git_get_pull_requests tool. It connects to Azure DevOps, constructs search criteria, fetches pull requests using the Git API, simplifies the data, and returns it as JSON.async ({ organization, project, repositoryId, status, creatorId, reviewerId, sourceRefName, targetRefName, top }) => { const connection = await connectionManager.getConnection(organization); const gitApi = await connection.getGitApi(); const searchCriteria: any = { status: safeEnumConvert<PullRequestStatus>(PullRequestStatus, status), creatorId, reviewerId, sourceRefName, targetRefName }; const prs = await gitApi.getPullRequests( repositoryId, searchCriteria, project, undefined, undefined, top || 20 ); const simplified = prs.map(pr => ({ pullRequestId: pr.pullRequestId, title: pr.title, description: pr.description, status: pr.status, creationDate: pr.creationDate, createdBy: pr.createdBy?.displayName, sourceRefName: pr.sourceRefName, targetRefName: pr.targetRefName, url: pr.url })); return { content: [{ type: "text", text: JSON.stringify(simplified, null, 2) }], }; }
- src/tools/repositories.ts:43-53 (schema)Zod schema defining the input parameters and their descriptions for the git_get_pull_requests tool, including organization, project, repository, filters, and pagination.{ 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"), status: z.enum(getEnumKeys(PullRequestStatus)).optional().describe("Filter by PR status (Active, Abandoned, Completed, All)"), creatorId: z.string().optional().describe("Filter by creator ID"), reviewerId: z.string().optional().describe("Filter by reviewer ID"), sourceRefName: z.string().optional().describe("Filter by source branch name (e.g. refs/heads/feature/1)"), targetRefName: z.string().optional().describe("Filter by target branch name (e.g. refs/heads/main)"), top: z.number().optional().describe("Number of results to return"), },
- src/tools/repositories.ts:40-91 (registration)Registration of the git_get_pull_requests tool using McpServer.tool(), specifying name, description, input schema, and handler function.server.tool( "git_get_pull_requests", "Gets a list of pull requests in a repository with filtering options", { 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"), status: z.enum(getEnumKeys(PullRequestStatus)).optional().describe("Filter by PR status (Active, Abandoned, Completed, All)"), creatorId: z.string().optional().describe("Filter by creator ID"), reviewerId: z.string().optional().describe("Filter by reviewer ID"), sourceRefName: z.string().optional().describe("Filter by source branch name (e.g. refs/heads/feature/1)"), targetRefName: z.string().optional().describe("Filter by target branch name (e.g. refs/heads/main)"), top: z.number().optional().describe("Number of results to return"), }, async ({ organization, project, repositoryId, status, creatorId, reviewerId, sourceRefName, targetRefName, top }) => { const connection = await connectionManager.getConnection(organization); const gitApi = await connection.getGitApi(); const searchCriteria: any = { status: safeEnumConvert<PullRequestStatus>(PullRequestStatus, status), creatorId, reviewerId, sourceRefName, targetRefName }; const prs = await gitApi.getPullRequests( repositoryId, searchCriteria, project, undefined, undefined, top || 20 ); const simplified = prs.map(pr => ({ pullRequestId: pr.pullRequestId, title: pr.title, description: pr.description, status: pr.status, creationDate: pr.creationDate, createdBy: pr.createdBy?.displayName, sourceRefName: pr.sourceRefName, targetRefName: pr.targetRefName, url: pr.url })); return { content: [{ type: "text", text: JSON.stringify(simplified, null, 2) }], }; } );