Skip to content

Add label support to update_pull_request tool #697

@Meir017

Description

@Meir017

Problem Statement

Currently, the update_pull_request tool doesn't support updating labels on existing pull requests in Azure DevOps. While we recently added label support to create_pull_request, users cannot modify labels after a PR has been created through the MCP tools.

Proposed Solution

Add an optional labels parameter to the update_pull_request tool that accepts an array of label names. The behavior should follow the same pattern as other optional update fields:

  • undefined (not provided): Don't modify existing labels
  • [] (empty array): Remove all labels from the PR
  • ["label1", "label2"]: Replace existing labels with the specified ones

Implementation Approach

Similar to the create_pull_request implementation:

  1. Add an optional labels parameter to the update_pull_request tool schema (array of strings, optional)
  2. Map the label names to WebApiTagDefinition[] format when provided: labels.map((label) => ({ name: label }))
  3. Only include labels in the update request if the parameter is defined:
    if (labels !== undefined) {
      updateRequest.labels = labels.map((label) => ({ name: label }));
    }
  4. Add comprehensive tests to verify:
    • Labels are not updated when parameter is undefined
    • All labels are removed when empty array is provided
    • Labels are replaced when array with values is provided

Benefits

  • Completes the label management story for pull requests
  • Consistent API pattern with other update fields (title, description, etc.)
  • Single API call to update labels instead of separate operations
  • Allows removing all labels by passing empty array

Metadata

Metadata

Assignees

Labels

Approved ✅this issue or pull request has been approvedRepos 📁issue in the repos area

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions