MCPcopy
hub / github.com/github/github-mcp-server / AddIssueComment

Function AddIssueComment

pkg/github/issues.go:1105–1289  ·  view source on GitHub ↗

AddIssueComment creates a tool to add a comment or reaction to an issue.

(t translations.TranslationHelperFunc)

Source from the content-addressed store, hash-verified

1103
1104// AddIssueComment creates a tool to add a comment or reaction to an issue.
1105func AddIssueComment(t translations.TranslationHelperFunc) inventory.ServerTool {
1106 return NewTool(
1107 ToolsetMetadataIssues,
1108 mcp.Tool{
1109 Name: "add_issue_comment",
1110 Description: t("TOOL_ADD_ISSUE_COMMENT_DESCRIPTION", "Add a comment and/or reaction to a specific issue or issue comment in a GitHub repository. Use this tool with pull requests as well (in this case pass pull request number as issue_number), but only if user is not asking specifically to add or react to review comments. At least one of body or reaction is required."),
1111 Annotations: &mcp.ToolAnnotations{
1112 Title: t("TOOL_ADD_ISSUE_COMMENT_USER_TITLE", "Add comment to issue or pull request"),
1113 ReadOnlyHint: false,
1114 },
1115 InputSchema: &jsonschema.Schema{
1116 Type: "object",
1117 Properties: map[string]*jsonschema.Schema{
1118 "owner": {
1119 Type: "string",
1120 Description: "Repository owner",
1121 },
1122 "repo": {
1123 Type: "string",
1124 Description: "Repository name",
1125 },
1126 "issue_number": {
1127 Type: "number",
1128 Description: "Issue or pull request number to comment on or react to.",
1129 },
1130 "comment_id": {
1131 Type: "number",
1132 Description: "The numeric ID of the issue or pull request comment to react to. Use this for reactions to comments; omit it to react to the issue or pull request itself. Cannot be combined with body.",
1133 Minimum: jsonschema.Ptr(1.0),
1134 },
1135 "body": {
1136 Type: "string",
1137 Description: "Comment content. Required unless reaction is provided.",
1138 },
1139 "reaction": {
1140 Type: "string",
1141 Description: "Emoji reaction to add. Required unless body is provided.",
1142 Enum: []any{"+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", "eyes"},
1143 },
1144 },
1145 Required: []string{"owner", "repo", "issue_number"},
1146 },
1147 },
1148 []scopes.Scope{scopes.Repo},
1149 func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
1150 owner, err := RequiredParam[string](args, "owner")
1151 if err != nil {
1152 return utils.NewToolResultError(err.Error()), nil, nil
1153 }
1154 repo, err := RequiredParam[string](args, "repo")
1155 if err != nil {
1156 return utils.NewToolResultError(err.Error()), nil, nil
1157 }
1158 issueNumber, err := RequiredInt(args, "issue_number")
1159 if err != nil {
1160 return utils.NewToolResultError(err.Error()), nil, nil
1161 }
1162 var commentID int64

Callers 2

AllToolsFunction · 0.85
TestAddIssueCommentFunction · 0.85

Calls 10

NewToolResultErrorFunction · 0.92
NewToolResultTextFunction · 0.92
NewToolFunction · 0.85
RequiredIntFunction · 0.85
RequiredBigIntFunction · 0.85
issueNumberFromIssueURLFunction · 0.85
CloseMethod · 0.80
GetClientMethod · 0.65
ErrorMethod · 0.45

Tested by 1

TestAddIssueCommentFunction · 0.68