repo_update_pull_request_reviewers
Add or remove reviewers from an Azure DevOps pull request by specifying repository ID, pull request ID, and reviewer IDs. Manage PR reviewers efficiently with this Azure DevOps MCP Server tool.
Instructions
Add or remove reviewers for an existing pull request.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| action | Yes | Action to perform on the reviewers. Can be 'add' or 'remove'. | |
| pullRequestId | Yes | The ID of the pull request to update. | |
| repositoryId | Yes | The ID of the repository where the pull request exists. | |
| reviewerIds | Yes | List of reviewer ids to add or remove from the pull request. |
Implementation Reference
- src/tools/repos.ts:203-227 (handler)The core handler function that implements the tool logic: connects to Azure DevOps Git API, adds reviewers if action='add' using createPullRequestReviewers, or removes them individually if 'remove' using deletePullRequestReviewer, and returns JSON response or confirmation.async ({ repositoryId, pullRequestId, reviewerIds, action }) => { const connection = await connectionProvider(); const gitApi = await connection.getGitApi(); let updatedPullRequest; if (action === "add") { updatedPullRequest = await gitApi.createPullRequestReviewers( reviewerIds.map((id) => ({ id: id })), repositoryId, pullRequestId ); return { content: [{ type: "text", text: JSON.stringify(updatedPullRequest, null, 2) }], }; } else { for (const reviewerId of reviewerIds) { await gitApi.deletePullRequestReviewer(repositoryId, pullRequestId, reviewerId); } return { content: [{ type: "text", text: `Reviewers with IDs ${reviewerIds.join(", ")} removed from pull request ${pullRequestId}.` }], }; } }
- src/tools/repos.ts:197-202 (schema)Input schema using Zod validation for the tool parameters: repositoryId (string), pullRequestId (number), reviewerIds (array of strings), action (enum: add/remove).{ repositoryId: z.string().describe("The ID of the repository where the pull request exists."), pullRequestId: z.number().describe("The ID of the pull request to update."), reviewerIds: z.array(z.string()).describe("List of reviewer ids to add or remove from the pull request."), action: z.enum(["add", "remove"]).describe("Action to perform on the reviewers. Can be 'add' or 'remove'."), },
- src/tools/repos.ts:194-228 (registration)Registers the 'repo_update_pull_request_reviewers' tool on the McpServer using the name from REPO_TOOLS constant, with description, input schema, and handler function.server.tool( REPO_TOOLS.update_pull_request_reviewers, "Add or remove reviewers for an existing pull request.", { repositoryId: z.string().describe("The ID of the repository where the pull request exists."), pullRequestId: z.number().describe("The ID of the pull request to update."), reviewerIds: z.array(z.string()).describe("List of reviewer ids to add or remove from the pull request."), action: z.enum(["add", "remove"]).describe("Action to perform on the reviewers. Can be 'add' or 'remove'."), }, async ({ repositoryId, pullRequestId, reviewerIds, action }) => { const connection = await connectionProvider(); const gitApi = await connection.getGitApi(); let updatedPullRequest; if (action === "add") { updatedPullRequest = await gitApi.createPullRequestReviewers( reviewerIds.map((id) => ({ id: id })), repositoryId, pullRequestId ); return { content: [{ type: "text", text: JSON.stringify(updatedPullRequest, null, 2) }], }; } else { for (const reviewerId of reviewerIds) { await gitApi.deletePullRequestReviewer(repositoryId, pullRequestId, reviewerId); } return { content: [{ type: "text", text: `Reviewers with IDs ${reviewerIds.join(", ")} removed from pull request ${pullRequestId}.` }], }; } } );
- src/tools/repos.ts:38-38 (registration)Part of REPO_TOOLS constant that maps the internal identifier to the tool name string used in server.tool registration.update_pull_request_reviewers: "repo_update_pull_request_reviewers",