Skip to main content
Glama
ennuiii

Azure DevOps MCP Server with PAT Authentication

by ennuiii

repo_list_pull_request_threads

Retrieve and manage comment threads for specific pull requests in Azure DevOps repositories. Streamline review processes by accessing detailed thread data based on repository ID, pull request ID, and optional filters.

Instructions

Retrieve a list of comment threads for a pull request.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
baseIterationNoThe base iteration ID for which to retrieve threads. Optional, defaults to the latest base iteration.
fullResponseNoReturn full thread JSON response instead of trimmed data.
iterationNoThe iteration ID for which to retrieve threads. Optional, defaults to the latest iteration.
projectNoProject ID or project name (optional)
pullRequestIdYesThe ID of the pull request for which to retrieve threads.
repositoryIdYesThe ID of the repository where the pull request is located.
skipNoThe number of threads to skip.
topNoThe maximum number of threads to return.

Implementation Reference

  • The main handler function that executes the logic for listing pull request threads using Azure DevOps Git API, including pagination and optional trimming of comments.
    async ({ repositoryId, pullRequestId, project, iteration, baseIteration, top, skip, fullResponse }) => { const connection = await connectionProvider(); const gitApi = await connection.getGitApi(); const threads = await gitApi.getThreads(repositoryId, pullRequestId, project, iteration, baseIteration); const paginatedThreads = threads?.sort((a, b) => (a.id ?? 0) - (b.id ?? 0)).slice(skip, skip + top); if (fullResponse) { return { content: [{ type: "text", text: JSON.stringify(paginatedThreads, null, 2) }], }; } // Return trimmed thread data focusing on essential information const trimmedThreads = paginatedThreads?.map((thread) => ({ id: thread.id, publishedDate: thread.publishedDate, lastUpdatedDate: thread.lastUpdatedDate, status: thread.status, comments: trimComments(thread.comments), })); return { content: [{ type: "text", text: JSON.stringify(trimmedThreads, null, 2) }], }; }
  • Input schema using Zod validators for the tool's parameters.
    repositoryId: z.string().describe("The ID of the repository where the pull request is located."), pullRequestId: z.number().describe("The ID of the pull request for which to retrieve threads."), project: z.string().optional().describe("Project ID or project name (optional)"), iteration: z.number().optional().describe("The iteration ID for which to retrieve threads. Optional, defaults to the latest iteration."), baseIteration: z.number().optional().describe("The base iteration ID for which to retrieve threads. Optional, defaults to the latest base iteration."), top: z.number().default(100).describe("The maximum number of threads to return."), skip: z.number().default(0).describe("The number of threads to skip."), fullResponse: z.boolean().optional().default(false).describe("Return full thread JSON response instead of trimmed data."), },
  • Registration of the tool using McpServer.tool() with name from REPO_TOOLS.list_pull_request_threads, description, input schema, and handler.
    REPO_TOOLS.list_pull_request_threads, "Retrieve a list of comment threads for a pull request.", { repositoryId: z.string().describe("The ID of the repository where the pull request is located."), pullRequestId: z.number().describe("The ID of the pull request for which to retrieve threads."), project: z.string().optional().describe("Project ID or project name (optional)"), iteration: z.number().optional().describe("The iteration ID for which to retrieve threads. Optional, defaults to the latest iteration."), baseIteration: z.number().optional().describe("The base iteration ID for which to retrieve threads. Optional, defaults to the latest base iteration."), top: z.number().default(100).describe("The maximum number of threads to return."), skip: z.number().default(0).describe("The number of threads to skip."), fullResponse: z.boolean().optional().default(false).describe("Return full thread JSON response instead of trimmed data."), }, async ({ repositoryId, pullRequestId, project, iteration, baseIteration, top, skip, fullResponse }) => { const connection = await connectionProvider(); const gitApi = await connection.getGitApi(); const threads = await gitApi.getThreads(repositoryId, pullRequestId, project, iteration, baseIteration); const paginatedThreads = threads?.sort((a, b) => (a.id ?? 0) - (b.id ?? 0)).slice(skip, skip + top); if (fullResponse) { return { content: [{ type: "text", text: JSON.stringify(paginatedThreads, null, 2) }], }; } // Return trimmed thread data focusing on essential information const trimmedThreads = paginatedThreads?.map((thread) => ({ id: thread.id, publishedDate: thread.publishedDate, lastUpdatedDate: thread.lastUpdatedDate, status: thread.status, comments: trimComments(thread.comments), })); return { content: [{ type: "text", text: JSON.stringify(trimmedThreads, null, 2) }], }; } );
  • Helper function used in the handler to trim and filter comments, excluding deleted ones and selecting essential properties.
    function trimComments(comments: any[] | undefined | null) { return comments ?.filter((comment) => !comment.isDeleted) // Exclude deleted comments ?.map((comment) => ({ id: comment.id, author: { displayName: comment.author?.displayName, uniqueName: comment.author?.uniqueName, }, content: comment.content, publishedDate: comment.publishedDate, lastUpdatedDate: comment.lastUpdatedDate, lastContentUpdatedDate: comment.lastContentUpdatedDate, })); }
  • Mapping in REPO_TOOLS constant from internal name to the tool name string used in registration.
    list_pull_request_threads: "repo_list_pull_request_threads",

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/ennuiii/DevOpsMcpPAT'

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