27 Star 249 Fork 69

开源中国/mcp-gitee

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
comment_issue.go 1.80 KB
一键复制 编辑 原始数据 按行查看 历史
JJ-H 提交于 2025-06-16 16:10 +08:00 . feat: Support streamable http
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)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/oschina/mcp-gitee.git
git@gitee.com:oschina/mcp-gitee.git
oschina
mcp-gitee
mcp-gitee
master

搜索帮助