mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2025-08-23 22:33: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:
@@ -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"))
|
||||
}
|
||||
|
Reference in New Issue
Block a user