代码拉取完成,页面将自动刷新
package issues
import (
"context"
"fmt"
"gitee.com/oschina/mcp-gitee/operations/types"
"gitee.com/oschina/mcp-gitee/utils"
"github.com/mark3labs/mcp-go/mcp"
)
const (
// CommentIssueToolName is the name of the tool
CommentIssueToolName = "comment_issue"
)
// CommentIssueOptions defines the specific options for commenting on an issue
var CommentIssueOptions = []mcp.ToolOption{
mcp.WithString(
"number",
mcp.Description("Issue number (case sensitive, no # prefix needed)"),
mcp.Required(),
),
mcp.WithString(
"body",
mcp.Description("The contents of the comment"),
mcp.Required(),
),
}
// CommentIssueTool defines the tool for commenting on an issue
var CommentIssueTool = func() mcp.Tool {
options := utils.CombineOptions(
[]mcp.ToolOption{
mcp.WithDescription("Create a comment on a repository issue"),
},
BasicOptions,
CommentIssueOptions,
)
return mcp.NewTool(CommentIssueToolName, options...)
}()
// CommentIssueHandleFunc handles the request to comment on an issue
func CommentIssueHandleFunc(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
// Extract required parameters from the request
args, _ := utils.ConvertArgumentsToMap(request.Params.Arguments)
owner := args["owner"].(string)
repo := args["repo"].(string)
number := args["number"].(string)
// Construct the API URL for creating a comment on an issue
apiUrl := fmt.Sprintf("/repos/%s/%s/issues/%s/comments", owner, repo, number)
// Create a new Gitee client with the POST method and the constructed API URL
giteeClient := utils.NewGiteeClient("POST", apiUrl, utils.WithContext(ctx), utils.WithPayload(request.Params.Arguments))
// Define the response structure
comment := &types.IssueComment{}
// Handle the API call and return the result
return giteeClient.HandleMCPResult(comment)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。