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
| Name | Required | Description | Default |
|---|---|---|---|
| baseIteration | No | The base iteration ID for which to retrieve threads. Optional, defaults to the latest base iteration. | |
| fullResponse | No | Return full thread JSON response instead of trimmed data. | |
| iteration | No | The iteration ID for which to retrieve threads. Optional, defaults to the latest iteration. | |
| project | No | Project ID or project name (optional) | |
| pullRequestId | Yes | The ID of the pull request for which to retrieve threads. | |
| repositoryId | Yes | The ID of the repository where the pull request is located. | |
| skip | No | The number of threads to skip. | |
| top | No | The maximum number of threads to return. |
Implementation Reference
- src/tools/repos.ts:418-444 (handler)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) }], }; }
- src/tools/repos.ts:409-417 (schema)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."), },
- src/tools/repos.ts:406-445 (registration)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) }], }; } );
- src/tools/repos.ts:60-74 (helper)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, })); }
- src/tools/repos.ts:31-31 (registration)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",