Skip to content

feat: add labels support to create_pull_request tool#2413

Open
yashdesai30 wants to merge 1 commit intogithub:mainfrom
yashdesai30:feat/add-labels-to-create-pull-request
Open

feat: add labels support to create_pull_request tool#2413
yashdesai30 wants to merge 1 commit intogithub:mainfrom
yashdesai30:feat/add-labels-to-create-pull-request

Conversation

@yashdesai30
Copy link
Copy Markdown

@yashdesai30 yashdesai30 commented May 1, 2026

Summary

Add optional labels parameter to the create_pull_request tool, enabling users to apply labels during PR creation in a single step.

Why

Fixes #2417

The create_pull_request tool currently doesn't support adding labels. Users in agentic workflows must make a separate add_label tool call after creating a PR, which is inefficient and unintuitive. Developers naturally think of PR creation as: title + description + labels together.

What changed

  • pkg/github/pullrequests.go: Added labels (string array) to CreatePullRequest InputSchema. After PR creation, calls client.Issues.AddLabelsToIssue to apply labels. If label application fails, returns error with PR number so users know the PR was created.
  • pkg/github/helper_test.go: Added PostReposIssuesLabelsByOwnerByRepoByIssueNumber endpoint constant for mocking.
  • pkg/github/pullrequests_test.go: Added 2 test cases — successful PR creation with labels, and label failure after PR creation.
  • pkg/github/__toolsnaps__/create_pull_request.snap: Updated schema snapshot to include labels.
  • ui/src/apps/pr-write/App.tsx: Added labels state, comma-separated input field, prefill from toolInput, and array conversion on submit.
  • README.md: Auto-generated via script/generate-docs.

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed — Added optional labels array parameter to create_pull_request
  • New tool added

Prompts tested (tool changes only)

  • "Create a pull request on owner/repo from branch feature-x to main with title 'Test PR' and labels bug, enhancement"
  • "Open a PR for this bugfix and label it as priority:high"

Security / limits

  • No security or limits impact
  • Auth / permissions considered
  • Data exposure, filtering, or token/size limits considered

Tool renaming

  • I am renaming tools as part of this PR (e.g. a part of a consolidation effort)
    • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR

Note: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs.

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Not needed
  • Updated (README / docs / examples)

Add optional 'labels' parameter to the create_pull_request tool,
enabling users to apply labels during PR creation.

Since the GitHub REST API doesn't support labels in the PR creation
endpoint, labels are applied in a second step via the Issues API
(POST /repos/{owner}/{repo}/issues/{issue_number}/labels).

Changes:
- Add 'labels' array property to CreatePullRequest InputSchema
- Add post-creation AddLabelsToIssue call in the handler
- Add labels input field to pr-write MCP App UI
- Add test cases for label success and failure scenarios
- Update toolsnap snapshot and README documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add labels support to create_pull_request tool

1 participant