Skip to main content
Glama
mmruesch12
by mmruesch12

get_pull_request

Retrieve detailed information about a specific pull request by providing its ID using this Azure DevOps MCP Server tool.

Instructions

Get details of a specific pull request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pullRequestIdYesID of the pull request

Implementation Reference

  • Main handler function that parses input, fetches the pull request details via gitClient.getPullRequestById, fetches and attaches linked work items, and returns formatted content.
    export async function getPullRequest(rawParams: any) {
      // Parse arguments with defaults from environment variables
      const params = getPullRequestSchema.parse({
        pullRequestId: rawParams.pullRequestId,
      });
    
      console.error("[API] Getting pull request details:", params);
    
      try {
        // Get the Git API client
        const gitClient = await getGitClient();
    
        // Get pull request details
        const pullRequest = await gitClient.getPullRequestById(
          params.pullRequestId,
          DEFAULT_PROJECT
        );
    
        console.error(`[API] Found pull request: ${pullRequest.pullRequestId}`);
    
        // Fetch linked work items if the link exists
        let linkedWorkItems: { id: number; url: string }[] = []; // Initialize with specific type
        if (pullRequest._links?.workItems?.href) {
          try {
            console.error(
              `[API] Fetching linked work items from: ${pullRequest._links.workItems.href}`
            );
            const workItemsResponse = await makeAzureDevOpsRequest(
              pullRequest._links.workItems.href
            );
            if (workItemsResponse && workItemsResponse.value) {
              linkedWorkItems = workItemsResponse.value.map(
                (item: { id: string; url: string }) => ({
                  id: parseInt(item.id, 10), // Convert ID back to number
                  url: item.url,
                })
              );
              console.error(
                `[API] Found ${linkedWorkItems.length} linked work items.`
              );
            } else {
              console.error(
                "[API] No linked work items found or unexpected response format from workItems link."
              );
              // Log the actual response for debugging
              console.error(
                "[API] Work items response received:",
                JSON.stringify(workItemsResponse, null, 2)
              );
            }
          } catch (wiError) {
            logError(
              "Error fetching linked work items from workItems link",
              wiError
            );
            // Explicitly set to empty array on error, but log it
            linkedWorkItems = [];
          }
        } else {
          console.error(
            "[API] No _links.workItems.href found in pull request response."
          );
        }
    
        // Add linked work items to the response object
        const responsePayload = {
          ...pullRequest,
          linkedWorkItems: linkedWorkItems, // Add the fetched work items
        };
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(responsePayload, null, 2), // Use the modified payload
            },
          ],
        };
      } catch (error) {
        logError("Error getting pull request", error);
        throw error;
      }
    }
  • Zod schema for input validation of pullRequestId and inferred TypeScript type.
    export const getPullRequestSchema = z.object({
      pullRequestId: z.number(),
    });
    
    export type GetPullRequestParams = z.infer<typeof getPullRequestSchema>;
  • Tool metadata registration including name, description, and input schema in the pullRequestTools array used for listTools.
    name: "get_pull_request",
    description: "Get details of a specific pull request",
    inputSchema: {
      type: "object",
      properties: {
        pullRequestId: {
          type: "number",
          description: "ID of the pull request",
        },
      },
      required: ["pullRequestId"],
    },
  • src/index.ts:79-80 (registration)
    Dispatch registration in the CallToolRequestSchema handler switch statement.
    case "get_pull_request":
      return await getPullRequest(request.params.arguments || {});
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 states it 'gets details' but doesn't specify what details are returned, whether it's read-only, requires authentication, or has rate limits. This is a significant gap for a tool with zero annotation coverage.

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 with no wasted words. It's appropriately sized and front-loaded, clearly stating the tool's purpose without unnecessary elaboration.

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 low complexity (1 parameter, no output schema, no annotations), the description is minimally adequate. However, it lacks details on return values and behavioral traits, which are important for a tool with no annotations or output schema to guide the 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 schema description coverage is 100%, with the parameter 'pullRequestId' fully documented in the schema. The description doesn't add any meaning beyond the schema, such as format examples or constraints, 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 verb ('Get details') and resource ('a specific pull request'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'get_pull_request_diff' or 'list_pull_requests', which limits its specificity.

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 doesn't mention siblings like 'list_pull_requests' for listing multiple PRs or 'get_pull_request_diff' for diff details, leaving the agent to infer usage context.

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/mmruesch12/azdo-mcp'

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