Skip to main content
Glama

list_pull_requests

Filter and retrieve pull requests by status (active, completed, abandoned) in a repository using this tool on the azure-devops MCP Server.

Instructions

List pull requests in a repository

Input Schema

NameRequiredDescriptionDefault
statusNoFilter by PR status

Input Schema (JSON Schema)

{ "properties": { "status": { "description": "Filter by PR status", "enum": [ "active", "completed", "abandoned" ], "type": "string" } }, "required": [], "type": "object" }

Implementation Reference

  • The main handler function that implements the list_pull_requests tool logic. It parses input, fetches pull requests using the Git client based on status, and returns them as JSON.
    export async function listPullRequests(rawParams: any) { // Parse arguments with defaults from environment variables const params = listPullRequestsSchema.parse({ status: rawParams.status, }); console.error("[API] Listing pull requests:", params); try { // Get the Git API client const gitClient = await getGitClient(); // Convert status string to number let statusId: number | undefined; if (params.status) { switch (params.status) { case "active": statusId = 1; break; case "completed": statusId = 3; break; case "abandoned": statusId = 2; break; } } // Get pull requests if (!DEFAULT_PROJECT || !DEFAULT_REPOSITORY) { throw new Error("Default project and repository must be configured"); } const pullRequests = await gitClient.getPullRequests( DEFAULT_REPOSITORY, { status: statusId }, DEFAULT_PROJECT ); console.error(`[API] Found ${pullRequests.length} pull requests`); return { content: [ { type: "text", text: JSON.stringify(pullRequests, null, 2), }, ], }; } catch (error) { logError("Error listing pull requests", error); throw error; } }
  • Zod schema used for input validation and parsing in the handler function.
    export const listPullRequestsSchema = z.object({ status: z.enum(["active", "completed", "abandoned"]).optional(), }); export type ListPullRequestsParams = z.infer<typeof listPullRequestsSchema>;
  • Tool registration definition within the pullRequestTools array, including name, description, and input schema. This is returned by listTools.
    { name: "list_pull_requests", description: "List pull requests in a repository", inputSchema: { type: "object", properties: { status: { type: "string", enum: ["active", "completed", "abandoned"], description: "Filter by PR status", }, }, required: [], }, },
  • src/index.ts:77-78 (registration)
    Dispatcher in the main server CallToolRequest handler that routes calls to the listPullRequests function.
    case "list_pull_requests": return await listPullRequests(request.params.arguments || {});
  • src/index.ts:50-63 (registration)
    Registration of tools list handler that includes pullRequestTools containing the list_pull_requests tool.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ // Work Items ...workItemTools, // Pull Requests ...pullRequestTools, // Wiki ...wikiTools, // Projects ...projectTools, ], }; });

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