get_pull_request_checks
Retrieve status checks and policy evaluations for Azure DevOps pull requests to identify blocking validations and pipeline issues.
Instructions
Summarize the latest status checks and policy evaluations for a pull request.
Surfaces pipeline and run identifiers so you can jump straight to the blocking validation.
Pair with pipeline tools (e.g., get_pipeline_run, pipeline_timeline) to inspect failures in depth.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | No | The ID or name of the project (Default: MyProject) | |
| organizationId | No | The ID or name of the organization (Default: mycompany) | |
| repositoryId | Yes | The ID or name of the repository | |
| pullRequestId | Yes | The ID of the pull request |
Implementation Reference
- Main handler function that fetches pull request statuses and policy evaluations from Azure DevOps APIs, maps them to the response format, and handles errors.export async function getPullRequestChecks( connection: WebApi, options: PullRequestChecksOptions, ): Promise<PullRequestChecksResult> { try { const [gitApi, policyApi, projectId] = await Promise.all([ connection.getGitApi(), connection.getPolicyApi(), resolveProjectId(connection, options.projectId), ]); const [statusRecords, evaluationRecords] = await Promise.all([ gitApi.getPullRequestStatuses( options.repositoryId, options.pullRequestId, projectId, ), policyApi.getPolicyEvaluations( projectId, buildPolicyArtifactId(projectId, options.pullRequestId), ), ]); return { statuses: (statusRecords ?? []).map(mapStatusRecord), policyEvaluations: (evaluationRecords ?? []).map(mapEvaluationRecord), }; } catch (error) { if (error instanceof AzureDevOpsError) { throw error; } throw new Error( `Failed to get pull request checks: ${ error instanceof Error ? error.message : String(error) }`, ); } }
- Zod input schema for validating tool arguments: projectId, organizationId, repositoryId, pullRequestId.export const GetPullRequestChecksSchema = z.object({ projectId: z .string() .optional() .describe(`The ID or name of the project (Default: ${defaultProject})`), organizationId: z .string() .optional() .describe(`The ID or name of the organization (Default: ${defaultOrg})`), repositoryId: z.string().describe('The ID or name of the repository'), pullRequestId: z.number().describe('The ID of the pull request'), });
- src/features/pull-requests/tool-definitions.ts:51-59 (registration)MCP tool registration defining the tool name, description, and JSON schema for inputs.{ name: 'get_pull_request_checks', description: [ 'Summarize the latest status checks and policy evaluations for a pull request.', '- Surfaces pipeline and run identifiers so you can jump straight to the blocking validation.', '- Pair with pipeline tools (e.g., get_pipeline_run, pipeline_timeline) to inspect failures in depth.', ].join('\n'), inputSchema: zodToJsonSchema(GetPullRequestChecksSchema), },
- src/features/pull-requests/index.ts:171-181 (registration)Request handler router that parses arguments with schema and dispatches to the getPullRequestChecks handler.case 'get_pull_request_checks': { const params = GetPullRequestChecksSchema.parse(request.params.arguments); const result = await getPullRequestChecks(connection, { projectId: params.projectId ?? defaultProject, repositoryId: params.repositoryId, pullRequestId: params.pullRequestId, }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }
- Helper function to resolve project ID or name to GUID using Core API.const resolveProjectId = async ( connection: WebApi, projectIdOrName: string, ): Promise<string> => { if (projectIdGuidPattern.test(projectIdOrName)) { return projectIdOrName; } const coreApi = await connection.getCoreApi(); const project = await coreApi.getProject(projectIdOrName); if (!project?.id) { throw new AzureDevOpsResourceNotFoundError( `Project '${projectIdOrName}' not found`, ); } return project.id; };