Skip to main content
Glama
Tiberriver256

Azure DevOps MCP Server

get_pull_request_changes

Retrieve detailed changes from Azure DevOps pull requests including modified files, unified diffs, branch information, and policy evaluation status for code review and integration workflows.

Instructions

Get the files changed in a pull request, their unified diffs, source/target branch names, and the status of policy evaluations

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdNoThe ID or name of the project (Default: MyProject)
organizationIdNoThe ID or name of the organization (Default: mycompany)
repositoryIdYesThe ID or name of the repository
pullRequestIdYesThe ID of the pull request

Implementation Reference

  • The main handler function that fetches the latest pull request iteration changes, policy evaluations, source/target refs, and generates unified diff patches for changed files using Azure DevOps APIs.
    export async function getPullRequestChanges(
      connection: WebApi,
      options: PullRequestChangesOptions,
    ): Promise<PullRequestChangesResponse> {
      try {
        const gitApi = await connection.getGitApi();
        const [pullRequest, iterations] = await Promise.all([
          gitApi.getPullRequest(
            options.repositoryId,
            options.pullRequestId,
            options.projectId,
          ),
          gitApi.getPullRequestIterations(
            options.repositoryId,
            options.pullRequestId,
            options.projectId,
          ),
        ]);
        if (!iterations || iterations.length === 0) {
          throw new AzureDevOpsError('No iterations found for pull request');
        }
        const latest = iterations[iterations.length - 1];
        const changes = await gitApi.getPullRequestIterationChanges(
          options.repositoryId,
          options.pullRequestId,
          latest.id!,
          options.projectId,
        );
    
        const policyApi = await connection.getPolicyApi();
        const artifactId = `vstfs:///CodeReview/CodeReviewId/${options.projectId}/${options.pullRequestId}`;
        const evaluations = await policyApi.getPolicyEvaluations(
          options.projectId,
          artifactId,
        );
    
        const changeEntries = changes.changeEntries ?? [];
    
        const getBlobText = async (objId?: string): Promise<string> => {
          if (!objId) return '';
          const stream = await gitApi.getBlobContent(
            options.repositoryId,
            objId,
            options.projectId,
          );
    
          const chunks: Uint8Array[] = [];
          return await new Promise<string>((resolve, reject) => {
            stream.on('data', (chunk) => chunks.push(Buffer.from(chunk)));
            stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
            stream.on('error', reject);
          });
        };
    
        const files = await Promise.all(
          changeEntries.map(async (entry: GitChange) => {
            const path = entry.item?.path || entry.originalPath || '';
            const [oldContent, newContent] = await Promise.all([
              getBlobText(entry.item?.originalObjectId),
              getBlobText(entry.item?.objectId),
            ]);
            const patch = createTwoFilesPatch(
              entry.originalPath || path,
              path,
              oldContent,
              newContent,
            );
            return { path, patch };
          }),
        );
    
        return {
          changes,
          evaluations,
          files,
          sourceRefName: pullRequest?.sourceRefName,
          targetRefName: pullRequest?.targetRefName,
        };
      } catch (error) {
        if (error instanceof AzureDevOpsError) {
          throw error;
        }
        throw new Error(
          `Failed to get pull request changes: ${error instanceof Error ? error.message : String(error)}`,
        );
      }
    }
  • Input schema validation using Zod for the get_pull_request_changes tool parameters.
    export const GetPullRequestChangesSchema = 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'),
    });
  • Response schema defining the structure of data returned by the get_pull_request_changes tool.
    export const GetPullRequestChangesResponseSchema = z.object({
      changes: z.any(),
      evaluations: z.array(z.any()),
      files: z.array(PullRequestFileChangeSchema),
      sourceRefName: z.string().optional(),
      targetRefName: z.string().optional(),
    });
  • Tool registration definition including name, description, and JSON schema for inputs.
    {
      name: 'get_pull_request_changes',
      description:
        'Get the files changed in a pull request, their unified diffs, source/target branch names, and the status of policy evaluations',
      inputSchema: zodToJsonSchema(GetPullRequestChangesSchema),
    },
  • Request dispatcher case that parses inputs with schema and invokes the core getPullRequestChanges handler.
    case 'get_pull_request_changes': {
      const params = GetPullRequestChangesSchema.parse(
        request.params.arguments,
      );
      const result = await getPullRequestChanges(connection, {
        projectId: params.projectId ?? defaultProject,
        repositoryId: params.repositoryId,
        pullRequestId: params.pullRequestId,
      });
      return {
        content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions what data is retrieved (files, diffs, branch names, policy status) but does not cover critical behaviors such as permissions required, rate limits, pagination, error handling, or whether the operation is read-only or has side effects. For a tool with no annotation coverage, this leaves significant gaps in understanding its operational traits.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, well-structured sentence that efficiently lists all key outputs (files, diffs, branch names, policy status) without unnecessary words. It is front-loaded with the core purpose and avoids redundancy, making it easy to parse and understand quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (4 parameters, no output schema, no annotations), the description is partially complete. It clearly states what data is retrieved, which helps, but lacks details on behavioral aspects like permissions or error handling. Without an output schema, it does not describe return values, but the description compensates somewhat by listing output types. However, for a tool with no annotations, more behavioral context would improve completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, so the schema already documents all parameters (projectId, organizationId, repositoryId, pullRequestId) with their types and defaults. The description does not add any additional meaning or context beyond what the schema provides, such as explaining relationships between parameters or usage examples. This meets the baseline score of 3 when schema coverage is high.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('Get') and resources ('files changed in a pull request'), and it distinguishes itself from siblings like get_pull_request_comments or get_pull_request_checks by focusing on file changes, diffs, branch names, and policy evaluations. It provides a comprehensive scope that differentiates it from other pull request-related tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It does not mention sibling tools like get_pull_request_comments or get_pull_request_checks, nor does it specify scenarios or prerequisites for usage. Without such context, users must infer usage from the tool name and description alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/Tiberriver256/mcp-server-azure-devops'

If you have feedback or need assistance with the MCP directory API, please join our Discord server