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