-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Add optional rationale parameter to update_issue_type tool
#2458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alondahari
merged 4 commits into
main
from
alondahari/add-rationale-to-update-issue-type
May 13, 2026
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2ce2ced
Add optional rationale parameter to update_issue_type tool
alondahari 5cfd36a
Validate issue type rationale input
Copilot 7485ee2
Format issue type rationale tests
Copilot 1876ee4
Merge branch 'main' into alondahari/add-rationale-to-update-issue-type
omgitsads File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -309,27 +309,124 @@ func GranularUpdateIssueMilestone(t translations.TranslationHelperFunc) inventor | |
| ) | ||
| } | ||
|
|
||
| // issueTypeWithRationale represents the object form of the issue type field, | ||
| // allowing a rationale to be sent alongside the type name. | ||
| type issueTypeWithRationale struct { | ||
| Value string `json:"value"` | ||
| Rationale string `json:"rationale"` | ||
| } | ||
|
|
||
| // issueTypeUpdateRequest is a custom request body for updating an issue type | ||
| // with an optional rationale, using the object form that the REST API accepts. | ||
| type issueTypeUpdateRequest struct { | ||
| Type issueTypeWithRationale `json:"type"` | ||
| } | ||
|
|
||
| // GranularUpdateIssueType creates a tool to update an issue's type. | ||
| func GranularUpdateIssueType(t translations.TranslationHelperFunc) inventory.ServerTool { | ||
| return issueUpdateTool(t, | ||
| "update_issue_type", | ||
| "Update the type of an existing issue (e.g. 'bug', 'feature').", | ||
| "Update Issue Type", | ||
| map[string]*jsonschema.Schema{ | ||
| "issue_type": { | ||
| Type: "string", | ||
| Description: "The issue type to set", | ||
| st := NewTool( | ||
| ToolsetMetadataIssues, | ||
| mcp.Tool{ | ||
| Name: "update_issue_type", | ||
| Description: t("TOOL_UPDATE_ISSUE_TYPE_DESCRIPTION", "Update the type of an existing issue (e.g. 'bug', 'feature')."), | ||
| Annotations: &mcp.ToolAnnotations{ | ||
| Title: t("TOOL_UPDATE_ISSUE_TYPE_USER_TITLE", "Update Issue Type"), | ||
| ReadOnlyHint: false, | ||
| DestructiveHint: jsonschema.Ptr(false), | ||
| OpenWorldHint: jsonschema.Ptr(true), | ||
| }, | ||
| InputSchema: &jsonschema.Schema{ | ||
| Type: "object", | ||
| Properties: map[string]*jsonschema.Schema{ | ||
| "owner": { | ||
| Type: "string", | ||
| Description: "Repository owner (username or organization)", | ||
| }, | ||
| "repo": { | ||
| Type: "string", | ||
| Description: "Repository name", | ||
| }, | ||
| "issue_number": { | ||
| Type: "number", | ||
| Description: "The issue number to update", | ||
| Minimum: jsonschema.Ptr(1.0), | ||
| }, | ||
| "issue_type": { | ||
| Type: "string", | ||
| Description: "The issue type to set", | ||
| }, | ||
| "rationale": { | ||
| Type: "string", | ||
| Description: "One concise sentence explaining what specifically about the issue led you to choose this type. " + | ||
| "State the concrete signal (e.g. 'Reports a crash when saving' → bug, 'Asks for dark mode support' → feature).", | ||
| MaxLength: jsonschema.Ptr(280), | ||
| }, | ||
| }, | ||
| Required: []string{"owner", "repo", "issue_number", "issue_type"}, | ||
| }, | ||
| }, | ||
| []string{"issue_type"}, | ||
| func(args map[string]any) (*github.IssueRequest, error) { | ||
| []scopes.Scope{scopes.Repo}, | ||
| func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) { | ||
| owner, err := RequiredParam[string](args, "owner") | ||
| if err != nil { | ||
| return utils.NewToolResultError(err.Error()), nil, nil | ||
| } | ||
| repo, err := RequiredParam[string](args, "repo") | ||
| if err != nil { | ||
| return utils.NewToolResultError(err.Error()), nil, nil | ||
| } | ||
| issueNumber, err := RequiredInt(args, "issue_number") | ||
| if err != nil { | ||
| return utils.NewToolResultError(err.Error()), nil, nil | ||
| } | ||
| issueType, err := RequiredParam[string](args, "issue_type") | ||
| if err != nil { | ||
| return nil, err | ||
| return utils.NewToolResultError(err.Error()), nil, nil | ||
| } | ||
| rationale, _ := OptionalParam[string](args, "rationale") | ||
|
|
||
| client, err := deps.GetClient(ctx) | ||
| if err != nil { | ||
| return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil | ||
| } | ||
|
|
||
| var body any | ||
| if rationale != "" { | ||
| body = &issueTypeUpdateRequest{ | ||
| Type: issueTypeWithRationale{ | ||
| Value: issueType, | ||
| Rationale: rationale, | ||
| }, | ||
|
Comment on lines
+400
to
+406
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 5cfd36a. |
||
| } | ||
| } else { | ||
| body = &github.IssueRequest{Type: &issueType} | ||
| } | ||
|
|
||
| apiURL := fmt.Sprintf("repos/%s/%s/issues/%d", owner, repo, issueNumber) | ||
| req, err := client.NewRequest("PATCH", apiURL, body) | ||
| if err != nil { | ||
| return utils.NewToolResultErrorFromErr("failed to create request", err), nil, nil | ||
| } | ||
|
|
||
| issue := &github.Issue{} | ||
| resp, err := client.Do(ctx, req, issue) | ||
| if err != nil { | ||
| return ghErrors.NewGitHubAPIErrorResponse(ctx, "failed to update issue", resp, err), nil, nil | ||
| } | ||
| defer func() { _ = resp.Body.Close() }() | ||
|
|
||
| r, err := json.Marshal(MinimalResponse{ | ||
| ID: fmt.Sprintf("%d", issue.GetID()), | ||
| URL: issue.GetHTMLURL(), | ||
| }) | ||
| if err != nil { | ||
| return utils.NewToolResultErrorFromErr("failed to marshal response", err), nil, nil | ||
| } | ||
| return &github.IssueRequest{Type: &issueType}, nil | ||
| return utils.NewToolResultText(string(r)), nil, nil | ||
| }, | ||
| ) | ||
| st.FeatureFlagEnable = FeatureFlagIssuesGranular | ||
| return st | ||
| } | ||
|
|
||
| // GranularUpdateIssueState creates a tool to update an issue's state. | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 5cfd36a.