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:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user