Skip to main content
Glama
skurekjakub

Git Stuff Server

by skurekjakub

ado_pr_changes

Fetch detailed changes and full diff content from an Azure DevOps Pull Request using the Azure DevOps Node API for efficient code review and integration.

Instructions

Fetches changes from an Azure DevOps Pull Request with full diff content using the Azure DevOps Node API.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
organizationIdYesOptional organization identifier to load specific configuration settings.
pullRequestIdYesThe numeric ID of the Pull Request (as a string).

Implementation Reference

  • The main execution handler for the 'ado_pr_changes' tool. It fetches ADO configuration, PR details, latest iteration changes, formats the output, and returns the result or error.
    export const adoPrChangesHandler = async (input: AdoPrChangesInput): Promise<CallToolResult> => {
      try {
        const config = await getAdoConfig(input.organizationId);
    
        if (!config.organization || !config.project) {
          return { content: [{ type: "text", text: "ERROR: Missing required configuration parameters (organization, project). Please ensure Azure CLI is authenticated and configuration is set." }], isError: true };
        }
    
        const { gitApi } = await getAdoConnectionAndApi(config.organization);
    
        const pullRequestIdNum = parseInt(input.pullRequestId, 10);
        const pr = await getPrDetails(gitApi, pullRequestIdNum, config.project);
    
        if (!pr || !pr.repository?.id || !pr.sourceRefName || !pr.targetRefName) {
          return { content: [{ type: "text", text: "ERROR: Could not retrieve valid PR details." }], isError: true };
        }
    
        const repositoryId = pr.repository.id;
        const sourceBranch = pr.sourceRefName.replace("refs/heads/", "");
        const targetBranch = pr.targetRefName.replace("refs/heads/", "");
    
        const { iterationChanges, latestIteration } = await getLatestPrIterationChanges(gitApi, repositoryId, pullRequestIdNum, config.project);
    
        // Pass necessary arguments to the formatter
        const output = await formatPrChangesOutput(
          gitApi,
          repositoryId,
          config.project,
          input.pullRequestId,
          sourceBranch,
          targetBranch,
          iterationChanges,
          latestIteration
        );
    
        return { content: [{ type: "text", text: output }] };
    
      } catch (error: any) {
        console.error("Error processing ADO PR changes:", error);
        return { content: [{ type: "text", text: `ERROR: Failed to get PR changes. ${error.message}` }], isError: true };
      }
    };
  • Zod schema defining the input parameters for the tool: required pullRequestId (string of digits) and optional organizationId.
    export const adoPrChangesSchema = z.object({
      pullRequestId: z.string().min(1).regex(/^\d+$/).describe("The numeric ID of the Pull Request (as a string)."),
      organizationId: z.string().min(1).describe("Optional organization identifier to load specific configuration settings.")
    });
  • Tool registration in the MCP server, associating the name 'ado_pr_changes', description, schema, and handler function.
    server.tool(
      "ado_pr_changes", 
      "Fetches changes from an Azure DevOps Pull Request with full diff content using the Azure DevOps Node API.",
      adoPrChangesSchema.shape, // Use .shape here
      adoPrChangesHandler
    );
  • Key helper function that retrieves the iterations for a PR and fetches changes from the latest iteration, providing the core data for diffs.
    export async function getLatestPrIterationChanges(
        gitApi: GitApi, 
        repositoryId: string, 
        pullRequestId: number, 
        project: string
    ): Promise<{ 
        iterationChanges: GitInterfaces.GitPullRequestIterationChanges, 
        latestIteration: GitInterfaces.GitPullRequestIteration 
    }> {
        const iterations = await gitApi.getPullRequestIterations(repositoryId, pullRequestId, project);
        if (!iterations || iterations.length === 0) {
            throw new Error("Could not retrieve iterations for the PR.");
        }
        const latestIteration = iterations[iterations.length - 1];
        if (!latestIteration?.id) {
            throw new Error("Could not get latest iteration ID.");
        }
    
        const iterationChanges = await gitApi.getPullRequestIterationChanges(repositoryId, pullRequestId, latestIteration.id, project);
        if (!iterationChanges) {
            throw new Error("Could not retrieve changes for the latest PR iteration.");
        }
        return { iterationChanges, latestIteration };
    }
  • Helper to establish Azure DevOps connection and Git API using Azure CLI authentication.
    export async function getAdoConnectionAndApi(organization: string): Promise<{ connection: azdev.WebApi, gitApi: GitApi }> {
        const orgUrl = `https://dev.azure.com/${organization}`;
        
        // Get access token from Azure CLI
        const accessToken = await getAzureCliAccessToken(organization);
        const authHandler = azdev.getBearerHandler(accessToken);
        
        const connection = new azdev.WebApi(orgUrl, authHandler);
        const gitApi: GitApi = await connection.getGitApi();
        return { connection, gitApi };
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions fetching changes with 'full diff content', which implies a read-only operation, but doesn't clarify permissions, rate limits, or what the output format looks like (e.g., JSON structure, error handling). This leaves significant gaps for a tool that interacts with an external API.

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, efficient sentence that front-loads the core purpose without unnecessary details. Every word contributes to understanding the tool's function, making it highly concise and well-structured.

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

Completeness2/5

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

Given the complexity of interacting with Azure DevOps API and no annotations or output schema, the description is incomplete. It lacks details on authentication, error cases, return format (e.g., diff structure), and how it differs from sibling tools, making it inadequate for safe and effective use by an AI agent.

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, clearly documenting both parameters ('pullRequestId' and 'organizationId'). The description adds no additional parameter semantics beyond what the schema provides, such as example values or usage context, so it meets the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the action ('fetches changes') and resource ('Azure DevOps Pull Request'), specifying it includes 'full diff content' and uses the 'Azure DevOps Node API'. However, it doesn't explicitly distinguish this tool from sibling tools like 'ado_pr_comment' or 'ado_pr_threads', which likely handle different aspects of pull requests.

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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention sibling tools like 'ado_pr_comment' or 'git_merge_diff', nor does it specify prerequisites or contexts for usage, leaving the agent to infer based on the tool name 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

Related 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/skurekjakub/GitStuffServer'

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