Skip to main content
Glama

ado_pr_threads

Retrieves active comment threads from an Azure DevOps Pull Request using the Pull Request ID, enabling efficient review and collaboration.

Instructions

Fetches all active comment threads from an Azure DevOps Pull Request.

Input Schema

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

Implementation Reference

  • The main handler function that executes the 'ado_pr_threads' tool logic, fetching active comment threads from an Azure DevOps Pull Request.
    export const adoPrThreadsHandler = async (input: AdoPrThreadsRequest): Promise<CallToolResult> => { console.log("[AdoPrThreadsTool] Received request:", input); 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); if (isNaN(pullRequestIdNum)) { return { content: [{ type: "text", text: "ERROR: pullRequestId must be a numeric string." }], isError: true }; } const pr = await getPrDetails(gitApi, pullRequestIdNum, config.project); if (!pr || !pr.repository?.id) { return { content: [{ type: "text", text: "ERROR: Could not retrieve valid PR details or repository ID." }], isError: true }; } const repositoryId = pr.repository.id; const activeThreads: GitInterfaces.GitPullRequestCommentThread[] = await getActivePrThreads( gitApi, repositoryId, pullRequestIdNum, config.project ); console.log(`[AdoPrThreadsTool] Found ${activeThreads.length} active threads.`); return { content: [{ type: "text", text: JSON.stringify(activeThreads, null, 2) }], }; } catch (error: any) { console.error("[AdoPrThreadsTool] Error:", error); return { content: [{ type: "text", text: `ERROR: Failed to get active PR threads. ${error.message}` }], isError: true, }; } };
  • Zod schema defining the input parameters for the 'ado_pr_threads' tool: pullRequestId and optional organizationId.
    export const AdoPrThreadsRequestSchema = z.object({ pullRequestId: z.string().min(1).regex(/^\d+$/, "pullRequestId must be a numeric string.") .describe("The numeric ID of the Pull Request (as a string)."), organizationId: z.string().min(1).optional() .describe("Optional organization identifier to load specific configuration settings."), });
  • Registration of the 'ado_pr_threads' tool with the MCP server, including name, description, schema, and handler.
    server.tool( "ado_pr_threads", "Fetches all active comment threads from an Azure DevOps Pull Request.", AdoPrThreadsRequestSchema.shape, // Use .shape here for Zod schema adoPrThreadsHandler );
  • Core helper function that fetches all comment threads for a PR and filters for active ones, used by the handler.
    export async function getActivePrThreads( gitApi: GitApi, repositoryId: string, pullRequestId: number, project: string ): Promise<GitInterfaces.GitPullRequestCommentThread[]> { const threads = await gitApi.getThreads(repositoryId, pullRequestId, project); // Filter for active threads. CommentThreadStatus.Active = 1 // Adjust if the actual enum value is different or if a more direct status check is available. return threads.filter(thread => thread.status === GitInterfaces.CommentThreadStatus.Active); }

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