Adding more logs (#6)
Reviewed-on: #6 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: hiifong <i@hiif.ong> Co-committed-by: hiifong <i@hiif.ong>
This commit was merged in pull request #6.
This commit is contained in:
@@ -68,19 +68,19 @@ func GetIssueByIndexFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallT | ||||
log.Debugf("Called GetIssueByIndexFn") | ||||
owner, ok := req.Params.Arguments["owner"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("owner is required") | ||||
return to.ErrorResult(fmt.Errorf("owner is required")) | ||||
} | ||||
repo, ok := req.Params.Arguments["repo"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("repo is required") | ||||
return to.ErrorResult(fmt.Errorf("repo is required")) | ||||
} | ||||
index, ok := req.Params.Arguments["index"].(float64) | ||||
if !ok { | ||||
return nil, fmt.Errorf("index is required") | ||||
return to.ErrorResult(fmt.Errorf("index is required")) | ||||
} | ||||
issue, _, err := gitea.Client().GetIssue(owner, repo, int64(index)) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("get %v/%v/issue/%v err", owner, repo, int64(index)) | ||||
return to.ErrorResult(fmt.Errorf("get %v/%v/issue/%v err: %v", owner, repo, int64(index), err)) | ||||
} | ||||
| ||||
return to.TextResult(issue) | ||||
@@ -90,11 +90,11 @@ func ListRepoIssuesFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallTo | ||||
log.Debugf("Called ListIssuesFn") | ||||
owner, ok := req.Params.Arguments["owner"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("owner is required") | ||||
return to.ErrorResult(fmt.Errorf("owner is required")) | ||||
} | ||||
repo, ok := req.Params.Arguments["repo"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("repo is required") | ||||
return to.ErrorResult(fmt.Errorf("repo is required")) | ||||
} | ||||
state, ok := req.Params.Arguments["state"].(string) | ||||
if !ok { | ||||
@@ -117,7 +117,7 @@ func ListRepoIssuesFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallTo | ||||
} | ||||
issues, _, err := gitea.Client().ListRepoIssues(owner, repo, opt) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("get %v/%v/issues err", owner, repo) | ||||
return to.ErrorResult(fmt.Errorf("get %v/%v/issues err: %v", owner, repo, err)) | ||||
} | ||||
return to.TextResult(issues) | ||||
} | ||||
@@ -126,26 +126,26 @@ func CreateIssueFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolR | ||||
log.Debugf("Called CreateIssueFn") | ||||
owner, ok := req.Params.Arguments["owner"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("owner is required") | ||||
return to.ErrorResult(fmt.Errorf("owner is required")) | ||||
} | ||||
repo, ok := req.Params.Arguments["repo"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("repo is required") | ||||
return to.ErrorResult(fmt.Errorf("repo is required")) | ||||
} | ||||
title, ok := req.Params.Arguments["title"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("title is required") | ||||
return to.ErrorResult(fmt.Errorf("title is required")) | ||||
} | ||||
body, ok := req.Params.Arguments["body"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("body is required") | ||||
return to.ErrorResult(fmt.Errorf("body is required")) | ||||
} | ||||
issue, _, err := gitea.Client().CreateIssue(owner, repo, gitea_sdk.CreateIssueOption{ | ||||
Title: title, | ||||
Body: body, | ||||
}) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("create %v/%v/issue err", owner, repo) | ||||
return to.ErrorResult(fmt.Errorf("create %v/%v/issue err", owner, repo)) | ||||
} | ||||
| ||||
return to.TextResult(issue) | ||||
@@ -155,26 +155,26 @@ func CreateIssueCommentFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.Ca | ||||
log.Debugf("Called CreateIssueCommentFn") | ||||
owner, ok := req.Params.Arguments["owner"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("owner is required") | ||||
return to.ErrorResult(fmt.Errorf("owner is required")) | ||||
} | ||||
repo, ok := req.Params.Arguments["repo"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("repo is required") | ||||
return to.ErrorResult(fmt.Errorf("repo is required")) | ||||
} | ||||
index, ok := req.Params.Arguments["index"].(float64) | ||||
if !ok { | ||||
return nil, fmt.Errorf("index is required") | ||||
return to.ErrorResult(fmt.Errorf("index is required")) | ||||
} | ||||
body, ok := req.Params.Arguments["body"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("body is required") | ||||
return to.ErrorResult(fmt.Errorf("body is required")) | ||||
} | ||||
opt := gitea_sdk.CreateIssueCommentOption{ | ||||
Body: body, | ||||
} | ||||
issueComment, _, err := gitea.Client().CreateIssueComment(owner, repo, int64(index), opt) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("create %v/%v/issue/%v/comment err", owner, repo, int64(index)) | ||||
return to.ErrorResult(fmt.Errorf("create %v/%v/issue/%v/comment err", owner, repo, int64(index))) | ||||
} | ||||
| ||||
return to.TextResult(issueComment) | ||||
|
@@ -60,19 +60,19 @@ func GetPullRequestByIndexFn(ctx context.Context, req mcp.CallToolRequest) (*mcp | ||||
log.Debugf("Called GetPullRequestByIndexFn") | ||||
owner, ok := req.Params.Arguments["owner"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("owner is required") | ||||
return to.ErrorResult(fmt.Errorf("owner is required")) | ||||
} | ||||
repo, ok := req.Params.Arguments["repo"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("repo is required") | ||||
return to.ErrorResult(fmt.Errorf("repo is required")) | ||||
} | ||||
index, ok := req.Params.Arguments["index"].(float64) | ||||
if !ok { | ||||
return nil, fmt.Errorf("index is required") | ||||
return to.ErrorResult(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)) | ||||
return to.ErrorResult(fmt.Errorf("get %v/%v/pr/%v err: %v", owner, repo, int64(index), err)) | ||||
} | ||||
| ||||
return to.TextResult(pr) | ||||
@@ -82,11 +82,11 @@ func ListRepoPullRequestsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp. | ||||
log.Debugf("Called ListRepoPullRequests") | ||||
owner, ok := req.Params.Arguments["owner"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("owner is required") | ||||
return to.ErrorResult(fmt.Errorf("owner is required")) | ||||
} | ||||
repo, ok := req.Params.Arguments["repo"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("repo is required") | ||||
return to.ErrorResult(fmt.Errorf("repo is required")) | ||||
} | ||||
state, _ := req.Params.Arguments["state"].(string) | ||||
sort, _ := req.Params.Arguments["sort"].(string) | ||||
@@ -102,7 +102,7 @@ func ListRepoPullRequestsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp. | ||||
} | ||||
pullRequests, _, err := gitea.Client().ListRepoPullRequests("", "", opt) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("list %v/%v/pull_requests err", owner, repo) | ||||
return to.ErrorResult(fmt.Errorf("list %v/%v/pull_requests err: %v", owner, repo, err)) | ||||
} | ||||
| ||||
return to.TextResult(pullRequests) | ||||
@@ -112,27 +112,27 @@ func CreatePullRequestFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.Cal | ||||
log.Debugf("Called CreatePullRequestFn") | ||||
owner, ok := req.Params.Arguments["owner"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("owner is required") | ||||
return to.ErrorResult(fmt.Errorf("owner is required")) | ||||
} | ||||
repo, ok := req.Params.Arguments["repo"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("repo is required") | ||||
return to.ErrorResult(fmt.Errorf("repo is required")) | ||||
} | ||||
title, ok := req.Params.Arguments["title"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("title is required") | ||||
return to.ErrorResult(fmt.Errorf("title is required")) | ||||
} | ||||
body, ok := req.Params.Arguments["body"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("body is required") | ||||
return to.ErrorResult(fmt.Errorf("body is required")) | ||||
} | ||||
head, ok := req.Params.Arguments["head"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("head is required") | ||||
return to.ErrorResult(fmt.Errorf("head is required")) | ||||
} | ||||
base, ok := req.Params.Arguments["base"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("base is required") | ||||
return to.ErrorResult(fmt.Errorf("base is required")) | ||||
} | ||||
pr, _, err := gitea.Client().CreatePullRequest(owner, repo, gitea_sdk.CreatePullRequestOption{ | ||||
Title: title, | ||||
@@ -141,7 +141,7 @@ func CreatePullRequestFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.Cal | ||||
Base: base, | ||||
}) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("create %v/%v/pull_request err", owner, repo) | ||||
return to.ErrorResult(fmt.Errorf("create %v/%v/pull_request err: %v", owner, repo, err)) | ||||
} | ||||
| ||||
return to.TextResult(pr) | ||||
|
@@ -48,15 +48,15 @@ func CreateBranchFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallTool | ||||
log.Debugf("Called CreateBranchFn") | ||||
owner, ok := req.Params.Arguments["owner"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("owner is required") | ||||
return to.ErrorResult(fmt.Errorf("owner is required")) | ||||
} | ||||
repo, ok := req.Params.Arguments["repo"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("repo is required") | ||||
return to.ErrorResult(fmt.Errorf("repo is required")) | ||||
} | ||||
branch, ok := req.Params.Arguments["branch"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("branch is required") | ||||
return to.ErrorResult(fmt.Errorf("branch is required")) | ||||
} | ||||
oldBranch, _ := req.Params.Arguments["old_branch"].(string) | ||||
| ||||
@@ -65,7 +65,7 @@ func CreateBranchFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallTool | ||||
OldBranchName: oldBranch, | ||||
}) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("create branch error: %v", err) | ||||
return to.ErrorResult(fmt.Errorf("create branch error: %v", err)) | ||||
} | ||||
| ||||
return mcp.NewToolResultText("Branch Created"), nil | ||||
@@ -75,19 +75,19 @@ func DeleteBranchFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallTool | ||||
log.Debugf("Called DeleteBranchFn") | ||||
owner, ok := req.Params.Arguments["owner"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("owner is required") | ||||
return to.ErrorResult(fmt.Errorf("owner is required")) | ||||
} | ||||
repo, ok := req.Params.Arguments["repo"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("repo is required") | ||||
return to.ErrorResult(fmt.Errorf("repo is required")) | ||||
} | ||||
branch, ok := req.Params.Arguments["branch"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("branch is required") | ||||
return to.ErrorResult(fmt.Errorf("branch is required")) | ||||
} | ||||
_, _, err := gitea.Client().DeleteRepoBranch(owner, repo, branch) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("delete branch error: %v", err) | ||||
return to.ErrorResult(fmt.Errorf("delete branch error: %v", err)) | ||||
} | ||||
| ||||
return to.TextResult("Branch Deleted") | ||||
@@ -97,11 +97,11 @@ func ListBranchesFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallTool | ||||
log.Debugf("Called ListBranchesFn") | ||||
owner, ok := req.Params.Arguments["owner"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("owner is required") | ||||
return to.ErrorResult(fmt.Errorf("owner is required")) | ||||
} | ||||
repo, ok := req.Params.Arguments["repo"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("repo is required") | ||||
return to.ErrorResult(fmt.Errorf("repo is required")) | ||||
} | ||||
opt := gitea_sdk.ListRepoBranchesOptions{ | ||||
ListOptions: gitea_sdk.ListOptions{ | ||||
@@ -111,7 +111,7 @@ func ListBranchesFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallTool | ||||
} | ||||
branches, _, err := gitea.Client().ListRepoBranches(owner, repo, opt) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("list branches error: %v", err) | ||||
return to.ErrorResult(fmt.Errorf("list branches error: %v", err)) | ||||
} | ||||
| ||||
return to.TextResult(branches) | ||||
|
@@ -33,19 +33,19 @@ func ListRepoCommitsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallT | ||||
log.Debugf("Called ListRepoCommitsFn") | ||||
owner, ok := req.Params.Arguments["owner"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("owner is required") | ||||
return to.ErrorResult(fmt.Errorf("owner is required")) | ||||
} | ||||
repo, ok := req.Params.Arguments["repo"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("repo is required") | ||||
return to.ErrorResult(fmt.Errorf("repo is required")) | ||||
} | ||||
page, ok := req.Params.Arguments["page"].(float64) | ||||
if !ok { | ||||
return nil, fmt.Errorf("page is required") | ||||
return to.ErrorResult(fmt.Errorf("page is required")) | ||||
} | ||||
pageSize, ok := req.Params.Arguments["page_size"].(float64) | ||||
if !ok { | ||||
return nil, fmt.Errorf("page_size is required") | ||||
return to.ErrorResult(fmt.Errorf("page_size is required")) | ||||
} | ||||
sha, _ := req.Params.Arguments["sha"].(string) | ||||
path, _ := req.Params.Arguments["path"].(string) | ||||
@@ -59,7 +59,7 @@ func ListRepoCommitsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallT | ||||
} | ||||
commits, _, err := gitea.Client().ListRepoCommits(owner, repo, opt) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("list repo commits err: %v", err) | ||||
return to.ErrorResult(fmt.Errorf("list repo commits err: %v", err)) | ||||
} | ||||
return to.TextResult(commits) | ||||
} | ||||
|
@@ -69,20 +69,20 @@ func GetFileContentFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallTo | ||||
log.Debugf("Called GetFileFn") | ||||
owner, ok := req.Params.Arguments["owner"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("owner is required") | ||||
return to.ErrorResult(fmt.Errorf("owner is required")) | ||||
} | ||||
repo, ok := req.Params.Arguments["repo"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("repo is required") | ||||
return to.ErrorResult(fmt.Errorf("repo is required")) | ||||
} | ||||
ref, _ := req.Params.Arguments["ref"].(string) | ||||
filePath, ok := req.Params.Arguments["filePath"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("filePath is required") | ||||
return to.ErrorResult(fmt.Errorf("filePath is required")) | ||||
} | ||||
content, _, err := gitea.Client().GetContents(owner, repo, ref, filePath) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("get file err: %v", err) | ||||
return to.ErrorResult(fmt.Errorf("get file err: %v", err)) | ||||
} | ||||
return to.TextResult(content) | ||||
} | ||||
@@ -91,15 +91,15 @@ func CreateFileFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRe | ||||
log.Debugf("Called CreateFileFn") | ||||
owner, ok := req.Params.Arguments["owner"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("owner is required") | ||||
return to.ErrorResult(fmt.Errorf("owner is required")) | ||||
} | ||||
repo, ok := req.Params.Arguments["repo"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("repo is required") | ||||
return to.ErrorResult(fmt.Errorf("repo is required")) | ||||
} | ||||
filePath, ok := req.Params.Arguments["filePath"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("filePath is required") | ||||
return to.ErrorResult(fmt.Errorf("filePath is required")) | ||||
} | ||||
content, _ := req.Params.Arguments["content"].(string) | ||||
message, _ := req.Params.Arguments["message"].(string) | ||||
@@ -114,7 +114,7 @@ func CreateFileFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRe | ||||
| ||||
_, _, err := gitea.Client().CreateFile(owner, repo, filePath, opt) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("create file err: %v", err) | ||||
return to.ErrorResult(fmt.Errorf("create file err: %v", err)) | ||||
} | ||||
return to.TextResult("Create file success") | ||||
} | ||||
@@ -123,19 +123,19 @@ func UpdateFileFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRe | ||||
log.Debugf("Called UpdateFileFn") | ||||
owner, ok := req.Params.Arguments["owner"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("owner is required") | ||||
return to.ErrorResult(fmt.Errorf("owner is required")) | ||||
} | ||||
repo, ok := req.Params.Arguments["repo"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("repo is required") | ||||
return to.ErrorResult(fmt.Errorf("repo is required")) | ||||
} | ||||
filePath, ok := req.Params.Arguments["filePath"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("filePath is required") | ||||
return to.ErrorResult(fmt.Errorf("filePath is required")) | ||||
} | ||||
sha, ok := req.Params.Arguments["sha"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("sha is required") | ||||
return to.ErrorResult(fmt.Errorf("sha is required")) | ||||
} | ||||
content, _ := req.Params.Arguments["content"].(string) | ||||
message, _ := req.Params.Arguments["message"].(string) | ||||
@@ -151,7 +151,7 @@ func UpdateFileFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRe | ||||
} | ||||
_, _, err := gitea.Client().UpdateFile(owner, repo, filePath, opt) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("update file err: %v", err) | ||||
return to.ErrorResult(fmt.Errorf("update file err: %v", err)) | ||||
} | ||||
return to.TextResult("Update file success") | ||||
} | ||||
@@ -160,15 +160,15 @@ func DeleteFileFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRe | ||||
log.Debugf("Called DeleteFileFn") | ||||
owner, ok := req.Params.Arguments["owner"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("owner is required") | ||||
return to.ErrorResult(fmt.Errorf("owner is required")) | ||||
} | ||||
repo, ok := req.Params.Arguments["repo"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("repo is required") | ||||
return to.ErrorResult(fmt.Errorf("repo is required")) | ||||
} | ||||
filePath, ok := req.Params.Arguments["filePath"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("filePath is required") | ||||
return to.ErrorResult(fmt.Errorf("filePath is required")) | ||||
} | ||||
message, _ := req.Params.Arguments["message"].(string) | ||||
branchName, _ := req.Params.Arguments["branch_name"].(string) | ||||
@@ -180,7 +180,7 @@ func DeleteFileFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRe | ||||
} | ||||
_, err := gitea.Client().DeleteFile(owner, repo, filePath, opt) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("delete file err: %v", err) | ||||
return to.ErrorResult(fmt.Errorf("delete file err: %v", err)) | ||||
} | ||||
return to.TextResult("Delete file success") | ||||
} | ||||
|
@@ -78,7 +78,7 @@ func CreateRepoFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRe | ||||
log.Debugf("Called CreateRepoFn") | ||||
name, ok := req.Params.Arguments["name"].(string) | ||||
if !ok { | ||||
return nil, errors.New("repository name is required") | ||||
return to.ErrorResult(errors.New("repository name is required")) | ||||
} | ||||
description, _ := req.Params.Arguments["description"].(string) | ||||
private, _ := req.Params.Arguments["private"].(bool) | ||||
@@ -104,7 +104,7 @@ func CreateRepoFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRe | ||||
} | ||||
repo, _, err := gitea.Client().CreateRepo(opt) | ||||
if err != nil { | ||||
return nil, err | ||||
return to.ErrorResult(fmt.Errorf("create repo err: %v", err)) | ||||
} | ||||
return to.TextResult(repo) | ||||
} | ||||
@@ -113,11 +113,11 @@ func ForkRepoFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResu | ||||
log.Debugf("Called ForkRepoFn") | ||||
user, ok := req.Params.Arguments["user"].(string) | ||||
if !ok { | ||||
return nil, errors.New("user name is required") | ||||
return to.ErrorResult(errors.New("user name is required")) | ||||
} | ||||
repo, ok := req.Params.Arguments["repo"].(string) | ||||
if !ok { | ||||
return nil, errors.New("repository name is required") | ||||
return to.ErrorResult(errors.New("repository name is required")) | ||||
} | ||||
organization, _ := req.Params.Arguments["organization"].(string) | ||||
name, _ := req.Params.Arguments["name"].(string) | ||||
@@ -127,7 +127,7 @@ func ForkRepoFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResu | ||||
} | ||||
_, _, err := gitea.Client().CreateFork(user, repo, opt) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("fork repository error %v", err) | ||||
return to.ErrorResult(fmt.Errorf("fork repository error %v", err)) | ||||
} | ||||
return to.TextResult("Fork success") | ||||
} | ||||
@@ -136,21 +136,21 @@ func ListMyReposFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolR | ||||
log.Debugf("Called ListMyReposFn") | ||||
page, ok := req.Params.Arguments["page"].(float64) | ||||
if !ok { | ||||
return nil, errors.New("get page number error") | ||||
page = 1 | ||||
} | ||||
size, ok := req.Params.Arguments["pageSize"].(float64) | ||||
pageSize, ok := req.Params.Arguments["pageSize"].(float64) | ||||
if !ok { | ||||
return nil, errors.New("get page size number error") | ||||
pageSize = 100 | ||||
} | ||||
opt := gitea_sdk.ListReposOptions{ | ||||
ListOptions: gitea_sdk.ListOptions{ | ||||
Page: int(page), | ||||
PageSize: int(size), | ||||
PageSize: int(pageSize), | ||||
}, | ||||
} | ||||
repos, _, err := gitea.Client().ListMyRepos(opt) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("list my repositories error %v", err) | ||||
return to.ErrorResult(fmt.Errorf("list my repositories error: %v", err)) | ||||
} | ||||
| ||||
return to.TextResult(repos) | ||||
|
@@ -65,7 +65,7 @@ func SearchUsersFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolR | ||||
log.Debugf("Called SearchUsersFn") | ||||
keyword, ok := req.Params.Arguments["keyword"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("keyword is required") | ||||
return to.ErrorResult(fmt.Errorf("keyword is required")) | ||||
} | ||||
page, ok := req.Params.Arguments["page"].(float64) | ||||
if !ok { | ||||
@@ -84,7 +84,7 @@ func SearchUsersFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolR | ||||
} | ||||
users, _, err := gitea.Client().SearchUsers(opt) | ||||
if err != nil { | ||||
return nil, err | ||||
return to.ErrorResult(fmt.Errorf("search users err: %v", err)) | ||||
} | ||||
return to.TextResult(users) | ||||
} | ||||
@@ -93,11 +93,11 @@ func SearchOrgTeamsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallTo | ||||
log.Debugf("Called SearchOrgTeamsFn") | ||||
org, ok := req.Params.Arguments["org"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("organization is required") | ||||
return to.ErrorResult(fmt.Errorf("organization is required")) | ||||
} | ||||
query, ok := req.Params.Arguments["query"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("query is required") | ||||
return to.ErrorResult(fmt.Errorf("query is required")) | ||||
} | ||||
includeDescription, _ := req.Params.Arguments["includeDescription"].(bool) | ||||
page, ok := req.Params.Arguments["page"].(float64) | ||||
@@ -118,7 +118,7 @@ func SearchOrgTeamsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallTo | ||||
} | ||||
teams, _, err := gitea.Client().SearchOrgTeams(org, &opt) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("search organization teams error: %v", err) | ||||
return to.ErrorResult(fmt.Errorf("search organization teams error: %v", err)) | ||||
} | ||||
return to.TextResult(teams) | ||||
} | ||||
@@ -127,7 +127,7 @@ func SearchReposFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolR | ||||
log.Debugf("Called SearchReposFn") | ||||
keyword, ok := req.Params.Arguments["keyword"].(string) | ||||
if !ok { | ||||
return nil, fmt.Errorf("keyword is required") | ||||
return to.ErrorResult(fmt.Errorf("keyword is required")) | ||||
} | ||||
keywordIsTopic, _ := req.Params.Arguments["keywordIsTopic"].(bool) | ||||
keywordInDescription, _ := req.Params.Arguments["keywordInDescription"].(bool) | ||||
@@ -160,7 +160,7 @@ func SearchReposFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolR | ||||
} | ||||
repos, _, err := gitea.Client().SearchRepos(opt) | ||||
if err != nil { | ||||
return nil, fmt.Errorf("search repos error: %v", err) | ||||
return to.ErrorResult(fmt.Errorf("search repos error: %v", err)) | ||||
} | ||||
return to.TextResult(repos) | ||||
} | ||||
|
@@ -31,7 +31,7 @@ func GetUserInfoFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolR | ||||
log.Debugf("Called GetUserInfoFn") | ||||
user, _, err := gitea.Client().GetMyUserInfo() | ||||
if err != nil { | ||||
return nil, fmt.Errorf("get user info err: %v", err) | ||||
return to.ErrorResult(fmt.Errorf("get user info err: %v", err)) | ||||
} | ||||
| ||||
return to.TextResult(user) | ||||
|
Reference in New Issue
Block a user