Skip to content

Commit 30da9da

Browse files
timrogersCopilot
andcommitted
Improve reaction tool responses and wording
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>
1 parent 94c6f2c commit 30da9da

6 files changed

Lines changed: 34 additions & 15 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,14 +846,14 @@ The following sets of tools are available:
846846
- `owner`: Repository owner (string, required)
847847
- `repo`: Repository name (string, required)
848848

849-
- **add_issue_comment_reaction** - Add Issue Comment Reaction
849+
- **add_issue_comment_reaction** - Add Reaction to Issue or Pull Request Comment
850850
- **Required OAuth Scopes**: `repo`
851851
- `comment_id`: The issue comment ID (number, required)
852852
- `content`: The emoji reaction type (string, required)
853853
- `owner`: Repository owner (username or organization) (string, required)
854854
- `repo`: Repository name (string, required)
855855

856-
- **add_issue_reaction** - Add Issue Reaction
856+
- **add_issue_reaction** - Add Reaction to Issue or Pull Request
857857
- **Required OAuth Scopes**: `repo`
858858
- `content`: The emoji reaction type (string, required)
859859
- `issue_number`: The issue number (number, required)

pkg/github/__toolsnaps__/add_issue_comment_reaction.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"annotations": {
33
"destructiveHint": false,
44
"openWorldHint": true,
5-
"title": "Add Issue Comment Reaction"
5+
"title": "Add Reaction to Issue or Pull Request Comment"
66
},
7-
"description": "Add a reaction to an issue comment.",
7+
"description": "Add a reaction to an issue or pull request comment.",
88
"inputSchema": {
99
"properties": {
1010
"comment_id": {

pkg/github/__toolsnaps__/add_issue_reaction.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"annotations": {
33
"destructiveHint": false,
44
"openWorldHint": true,
5-
"title": "Add Issue Reaction"
5+
"title": "Add Reaction to Issue or Pull Request"
66
},
7-
"description": "Add a reaction to an issue.",
7+
"description": "Add a reaction to an issue or pull request.",
88
"inputSchema": {
99
"properties": {
1010
"content": {

pkg/github/granular_tools_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package github
22

33
import (
44
"context"
5+
"encoding/json"
56
"net/http"
67
"strings"
78
"testing"
@@ -2091,6 +2092,11 @@ func TestAddIssueReaction(t *testing.T) {
20912092
assert.True(t, result.IsError)
20922093
} else {
20932094
assert.False(t, result.IsError)
2095+
textContent := getTextResult(t, result)
2096+
var response MinimalResponse
2097+
require.NoError(t, json.Unmarshal([]byte(textContent.Text), &response))
2098+
assert.Equal(t, "12345", response.ID)
2099+
assert.Equal(t, "https://api.github.com/repos/owner/repo/issues/42/reactions/12345", response.URL)
20942100
}
20952101
})
20962102
}
@@ -2146,6 +2152,11 @@ func TestAddIssueCommentReaction(t *testing.T) {
21462152
assert.True(t, result.IsError)
21472153
} else {
21482154
assert.False(t, result.IsError)
2155+
textContent := getTextResult(t, result)
2156+
var response MinimalResponse
2157+
require.NoError(t, json.Unmarshal([]byte(textContent.Text), &response))
2158+
assert.Equal(t, "67890", response.ID)
2159+
assert.Equal(t, "https://api.github.com/repos/owner/repo/issues/comments/999/reactions/67890", response.URL)
21492160
}
21502161
})
21512162
}
@@ -2201,6 +2212,11 @@ func TestAddPullRequestReviewCommentReaction(t *testing.T) {
22012212
assert.True(t, result.IsError)
22022213
} else {
22032214
assert.False(t, result.IsError)
2215+
textContent := getTextResult(t, result)
2216+
var response MinimalResponse
2217+
require.NoError(t, json.Unmarshal([]byte(textContent.Text), &response))
2218+
assert.Equal(t, "54321", response.ID)
2219+
assert.Equal(t, "https://api.github.com/repos/owner/repo/pulls/comments/888/reactions/54321", response.URL)
22042220
}
22052221
})
22062222
}

pkg/github/issues_granular.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,15 +1199,15 @@ func GranularSetIssueFields(t translations.TranslationHelperFunc) inventory.Serv
11991199
return st
12001200
}
12011201

1202-
// AddIssueReaction adds a reaction to an issue.
1202+
// AddIssueReaction adds a reaction to an issue or pull request.
12031203
func AddIssueReaction(t translations.TranslationHelperFunc) inventory.ServerTool {
12041204
st := NewTool(
12051205
ToolsetMetadataIssues,
12061206
mcp.Tool{
12071207
Name: "add_issue_reaction",
1208-
Description: t("TOOL_ADD_ISSUE_REACTION_DESCRIPTION", "Add a reaction to an issue."),
1208+
Description: t("TOOL_ADD_ISSUE_REACTION_DESCRIPTION", "Add a reaction to an issue or pull request."),
12091209
Annotations: &mcp.ToolAnnotations{
1210-
Title: t("TOOL_ADD_ISSUE_REACTION_USER_TITLE", "Add Issue Reaction"),
1210+
Title: t("TOOL_ADD_ISSUE_REACTION_USER_TITLE", "Add Reaction to Issue or Pull Request"),
12111211
ReadOnlyHint: false,
12121212
DestructiveHint: jsonschema.Ptr(false),
12131213
OpenWorldHint: jsonschema.Ptr(true),
@@ -1268,7 +1268,8 @@ func AddIssueReaction(t translations.TranslationHelperFunc) inventory.ServerTool
12681268
defer func() { _ = resp.Body.Close() }()
12691269

12701270
r, err := json.Marshal(MinimalResponse{
1271-
ID: fmt.Sprintf("%d", reaction.GetID()),
1271+
ID: fmt.Sprintf("%d", reaction.GetID()),
1272+
URL: fmt.Sprintf("%srepos/%s/%s/issues/%d/reactions/%d", client.BaseURL(), owner, repo, issueNumber, reaction.GetID()),
12721273
})
12731274
if err != nil {
12741275
return utils.NewToolResultErrorFromErr("failed to marshal response", err), nil, nil
@@ -1279,15 +1280,15 @@ func AddIssueReaction(t translations.TranslationHelperFunc) inventory.ServerTool
12791280
return st
12801281
}
12811282

1282-
// AddIssueCommentReaction adds a reaction to an issue comment.
1283+
// AddIssueCommentReaction adds a reaction to an issue or pull request comment.
12831284
func AddIssueCommentReaction(t translations.TranslationHelperFunc) inventory.ServerTool {
12841285
st := NewTool(
12851286
ToolsetMetadataIssues,
12861287
mcp.Tool{
12871288
Name: "add_issue_comment_reaction",
1288-
Description: t("TOOL_ADD_ISSUE_COMMENT_REACTION_DESCRIPTION", "Add a reaction to an issue comment."),
1289+
Description: t("TOOL_ADD_ISSUE_COMMENT_REACTION_DESCRIPTION", "Add a reaction to an issue or pull request comment."),
12891290
Annotations: &mcp.ToolAnnotations{
1290-
Title: t("TOOL_ADD_ISSUE_COMMENT_REACTION_USER_TITLE", "Add Issue Comment Reaction"),
1291+
Title: t("TOOL_ADD_ISSUE_COMMENT_REACTION_USER_TITLE", "Add Reaction to Issue or Pull Request Comment"),
12911292
ReadOnlyHint: false,
12921293
DestructiveHint: jsonschema.Ptr(false),
12931294
OpenWorldHint: jsonschema.Ptr(true),
@@ -1348,7 +1349,8 @@ func AddIssueCommentReaction(t translations.TranslationHelperFunc) inventory.Ser
13481349
defer func() { _ = resp.Body.Close() }()
13491350

13501351
r, err := json.Marshal(MinimalResponse{
1351-
ID: fmt.Sprintf("%d", reaction.GetID()),
1352+
ID: fmt.Sprintf("%d", reaction.GetID()),
1353+
URL: fmt.Sprintf("%srepos/%s/%s/issues/comments/%d/reactions/%d", client.BaseURL(), owner, repo, commentID, reaction.GetID()),
13521354
})
13531355
if err != nil {
13541356
return utils.NewToolResultErrorFromErr("failed to marshal response", err), nil, nil

pkg/github/pullrequests_granular.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,8 @@ func AddPullRequestReviewCommentReaction(t translations.TranslationHelperFunc) i
827827
defer func() { _ = resp.Body.Close() }()
828828

829829
r, err := json.Marshal(MinimalResponse{
830-
ID: fmt.Sprintf("%d", reaction.GetID()),
830+
ID: fmt.Sprintf("%d", reaction.GetID()),
831+
URL: fmt.Sprintf("%srepos/%s/%s/pulls/comments/%d/reactions/%d", client.BaseURL(), owner, repo, commentID, reaction.GetID()),
831832
})
832833
if err != nil {
833834
return utils.NewToolResultErrorFromErr("failed to marshal response", err), nil, nil

0 commit comments

Comments
 (0)