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:
Bo-Yi Wu
2025-05-26 06:10:10 +00:00
committed by Bo-Yi Wu (吳柏毅)
parent 796fd4682d
commit 34ca5d45db
12 changed files with 176 additions and 178 deletions

View File

@@ -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{