Skip to main content
Glama

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

NameRequiredDescriptionDefault
pullRequestIdYesID of the pull request

Input Schema (JSON Schema)

{ "properties": { "pullRequestId": { "description": "ID of the pull request", "type": "number" } }, "required": [ "pullRequestId" ], "type": "object" }

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 || {});

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