list_pull_requests
Retrieve and filter pull requests in Azure DevOps projects by status, creator, or repository to monitor code review progress.
Instructions
List all pull requests in the project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| status | No | Filter by PR status (active, completed, abandoned) | |
| creatorId | No | Filter by creator ID (optional) | |
| repositoryId | No | Filter by repository ID (optional) |
Implementation Reference
- src/tools/pull-request/get.ts:12-60 (handler)The core handler function that executes the list_pull_requests tool by querying the Azure DevOps Git API with optional status, creatorId, and repositoryId filters.export async function getPullRequests(args: GetPullRequestsArgs, config: AzureDevOpsConfig) { AzureDevOpsConnection.initialize(config); const connection = AzureDevOpsConnection.getInstance(); const gitApi = await connection.getGitApi(); try { let statusFilter: PullRequestStatus | undefined; if (args.status) { switch (args.status) { case 'active': statusFilter = 1; // PullRequestStatus.Active break; case 'completed': statusFilter = 3; // PullRequestStatus.Completed break; case 'abandoned': statusFilter = 2; // PullRequestStatus.Abandoned break; } } const searchCriteria = { status: statusFilter, creatorId: args.creatorId, repositoryId: args.repositoryId, }; const pullRequests = await gitApi.getPullRequests( args.repositoryId || config.project, searchCriteria ); return { content: [ { type: 'text', text: JSON.stringify(pullRequests, null, 2), }, ], }; } catch (error: unknown) { if (error instanceof McpError) throw error; const errorMessage = error instanceof Error ? error.message : 'Unknown error'; throw new McpError( ErrorCode.InternalError, `Failed to get pull requests: ${errorMessage}` ); } }
- src/tools/pull-request/index.ts:7-28 (schema)The input schema and metadata definition for the list_pull_requests tool.{ name: 'list_pull_requests', description: 'List all pull requests in the project', inputSchema: { type: 'object', properties: { status: { type: 'string', description: 'Filter by PR status (active, completed, abandoned)', enum: ['active', 'completed', 'abandoned'], }, creatorId: { type: 'string', description: 'Filter by creator ID (optional)', }, repositoryId: { type: 'string', description: 'Filter by repository ID (optional)', }, }, }, },
- src/index.ts:170-173 (registration)Registration in the main MCP server switch statement that handles calls to list_pull_requests by invoking the getPullRequests handler.case 'list_pull_requests': result = await tools.pullRequest.getPullRequests( validateArgs(request.params.arguments, 'Pull request list arguments required') );