Add reaction tools for issues and pull requests#2732
Open
timrogers wants to merge 13 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds three new MCP write tools that let clients create emoji reactions on GitHub issues, issue comments, and pull request review comments, extending the server’s “write” surface area to cover a core GitHub interaction.
Changes:
- Added three new tools:
add_issue_reaction,add_issue_comment_reaction, andadd_pull_request_review_comment_reaction. - Wired the tools into the global tool inventory and added handler tests with mocked HTTP endpoints.
- Updated generated documentation and added new tool schema snapshots (
__toolsnaps__).
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the three new tools and their parameters in the generated tool listing. |
| pkg/github/tools.go | Registers the three new tools in AllTools so they’re available to clients. |
| pkg/github/issues_granular.go | Implements add_issue_reaction and add_issue_comment_reaction tool schemas and handlers. |
| pkg/github/pullrequests_granular.go | Implements add_pull_request_review_comment_reaction tool schema and handler. |
| pkg/github/helper_test.go | Adds mocked endpoint patterns for the reactions REST endpoints. |
| pkg/github/granular_tools_test.go | Adds toolsnap coverage and handler tests for the new reaction tools. |
| pkg/github/toolsnaps/add_issue_reaction.snap | New snapshot for add_issue_reaction tool schema. |
| pkg/github/toolsnaps/add_issue_comment_reaction.snap | New snapshot for add_issue_comment_reaction tool schema. |
| pkg/github/toolsnaps/add_pull_request_review_comment_reaction.snap | New snapshot for add_pull_request_review_comment_reaction tool schema. |
Copilot's findings
- Files reviewed: 9/9 changed files
- Comments generated: 3
Implement three granular-only tools for adding emoji reactions: - add_issue_reaction: Add reaction to an issue - add_issue_comment_reaction: Add reaction to an issue comment - add_pull_request_review_comment_reaction: Add reaction to a PR review comment All tools are feature-flagged with FeatureFlagEnable set to enable them only when clients request granular toolsets. Tools use go-github's Reactions service and return minimal ID response on success (HTTP 201). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove feature flag gates from reaction tools so they're available to all clients regardless of granular toolset preference. Reaction tools are naturally atomic operations and work equally well in both modes. Updates test expectations to exclude reaction tools from granular-only test assertions, since they're now always available. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
44c2a5e to
94c6f2c
Compare
Contributor
Author
|
Tested manually locally and this is all working. We could consider adding tools to remove reactions, but I think this is a good incremental step and we can choose to add more later. |
Return reaction URLs in minimal responses and clarify issue tools apply to pull requests where applicable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A-Georgiou
previously approved these changes
Jun 19, 2026
phillipschandler19-web
left a comment
There was a problem hiding this comment.
internal/ghmcp/server_test.go.github/actions/build-ui/action.ymlREADME.mdhttps://github.com/modelcontextprotocol/modelcontextprotocol/issues/1489
Keep the standalone reaction tools behind granular feature flags to avoid expanding the default tool count. Add optional reaction support to the existing issue comment and pull request comment reply tools, requiring at least one of body or reaction. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Jun 23, 2026
Document that PR review comment reaction inputs require the numeric review comment ID, not the GraphQL review thread node ID returned by review thread APIs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4 tasks
Add optional comment_id support so the default add_issue_comment tool can react to a specific issue or pull request comment without exposing a separate default reaction tool. Keep body creation tied to issue_number and require reaction targets to provide either issue_number or comment_id. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment on lines
611
to
627
| { | ||
| name: "comment creation fails", | ||
| mockedClient: MockHTTPClientWithHandlers(map[string]http.HandlerFunc{ | ||
| PostReposIssuesCommentsByOwnerByRepoByIssueNumber: http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { | ||
| w.WriteHeader(http.StatusUnprocessableEntity) | ||
| _, _ = w.Write([]byte(`{"message": "Invalid request"}`)) | ||
| }), | ||
| }), | ||
| requestArgs: map[string]any{ | ||
| "owner": "owner", | ||
| "repo": "repo", | ||
| "issue_number": float64(42), | ||
| "body": "", | ||
| "body": "This is a test comment", | ||
| }, | ||
| expectError: false, | ||
| expectedErrMsg: "missing required parameter: body", | ||
| expectedErrMsg: "failed to create comment", | ||
| }, |
Comment on lines
+1210
to
+1213
| createdComment, resp, err := client.Issues.CreateComment(ctx, owner, repo, issueNumber, comment) | ||
| if err != nil { | ||
| return utils.NewToolResultErrorFromErr("failed to read response body", err), nil, nil | ||
| return utils.NewToolResultErrorFromErr("failed to create comment", err), nil, nil | ||
| } |
Comment on lines
+1190
to
+1192
| if hasReaction && !hasIssueNumber && !hasCommentID { | ||
| return utils.NewToolResultError("issue_number or comment_id is required when reaction is provided"), nil, nil | ||
| } |
Comment on lines
+215
to
+219
| ListIssueFields(t), | ||
| IssueWrite(t), | ||
| AddIssueComment(t), | ||
| AddIssueReaction(t), | ||
| AddIssueCommentReaction(t), |
Apply reactions before creating comments or replies so retrying a failed combined call cannot duplicate the non-idempotent comment operation. Also reject issue comment IDs without a reaction target to avoid silently ignoring the field. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment on lines
+1187
to
+1195
| if hasBody && !hasIssueNumber { | ||
| return utils.NewToolResultError("issue_number is required when body is provided"), nil, nil | ||
| } | ||
| if hasReaction && !hasIssueNumber && !hasCommentID { | ||
| return utils.NewToolResultError("issue_number or comment_id is required when reaction is provided"), nil, nil | ||
| } | ||
| if hasCommentID && !hasReaction { | ||
| return utils.NewToolResultError("comment_id can only be provided when reaction is provided"), nil, nil | ||
| } |
Comment on lines
+1202
to
+1204
| // AddIssueReaction adds a reaction to an issue or pull request. | ||
| func AddIssueReaction(t translations.TranslationHelperFunc) inventory.ServerTool { | ||
| st := NewTool( |
Comment on lines
+761
to
+763
| // AddPullRequestReviewCommentReaction adds a reaction to a pull request review comment. | ||
| func AddPullRequestReviewCommentReaction(t translations.TranslationHelperFunc) inventory.ServerTool { | ||
| st := NewTool( |
Keep standalone reaction tool registrations next to the granular issue and pull request tools they belong with, so the default compound tool sections stay focused. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rename the standalone reaction tool constructors to match the granular tool naming convention and clarify issue comment reaction IDs for pull request comments. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Copilot's findings
Comments suppressed due to low confidence (1)
pkg/github/issues_test.go:631
- In this test, the failure case sets expectedErrMsg but the assertion path does not verify the tool call actually returned an error result (result.IsError). This can allow regressions where the tool returns a non-error result containing the substring. Align the failure handling with the rest of the suite by asserting result.IsError and reading the error via getErrorResult().
expectedErrMsg: "failed to create comment",
},
}
for _, tc := range tests {
- Files reviewed: 16/16 changed files
- Comments generated: 0 new
Make issue_number required on the consolidated add_issue_comment tool even when reacting to a specific issue comment, keeping the default tool input shape explicit. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment on lines
620
to
628
| requestArgs: map[string]any{ | ||
| "owner": "owner", | ||
| "repo": "repo", | ||
| "issue_number": float64(42), | ||
| "body": "", | ||
| "body": "This is a test comment", | ||
| }, | ||
| expectError: false, | ||
| expectedErrMsg: "missing required parameter: body", | ||
| expectedErrMsg: "failed to create comment", | ||
| }, |
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 reaction support for issues, issue comments, and pull request review comments while keeping standalone reaction tools behind the granular tool feature flags.
Default users can add reactions through existing comment tools to avoid adding more default tools:
add_issue_commentcan add an issue/PR comment, add a reaction to an issue/PR, add a reaction to an issue/PR timeline comment, or combine a comment with a reaction.add_reply_to_pull_request_commentcan reply to a pull request review comment, add a reaction to a pull request review comment, or do both.Granular users also get standalone tools:
add_issue_reactionadd_issue_comment_reactionadd_pull_request_review_comment_reactionWhy
Reactions are a fundamental part of GitHub's interaction model. Clients should be able to add reactions programmatically just as they can create issues, comments, and reviews, without increasing the default tool surface more than necessary.
What changed
#discussion_r...ID rather than a GraphQL review thread node ID.MCP impact
add_issue_commentandadd_reply_to_pull_request_commentnow support reactions.Prompts tested (tool changes only)
Security / limits
Tool renaming
Lint & tests
./script/lint./script/testDocs
script/generate-docs.pkg/github/__toolsnaps__/.Closes #2757