repo_list_pull_request_thread_comments
Retrieve and manage comments in a pull request thread within Azure DevOps repositories. Input repository ID, pull request ID, and thread ID to access, filter, and organize feedback efficiently.
Instructions
Retrieve a list of comments in a pull request thread.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fullResponse | No | Return full comment JSON response instead of trimmed data. | |
| project | No | Project ID or project name (optional) | |
| pullRequestId | Yes | The ID of the pull request for which to retrieve thread comments. | |
| repositoryId | Yes | The ID of the repository where the pull request is located. | |
| skip | No | The number of comments to skip. | |
| threadId | Yes | The ID of the thread for which to retrieve comments. | |
| top | No | The maximum number of comments to return. |
Implementation Reference
- src/tools/repos.ts:459-479 (handler)The handler function that implements the core logic: fetches comments via Azure DevOps Git API's getComments method for the specified repository, pull request, and thread; applies sorting and pagination; optionally trims comments using the trimComments helper; returns JSON-formatted response.async ({ repositoryId, pullRequestId, threadId, project, top, skip, fullResponse }) => { const connection = await connectionProvider(); const gitApi = await connection.getGitApi(); // Get thread comments - GitApi uses getComments for retrieving comments from a specific thread const comments = await gitApi.getComments(repositoryId, pullRequestId, threadId, project); const paginatedComments = comments?.sort((a, b) => (a.id ?? 0) - (b.id ?? 0)).slice(skip, skip + top); if (fullResponse) { return { content: [{ type: "text", text: JSON.stringify(paginatedComments, null, 2) }], }; } // Return trimmed comment data focusing on essential information const trimmedComments = trimComments(paginatedComments); return { content: [{ type: "text", text: JSON.stringify(trimmedComments, null, 2) }], };
- src/tools/repos.ts:450-457 (schema)Zod schema defining input parameters for the tool, including required repositoryId, pullRequestId, threadId, and optional pagination and project 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 thread comments."), threadId: z.number().describe("The ID of the thread for which to retrieve comments."), project: z.string().optional().describe("Project ID or project name (optional)"), top: z.number().default(100).describe("The maximum number of comments to return."), skip: z.number().default(0).describe("The number of comments to skip."), fullResponse: z.boolean().optional().default(false).describe("Return full comment JSON response instead of trimmed data."),
- src/tools/repos.ts:447-481 (registration)Registers the tool using McpServer.tool() method, referencing the tool name from REPO_TOOLS, providing description, input schema, and handler function.server.tool( REPO_TOOLS.list_pull_request_thread_comments, "Retrieve a list of comments in a pull request thread.", { 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 thread comments."), threadId: z.number().describe("The ID of the thread for which to retrieve comments."), project: z.string().optional().describe("Project ID or project name (optional)"), top: z.number().default(100).describe("The maximum number of comments to return."), skip: z.number().default(0).describe("The number of comments to skip."), fullResponse: z.boolean().optional().default(false).describe("Return full comment JSON response instead of trimmed data."), }, async ({ repositoryId, pullRequestId, threadId, project, top, skip, fullResponse }) => { const connection = await connectionProvider(); const gitApi = await connection.getGitApi(); // Get thread comments - GitApi uses getComments for retrieving comments from a specific thread const comments = await gitApi.getComments(repositoryId, pullRequestId, threadId, project); const paginatedComments = comments?.sort((a, b) => (a.id ?? 0) - (b.id ?? 0)).slice(skip, skip + top); if (fullResponse) { return { content: [{ type: "text", text: JSON.stringify(paginatedComments, null, 2) }], }; } // Return trimmed comment data focusing on essential information const trimmedComments = trimComments(paginatedComments); return { content: [{ type: "text", text: JSON.stringify(trimmedComments, null, 2) }], }; } );
- src/tools/repos.ts:60-73 (helper)Supporting helper function to filter out deleted comments and trim to essential properties (id, author, content, dates), used by the handler for non-full responses.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:32-32 (registration)Part of REPO_TOOLS constant: maps the internal identifier 'list_pull_request_thread_comments' to the public tool name 'repo_list_pull_request_thread_comments' used in registration.list_pull_request_thread_comments: "repo_list_pull_request_thread_comments",