feat: add labels support to create_pull_request tool#2413
Open
yashdesai30 wants to merge 1 commit intogithub:mainfrom
Open
feat: add labels support to create_pull_request tool#2413yashdesai30 wants to merge 1 commit intogithub:mainfrom
yashdesai30 wants to merge 1 commit intogithub:mainfrom
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add optional
labelsparameter to thecreate_pull_requesttool, enabling users to apply labels during PR creation in a single step.Why
Fixes #2417
The
create_pull_requesttool currently doesn't support adding labels. Users in agentic workflows must make a separateadd_labeltool 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: Addedlabels(string array) toCreatePullRequestInputSchema. After PR creation, callsclient.Issues.AddLabelsToIssueto apply labels. If label application fails, returns error with PR number so users know the PR was created.pkg/github/helper_test.go: AddedPostReposIssuesLabelsByOwnerByRepoByIssueNumberendpoint 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 includelabels.ui/src/apps/pr-write/App.tsx: Added labels state, comma-separated input field, prefill fromtoolInput, and array conversion on submit.README.md: Auto-generated viascript/generate-docs.MCP impact
labelsarray parameter tocreate_pull_requestPrompts tested (tool changes only)
Security / limits
Tool renaming
deprecated_tool_aliases.goNote: 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
./script/lint./script/testDocs