mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2025-08-23 22:33:05 +00:00
Update
This commit is contained in:
@@ -23,30 +23,30 @@ var (
|
||||
GetPullRequestByIndexTool = mcp.NewTool(
|
||||
GetPullRequestByIndexToolName,
|
||||
mcp.WithDescription("get pull request by index"),
|
||||
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner"), mcp.DefaultString("")),
|
||||
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name"), mcp.DefaultString("")),
|
||||
mcp.WithNumber("index", mcp.Required(), mcp.Description("repository pull request index"), mcp.DefaultNumber(0)),
|
||||
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")),
|
||||
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")),
|
||||
mcp.WithNumber("index", mcp.Required(), mcp.Description("repository pull request index")),
|
||||
)
|
||||
|
||||
ListRepoPullRequestsTool = mcp.NewTool(
|
||||
ListRepoPullRequestsToolName,
|
||||
mcp.WithDescription("List repository pull requests"),
|
||||
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner"), mcp.DefaultString("")),
|
||||
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name"), mcp.DefaultString("")),
|
||||
mcp.WithString("state", mcp.Description("state"), mcp.DefaultString("")),
|
||||
mcp.WithString("sort", mcp.Description("sort"), mcp.DefaultString("")),
|
||||
mcp.WithNumber("milestone", mcp.Description("milestone"), mcp.DefaultNumber(0)),
|
||||
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")),
|
||||
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")),
|
||||
mcp.WithString("state", mcp.Description("state")),
|
||||
mcp.WithString("sort", mcp.Description("sort")),
|
||||
mcp.WithNumber("milestone", mcp.Description("milestone")),
|
||||
)
|
||||
|
||||
CreatePullRequestTool = mcp.NewTool(
|
||||
CreatePullRequestToolName,
|
||||
mcp.WithDescription("create pull request"),
|
||||
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner"), mcp.DefaultString("")),
|
||||
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name"), mcp.DefaultString("")),
|
||||
mcp.WithString("title", mcp.Required(), mcp.Description("pull request title"), mcp.DefaultString("")),
|
||||
mcp.WithString("body", mcp.Required(), mcp.Description("pull request body"), mcp.DefaultString("")),
|
||||
mcp.WithString("head", mcp.Required(), mcp.Description("pull request head"), mcp.DefaultString("")),
|
||||
mcp.WithString("base", mcp.Required(), mcp.Description("pull request base"), mcp.DefaultString("")),
|
||||
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")),
|
||||
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")),
|
||||
mcp.WithString("title", mcp.Required(), mcp.Description("pull request title")),
|
||||
mcp.WithString("body", mcp.Required(), mcp.Description("pull request body")),
|
||||
mcp.WithString("head", mcp.Required(), mcp.Description("pull request head")),
|
||||
mcp.WithString("base", mcp.Required(), mcp.Description("pull request base")),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -58,9 +58,18 @@ func RegisterTool(s *server.MCPServer) {
|
||||
|
||||
func GetPullRequestByIndexFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called GetPullRequestByIndexFn")
|
||||
owner := req.Params.Arguments["owner"].(string)
|
||||
repo := req.Params.Arguments["repo"].(string)
|
||||
index := req.Params.Arguments["index"].(float64)
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("owner is required")
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("repo is required")
|
||||
}
|
||||
index, ok := req.Params.Arguments["index"].(float64)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("index is required")
|
||||
}
|
||||
pr, _, err := gitea.Client().GetPullRequest(owner, repo, int64(index))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get %v/%v/pr/%v err", owner, repo, int64(index))
|
||||
@@ -71,12 +80,21 @@ func GetPullRequestByIndexFn(ctx context.Context, req mcp.CallToolRequest) (*mcp
|
||||
|
||||
func ListRepoPullRequestsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called ListRepoPullRequests")
|
||||
owner := req.Params.Arguments["owner"].(string)
|
||||
repo := req.Params.Arguments["repo"].(string)
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("owner is required")
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("repo is required")
|
||||
}
|
||||
state, _ := req.Params.Arguments["state"].(string)
|
||||
sort, _ := req.Params.Arguments["sort"].(string)
|
||||
milestone, _ := req.Params.Arguments["milestone"].(float64)
|
||||
opt := gitea_sdk.ListPullRequestsOptions{
|
||||
State: gitea_sdk.StateType(req.Params.Arguments["state"].(string)),
|
||||
Sort: req.Params.Arguments["sort"].(string),
|
||||
Milestone: req.Params.Arguments["milestone"].(int64),
|
||||
State: gitea_sdk.StateType(state),
|
||||
Sort: sort,
|
||||
Milestone: int64(milestone),
|
||||
ListOptions: gitea_sdk.ListOptions{
|
||||
Page: 1,
|
||||
PageSize: 1000,
|
||||
@@ -92,12 +110,30 @@ func ListRepoPullRequestsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.
|
||||
|
||||
func CreatePullRequestFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called CreatePullRequestFn")
|
||||
owner := req.Params.Arguments["owner"].(string)
|
||||
repo := req.Params.Arguments["repo"].(string)
|
||||
title := req.Params.Arguments["title"].(string)
|
||||
body := req.Params.Arguments["body"].(string)
|
||||
head := req.Params.Arguments["head"].(string)
|
||||
base := req.Params.Arguments["base"].(string)
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("owner is required")
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("repo is required")
|
||||
}
|
||||
title, ok := req.Params.Arguments["title"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("title is required")
|
||||
}
|
||||
body, ok := req.Params.Arguments["body"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("body is required")
|
||||
}
|
||||
head, ok := req.Params.Arguments["head"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("head is required")
|
||||
}
|
||||
base, ok := req.Params.Arguments["base"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("base is required")
|
||||
}
|
||||
pr, _, err := gitea.Client().CreatePullRequest(owner, repo, gitea_sdk.CreatePullRequestOption{
|
||||
Title: title,
|
||||
Body: body,
|
||||
|
Reference in New Issue
Block a user