mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2025-08-23 14:23:05 +00:00
refactor(args): request argument access and update dependencies (#42)
- Update dependencies to newer versions in go.mod - Refactor all request argument accesses to use req.GetArguments() instead of direct access to req.Params.Arguments - Change variable declaration for ListRepoCommitsTool from a grouped var block to a single var statement for consistency Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/42 Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com> Co-committed-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
@@ -99,15 +99,15 @@ func init() {
|
||||
|
||||
func GetIssueByIndexFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called GetIssueByIndexFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("owner is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("repo is required"))
|
||||
}
|
||||
index, ok := req.Params.Arguments["index"].(float64)
|
||||
index, ok := req.GetArguments()["index"].(float64)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("index is required"))
|
||||
}
|
||||
@@ -121,23 +121,23 @@ func GetIssueByIndexFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallT
|
||||
|
||||
func ListRepoIssuesFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called ListIssuesFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("owner is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("repo is required"))
|
||||
}
|
||||
state, ok := req.Params.Arguments["state"].(string)
|
||||
state, ok := req.GetArguments()["state"].(string)
|
||||
if !ok {
|
||||
state = "all"
|
||||
}
|
||||
page, ok := req.Params.Arguments["page"].(float64)
|
||||
page, ok := req.GetArguments()["page"].(float64)
|
||||
if !ok {
|
||||
page = 1
|
||||
}
|
||||
pageSize, ok := req.Params.Arguments["pageSize"].(float64)
|
||||
pageSize, ok := req.GetArguments()["pageSize"].(float64)
|
||||
if !ok {
|
||||
pageSize = 100
|
||||
}
|
||||
@@ -157,19 +157,19 @@ func ListRepoIssuesFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallTo
|
||||
|
||||
func CreateIssueFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called CreateIssueFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("owner is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("repo is required"))
|
||||
}
|
||||
title, ok := req.Params.Arguments["title"].(string)
|
||||
title, ok := req.GetArguments()["title"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("title is required"))
|
||||
}
|
||||
body, ok := req.Params.Arguments["body"].(string)
|
||||
body, ok := req.GetArguments()["body"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("body is required"))
|
||||
}
|
||||
@@ -186,19 +186,19 @@ func CreateIssueFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolR
|
||||
|
||||
func CreateIssueCommentFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called CreateIssueCommentFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("owner is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("repo is required"))
|
||||
}
|
||||
index, ok := req.Params.Arguments["index"].(float64)
|
||||
index, ok := req.GetArguments()["index"].(float64)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("index is required"))
|
||||
}
|
||||
body, ok := req.Params.Arguments["body"].(string)
|
||||
body, ok := req.GetArguments()["body"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("body is required"))
|
||||
}
|
||||
@@ -215,38 +215,38 @@ func CreateIssueCommentFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.Ca
|
||||
|
||||
func EditIssueFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called EditIssueFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("owner is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("repo is required"))
|
||||
}
|
||||
index, ok := req.Params.Arguments["index"].(float64)
|
||||
index, ok := req.GetArguments()["index"].(float64)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("index is required"))
|
||||
}
|
||||
|
||||
opt := gitea_sdk.EditIssueOption{}
|
||||
|
||||
title, ok := req.Params.Arguments["title"].(string)
|
||||
title, ok := req.GetArguments()["title"].(string)
|
||||
if ok {
|
||||
opt.Title = title
|
||||
}
|
||||
body, ok := req.Params.Arguments["body"].(string)
|
||||
body, ok := req.GetArguments()["body"].(string)
|
||||
if ok {
|
||||
opt.Body = ptr.To(body)
|
||||
}
|
||||
assignees, ok := req.Params.Arguments["assignees"].([]string)
|
||||
assignees, ok := req.GetArguments()["assignees"].([]string)
|
||||
if ok {
|
||||
opt.Assignees = assignees
|
||||
}
|
||||
milestone, ok := req.Params.Arguments["milestone"].(float64)
|
||||
milestone, ok := req.GetArguments()["milestone"].(float64)
|
||||
if ok {
|
||||
opt.Milestone = ptr.To(int64(milestone))
|
||||
}
|
||||
state, ok := req.Params.Arguments["state"].(string)
|
||||
state, ok := req.GetArguments()["state"].(string)
|
||||
if ok {
|
||||
opt.State = ptr.To(gitea_sdk.StateType(state))
|
||||
}
|
||||
|
@@ -72,15 +72,15 @@ func init() {
|
||||
|
||||
func GetPullRequestByIndexFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called GetPullRequestByIndexFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("owner is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("repo is required"))
|
||||
}
|
||||
index, ok := req.Params.Arguments["index"].(float64)
|
||||
index, ok := req.GetArguments()["index"].(float64)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("index is required"))
|
||||
}
|
||||
@@ -94,25 +94,25 @@ 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, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("owner is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("repo is required"))
|
||||
}
|
||||
state, _ := req.Params.Arguments["state"].(string)
|
||||
sort, ok := req.Params.Arguments["sort"].(string)
|
||||
state, _ := req.GetArguments()["state"].(string)
|
||||
sort, ok := req.GetArguments()["sort"].(string)
|
||||
if !ok {
|
||||
sort = "recentupdate"
|
||||
}
|
||||
milestone, _ := req.Params.Arguments["milestone"].(float64)
|
||||
page, ok := req.Params.Arguments["page"].(float64)
|
||||
milestone, _ := req.GetArguments()["milestone"].(float64)
|
||||
page, ok := req.GetArguments()["page"].(float64)
|
||||
if !ok {
|
||||
page = 1
|
||||
}
|
||||
pageSize, ok := req.Params.Arguments["pageSize"].(float64)
|
||||
pageSize, ok := req.GetArguments()["pageSize"].(float64)
|
||||
if !ok {
|
||||
pageSize = 100
|
||||
}
|
||||
@@ -135,27 +135,27 @@ 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, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("owner is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("repo is required"))
|
||||
}
|
||||
title, ok := req.Params.Arguments["title"].(string)
|
||||
title, ok := req.GetArguments()["title"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("title is required"))
|
||||
}
|
||||
body, ok := req.Params.Arguments["body"].(string)
|
||||
body, ok := req.GetArguments()["body"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("body is required"))
|
||||
}
|
||||
head, ok := req.Params.Arguments["head"].(string)
|
||||
head, ok := req.GetArguments()["head"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("head is required"))
|
||||
}
|
||||
base, ok := req.Params.Arguments["base"].(string)
|
||||
base, ok := req.GetArguments()["base"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("base is required"))
|
||||
}
|
||||
|
@@ -62,19 +62,19 @@ func init() {
|
||||
|
||||
func CreateBranchFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called CreateBranchFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("owner is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("repo is required"))
|
||||
}
|
||||
branch, ok := req.Params.Arguments["branch"].(string)
|
||||
branch, ok := req.GetArguments()["branch"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("branch is required"))
|
||||
}
|
||||
oldBranch, _ := req.Params.Arguments["old_branch"].(string)
|
||||
oldBranch, _ := req.GetArguments()["old_branch"].(string)
|
||||
|
||||
_, _, err := gitea.Client().CreateBranch(owner, repo, gitea_sdk.CreateBranchOption{
|
||||
BranchName: branch,
|
||||
@@ -89,15 +89,15 @@ func CreateBranchFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallTool
|
||||
|
||||
func DeleteBranchFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called DeleteBranchFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("owner is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("repo is required"))
|
||||
}
|
||||
branch, ok := req.Params.Arguments["branch"].(string)
|
||||
branch, ok := req.GetArguments()["branch"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("branch is required"))
|
||||
}
|
||||
@@ -111,11 +111,11 @@ func DeleteBranchFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallTool
|
||||
|
||||
func ListBranchesFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called ListBranchesFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("owner is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("repo is required"))
|
||||
}
|
||||
|
@@ -17,17 +17,15 @@ const (
|
||||
ListRepoCommitsToolName = "list_repo_commits"
|
||||
)
|
||||
|
||||
var (
|
||||
ListRepoCommitsTool = mcp.NewTool(
|
||||
ListRepoCommitsToolName,
|
||||
mcp.WithDescription("List repository commits"),
|
||||
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")),
|
||||
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")),
|
||||
mcp.WithString("sha", mcp.Description("SHA or branch to start listing commits from")),
|
||||
mcp.WithString("path", mcp.Description("path indicates that only commits that include the path's file/dir should be returned.")),
|
||||
mcp.WithNumber("page", mcp.Required(), mcp.Description("page number"), mcp.DefaultNumber(1), mcp.Min(1)),
|
||||
mcp.WithNumber("page_size", mcp.Required(), mcp.Description("page size"), mcp.DefaultNumber(50), mcp.Min(1)),
|
||||
)
|
||||
var ListRepoCommitsTool = mcp.NewTool(
|
||||
ListRepoCommitsToolName,
|
||||
mcp.WithDescription("List repository commits"),
|
||||
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")),
|
||||
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")),
|
||||
mcp.WithString("sha", mcp.Description("SHA or branch to start listing commits from")),
|
||||
mcp.WithString("path", mcp.Description("path indicates that only commits that include the path's file/dir should be returned.")),
|
||||
mcp.WithNumber("page", mcp.Required(), mcp.Description("page number"), mcp.DefaultNumber(1), mcp.Min(1)),
|
||||
mcp.WithNumber("page_size", mcp.Required(), mcp.Description("page size"), mcp.DefaultNumber(50), mcp.Min(1)),
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -39,24 +37,24 @@ func init() {
|
||||
|
||||
func ListRepoCommitsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called ListRepoCommitsFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("owner is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("repo is required"))
|
||||
}
|
||||
page, ok := req.Params.Arguments["page"].(float64)
|
||||
page, ok := req.GetArguments()["page"].(float64)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("page is required"))
|
||||
}
|
||||
pageSize, ok := req.Params.Arguments["page_size"].(float64)
|
||||
pageSize, ok := req.GetArguments()["page_size"].(float64)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("page_size is required"))
|
||||
}
|
||||
sha, _ := req.Params.Arguments["sha"].(string)
|
||||
path, _ := req.Params.Arguments["path"].(string)
|
||||
sha, _ := req.GetArguments()["sha"].(string)
|
||||
path, _ := req.GetArguments()["path"].(string)
|
||||
opt := gitea_sdk.ListCommitOptions{
|
||||
ListOptions: gitea_sdk.ListOptions{
|
||||
Page: int(page),
|
||||
|
@@ -88,16 +88,16 @@ func init() {
|
||||
|
||||
func GetFileContentFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called GetFileFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("owner is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("repo is required"))
|
||||
}
|
||||
ref, _ := req.Params.Arguments["ref"].(string)
|
||||
filePath, ok := req.Params.Arguments["filePath"].(string)
|
||||
ref, _ := req.GetArguments()["ref"].(string)
|
||||
filePath, ok := req.GetArguments()["filePath"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("filePath is required"))
|
||||
}
|
||||
@@ -110,21 +110,21 @@ func GetFileContentFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallTo
|
||||
|
||||
func CreateFileFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called CreateFileFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("owner is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("repo is required"))
|
||||
}
|
||||
filePath, ok := req.Params.Arguments["filePath"].(string)
|
||||
filePath, ok := req.GetArguments()["filePath"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("filePath is required"))
|
||||
}
|
||||
content, _ := req.Params.Arguments["content"].(string)
|
||||
message, _ := req.Params.Arguments["message"].(string)
|
||||
branchName, _ := req.Params.Arguments["branch_name"].(string)
|
||||
content, _ := req.GetArguments()["content"].(string)
|
||||
message, _ := req.GetArguments()["message"].(string)
|
||||
branchName, _ := req.GetArguments()["branch_name"].(string)
|
||||
opt := gitea_sdk.CreateFileOptions{
|
||||
Content: base64.StdEncoding.EncodeToString([]byte(content)),
|
||||
FileOptions: gitea_sdk.FileOptions{
|
||||
@@ -142,25 +142,25 @@ func CreateFileFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRe
|
||||
|
||||
func UpdateFileFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called UpdateFileFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("owner is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("repo is required"))
|
||||
}
|
||||
filePath, ok := req.Params.Arguments["filePath"].(string)
|
||||
filePath, ok := req.GetArguments()["filePath"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("filePath is required"))
|
||||
}
|
||||
sha, ok := req.Params.Arguments["sha"].(string)
|
||||
sha, ok := req.GetArguments()["sha"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("sha is required"))
|
||||
}
|
||||
content, _ := req.Params.Arguments["content"].(string)
|
||||
message, _ := req.Params.Arguments["message"].(string)
|
||||
branchName, _ := req.Params.Arguments["branch_name"].(string)
|
||||
content, _ := req.GetArguments()["content"].(string)
|
||||
message, _ := req.GetArguments()["message"].(string)
|
||||
branchName, _ := req.GetArguments()["branch_name"].(string)
|
||||
|
||||
opt := gitea_sdk.UpdateFileOptions{
|
||||
SHA: sha,
|
||||
@@ -179,21 +179,21 @@ func UpdateFileFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRe
|
||||
|
||||
func DeleteFileFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called DeleteFileFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("owner is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("repo is required"))
|
||||
}
|
||||
filePath, ok := req.Params.Arguments["filePath"].(string)
|
||||
filePath, ok := req.GetArguments()["filePath"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("filePath is required"))
|
||||
}
|
||||
message, _ := req.Params.Arguments["message"].(string)
|
||||
branchName, _ := req.Params.Arguments["branch_name"].(string)
|
||||
sha, ok := req.Params.Arguments["sha"].(string)
|
||||
message, _ := req.GetArguments()["message"].(string)
|
||||
branchName, _ := req.GetArguments()["branch_name"].(string)
|
||||
sha, ok := req.GetArguments()["sha"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("sha is required"))
|
||||
}
|
||||
|
@@ -109,28 +109,28 @@ type ListReleaseResult struct {
|
||||
|
||||
func CreateReleaseFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called CreateReleasesFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("owner is required")
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("repo is required")
|
||||
}
|
||||
tagName, ok := req.Params.Arguments["tag_name"].(string)
|
||||
tagName, ok := req.GetArguments()["tag_name"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("tag_name is required")
|
||||
}
|
||||
target, ok := req.Params.Arguments["target"].(string)
|
||||
target, ok := req.GetArguments()["target"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("target is required")
|
||||
}
|
||||
title, ok := req.Params.Arguments["title"].(string)
|
||||
title, ok := req.GetArguments()["title"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("title is required")
|
||||
}
|
||||
isDraft, _ := req.Params.Arguments["is_draft"].(bool)
|
||||
isPreRelease, _ := req.Params.Arguments["is_pre_release"].(bool)
|
||||
isDraft, _ := req.GetArguments()["is_draft"].(bool)
|
||||
isPreRelease, _ := req.GetArguments()["is_pre_release"].(bool)
|
||||
|
||||
_, _, err := gitea.Client().CreateRelease(owner, repo, gitea_sdk.CreateReleaseOption{
|
||||
TagName: tagName,
|
||||
@@ -148,15 +148,15 @@ func CreateReleaseFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToo
|
||||
|
||||
func DeleteReleaseFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called DeleteReleaseFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("owner is required")
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("repo is required")
|
||||
}
|
||||
id, ok := req.Params.Arguments["id"].(float64)
|
||||
id, ok := req.GetArguments()["id"].(float64)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("id is required")
|
||||
}
|
||||
@@ -171,15 +171,15 @@ func DeleteReleaseFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToo
|
||||
|
||||
func GetReleaseFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called GetReleaseFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("owner is required")
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("repo is required")
|
||||
}
|
||||
id, ok := req.Params.Arguments["id"].(float64)
|
||||
id, ok := req.GetArguments()["id"].(float64)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("id is required")
|
||||
}
|
||||
@@ -194,11 +194,11 @@ func GetReleaseFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRe
|
||||
|
||||
func GetLatestReleaseFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called GetLatestReleaseFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("owner is required")
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("repo is required")
|
||||
}
|
||||
@@ -213,18 +213,18 @@ func GetLatestReleaseFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.Call
|
||||
|
||||
func ListReleasesFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called ListReleasesFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("owner is required")
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("repo is required")
|
||||
}
|
||||
isDraft, _ := req.Params.Arguments["is_draft"].(bool)
|
||||
isPreRelease, _ := req.Params.Arguments["is_pre_release"].(bool)
|
||||
page, _ := req.Params.Arguments["page"].(float64)
|
||||
pageSize, _ := req.Params.Arguments["pageSize"].(float64)
|
||||
isDraft, _ := req.GetArguments()["is_draft"].(bool)
|
||||
isPreRelease, _ := req.GetArguments()["is_pre_release"].(bool)
|
||||
page, _ := req.GetArguments()["page"].(float64)
|
||||
pageSize, _ := req.GetArguments()["pageSize"].(float64)
|
||||
|
||||
releases, _, err := gitea.Client().ListReleases(owner, repo, gitea_sdk.ListReleasesOptions{
|
||||
ListOptions: gitea_sdk.ListOptions{
|
||||
|
@@ -107,19 +107,19 @@ func RegisterTool(s *server.MCPServer) {
|
||||
|
||||
func CreateRepoFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called CreateRepoFn")
|
||||
name, ok := req.Params.Arguments["name"].(string)
|
||||
name, ok := req.GetArguments()["name"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(errors.New("repository name is required"))
|
||||
}
|
||||
description, _ := req.Params.Arguments["description"].(string)
|
||||
private, _ := req.Params.Arguments["private"].(bool)
|
||||
issueLabels, _ := req.Params.Arguments["issue_labels"].(string)
|
||||
autoInit, _ := req.Params.Arguments["auto_init"].(bool)
|
||||
template, _ := req.Params.Arguments["template"].(bool)
|
||||
gitignores, _ := req.Params.Arguments["gitignores"].(string)
|
||||
license, _ := req.Params.Arguments["license"].(string)
|
||||
readme, _ := req.Params.Arguments["readme"].(string)
|
||||
defaultBranch, _ := req.Params.Arguments["default_branch"].(string)
|
||||
description, _ := req.GetArguments()["description"].(string)
|
||||
private, _ := req.GetArguments()["private"].(bool)
|
||||
issueLabels, _ := req.GetArguments()["issue_labels"].(string)
|
||||
autoInit, _ := req.GetArguments()["auto_init"].(bool)
|
||||
template, _ := req.GetArguments()["template"].(bool)
|
||||
gitignores, _ := req.GetArguments()["gitignores"].(string)
|
||||
license, _ := req.GetArguments()["license"].(string)
|
||||
readme, _ := req.GetArguments()["readme"].(string)
|
||||
defaultBranch, _ := req.GetArguments()["default_branch"].(string)
|
||||
|
||||
opt := gitea_sdk.CreateRepoOption{
|
||||
Name: name,
|
||||
@@ -142,20 +142,20 @@ func CreateRepoFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRe
|
||||
|
||||
func ForkRepoFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called ForkRepoFn")
|
||||
user, ok := req.Params.Arguments["user"].(string)
|
||||
user, ok := req.GetArguments()["user"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(errors.New("user name is required"))
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(errors.New("repository name is required"))
|
||||
}
|
||||
organization, ok := req.Params.Arguments["organization"].(string)
|
||||
organization, ok := req.GetArguments()["organization"].(string)
|
||||
organizationPtr := ptr.To(organization)
|
||||
if !ok || organization == "" {
|
||||
organizationPtr = nil
|
||||
}
|
||||
name, ok := req.Params.Arguments["name"].(string)
|
||||
name, ok := req.GetArguments()["name"].(string)
|
||||
namePtr := ptr.To(name)
|
||||
if !ok || name == "" {
|
||||
namePtr = nil
|
||||
@@ -173,11 +173,11 @@ func ForkRepoFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResu
|
||||
|
||||
func ListMyReposFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called ListMyReposFn")
|
||||
page, ok := req.Params.Arguments["page"].(float64)
|
||||
page, ok := req.GetArguments()["page"].(float64)
|
||||
if !ok {
|
||||
page = 1
|
||||
}
|
||||
pageSize, ok := req.Params.Arguments["pageSize"].(float64)
|
||||
pageSize, ok := req.GetArguments()["pageSize"].(float64)
|
||||
if !ok {
|
||||
pageSize = 100
|
||||
}
|
||||
|
@@ -87,20 +87,20 @@ type ListTagResult struct {
|
||||
|
||||
func CreateTagFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called CreateTagFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("owner is required")
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("repo is required")
|
||||
}
|
||||
tagName, ok := req.Params.Arguments["tag_name"].(string)
|
||||
tagName, ok := req.GetArguments()["tag_name"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("tag_name is required")
|
||||
}
|
||||
target, _ := req.Params.Arguments["target"].(string)
|
||||
message, _ := req.Params.Arguments["message"].(string)
|
||||
target, _ := req.GetArguments()["target"].(string)
|
||||
message, _ := req.GetArguments()["message"].(string)
|
||||
|
||||
_, _, err := gitea.Client().CreateTag(owner, repo, gitea_sdk.CreateTagOption{
|
||||
TagName: tagName,
|
||||
@@ -116,15 +116,15 @@ func CreateTagFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRes
|
||||
|
||||
func DeleteTagFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called DeleteTagFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("owner is required")
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("repo is required")
|
||||
}
|
||||
tagName, ok := req.Params.Arguments["tag_name"].(string)
|
||||
tagName, ok := req.GetArguments()["tag_name"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("tag_name is required")
|
||||
}
|
||||
@@ -139,15 +139,15 @@ func DeleteTagFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRes
|
||||
|
||||
func GetTagFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called GetTagFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("owner is required")
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("repo is required")
|
||||
}
|
||||
tagName, ok := req.Params.Arguments["tag_name"].(string)
|
||||
tagName, ok := req.GetArguments()["tag_name"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("tag_name is required")
|
||||
}
|
||||
@@ -162,16 +162,16 @@ func GetTagFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult
|
||||
|
||||
func ListTagsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called ListTagsFn")
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
owner, ok := req.GetArguments()["owner"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("owner is required")
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
repo, ok := req.GetArguments()["repo"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("repo is required")
|
||||
}
|
||||
page, _ := req.Params.Arguments["page"].(float64)
|
||||
pageSize, _ := req.Params.Arguments["pageSize"].(float64)
|
||||
page, _ := req.GetArguments()["page"].(float64)
|
||||
pageSize, _ := req.GetArguments()["pageSize"].(float64)
|
||||
|
||||
tags, _, err := gitea.Client().ListRepoTags(owner, repo, gitea_sdk.ListRepoTagsOptions{
|
||||
ListOptions: gitea_sdk.ListOptions{
|
||||
|
@@ -75,15 +75,15 @@ func init() {
|
||||
|
||||
func SearchUsersFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called SearchUsersFn")
|
||||
keyword, ok := req.Params.Arguments["keyword"].(string)
|
||||
keyword, ok := req.GetArguments()["keyword"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("keyword is required"))
|
||||
}
|
||||
page, ok := req.Params.Arguments["page"].(float64)
|
||||
page, ok := req.GetArguments()["page"].(float64)
|
||||
if !ok {
|
||||
page = 1
|
||||
}
|
||||
pageSize, ok := req.Params.Arguments["pageSize"].(float64)
|
||||
pageSize, ok := req.GetArguments()["pageSize"].(float64)
|
||||
if !ok {
|
||||
pageSize = 100
|
||||
}
|
||||
@@ -103,20 +103,20 @@ func SearchUsersFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolR
|
||||
|
||||
func SearchOrgTeamsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called SearchOrgTeamsFn")
|
||||
org, ok := req.Params.Arguments["org"].(string)
|
||||
org, ok := req.GetArguments()["org"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("organization is required"))
|
||||
}
|
||||
query, ok := req.Params.Arguments["query"].(string)
|
||||
query, ok := req.GetArguments()["query"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("query is required"))
|
||||
}
|
||||
includeDescription, _ := req.Params.Arguments["includeDescription"].(bool)
|
||||
page, ok := req.Params.Arguments["page"].(float64)
|
||||
includeDescription, _ := req.GetArguments()["includeDescription"].(bool)
|
||||
page, ok := req.GetArguments()["page"].(float64)
|
||||
if !ok {
|
||||
page = 1
|
||||
}
|
||||
pageSize, ok := req.Params.Arguments["pageSize"].(float64)
|
||||
pageSize, ok := req.GetArguments()["pageSize"].(float64)
|
||||
if !ok {
|
||||
pageSize = 100
|
||||
}
|
||||
@@ -137,22 +137,22 @@ func SearchOrgTeamsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallTo
|
||||
|
||||
func SearchReposFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called SearchReposFn")
|
||||
keyword, ok := req.Params.Arguments["keyword"].(string)
|
||||
keyword, ok := req.GetArguments()["keyword"].(string)
|
||||
if !ok {
|
||||
return to.ErrorResult(fmt.Errorf("keyword is required"))
|
||||
}
|
||||
keywordIsTopic, _ := req.Params.Arguments["keywordIsTopic"].(bool)
|
||||
keywordInDescription, _ := req.Params.Arguments["keywordInDescription"].(bool)
|
||||
ownerID, _ := req.Params.Arguments["ownerID"].(float64)
|
||||
isPrivate, _ := req.Params.Arguments["isPrivate"].(bool)
|
||||
isArchived, _ := req.Params.Arguments["isArchived"].(bool)
|
||||
sort, _ := req.Params.Arguments["sort"].(string)
|
||||
order, _ := req.Params.Arguments["order"].(string)
|
||||
page, ok := req.Params.Arguments["page"].(float64)
|
||||
keywordIsTopic, _ := req.GetArguments()["keywordIsTopic"].(bool)
|
||||
keywordInDescription, _ := req.GetArguments()["keywordInDescription"].(bool)
|
||||
ownerID, _ := req.GetArguments()["ownerID"].(float64)
|
||||
isPrivate, _ := req.GetArguments()["isPrivate"].(bool)
|
||||
isArchived, _ := req.GetArguments()["isArchived"].(bool)
|
||||
sort, _ := req.GetArguments()["sort"].(string)
|
||||
order, _ := req.GetArguments()["order"].(string)
|
||||
page, ok := req.GetArguments()["page"].(float64)
|
||||
if !ok {
|
||||
page = 1
|
||||
}
|
||||
pageSize, ok := req.Params.Arguments["pageSize"].(float64)
|
||||
pageSize, ok := req.GetArguments()["pageSize"].(float64)
|
||||
if !ok {
|
||||
pageSize = 100
|
||||
}
|
||||
|
@@ -59,11 +59,11 @@ func GetUserInfoFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolR
|
||||
|
||||
func GetUserOrgsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called GetUserOrgsFn")
|
||||
page, ok := req.Params.Arguments["page"].(float64)
|
||||
page, ok := req.GetArguments()["page"].(float64)
|
||||
if !ok || page < 1 {
|
||||
page = 1
|
||||
}
|
||||
pageSize, ok := req.Params.Arguments["pageSize"].(float64)
|
||||
pageSize, ok := req.GetArguments()["pageSize"].(float64)
|
||||
if !ok || pageSize < 1 {
|
||||
pageSize = 100
|
||||
}
|
||||
|
Reference in New Issue
Block a user