mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2025-08-23 22:33:05 +00:00
fix
This commit is contained in:
@@ -22,8 +22,10 @@ var (
|
|||||||
mcp.WithDescription("List repository commits"),
|
mcp.WithDescription("List repository commits"),
|
||||||
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")),
|
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")),
|
||||||
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")),
|
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")),
|
||||||
mcp.WithString("sha", mcp.Description("sha")),
|
mcp.WithString("sha", mcp.Description("SHA or branch to start listing commits from")),
|
||||||
mcp.WithString("path", mcp.Description("path")),
|
mcp.WithString("path", mcp.Description("path indicates that only commits that include the path's file/dir should be returned.")),
|
||||||
|
mcp.WithNumber("page", mcp.Required(), mcp.Description("page number"), mcp.DefaultNumber(1), mcp.Min(1)),
|
||||||
|
mcp.WithNumber("page_size", mcp.Required(), mcp.Description("page size"), mcp.DefaultNumber(50), mcp.Min(1)),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -37,12 +39,20 @@ func ListRepoCommitsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallT
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("repo is required")
|
return nil, fmt.Errorf("repo is required")
|
||||||
}
|
}
|
||||||
|
page, ok := req.Params.Arguments["page"].(float64)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("page is required")
|
||||||
|
}
|
||||||
|
pageSize, ok := req.Params.Arguments["page_size"].(float64)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("page_size is required")
|
||||||
|
}
|
||||||
sha, _ := req.Params.Arguments["sha"].(string)
|
sha, _ := req.Params.Arguments["sha"].(string)
|
||||||
path, _ := req.Params.Arguments["path"].(string)
|
path, _ := req.Params.Arguments["path"].(string)
|
||||||
opt := gitea_sdk.ListCommitOptions{
|
opt := gitea_sdk.ListCommitOptions{
|
||||||
ListOptions: gitea_sdk.ListOptions{
|
ListOptions: gitea_sdk.ListOptions{
|
||||||
Page: 1,
|
Page: int(page),
|
||||||
PageSize: 1000,
|
PageSize: int(pageSize),
|
||||||
},
|
},
|
||||||
SHA: sha,
|
SHA: sha,
|
||||||
Path: path,
|
Path: path,
|
||||||
|
@@ -2,6 +2,7 @@ package repo
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"gitea.com/gitea/gitea-mcp/pkg/gitea"
|
"gitea.com/gitea/gitea-mcp/pkg/gitea"
|
||||||
@@ -25,7 +26,7 @@ var (
|
|||||||
mcp.WithDescription("Get file"),
|
mcp.WithDescription("Get file"),
|
||||||
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")),
|
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")),
|
||||||
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")),
|
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")),
|
||||||
mcp.WithString("ref", mcp.Required(), mcp.Description("ref")),
|
mcp.WithString("ref", mcp.Required(), mcp.Description("ref can be branch/tag/commit")),
|
||||||
mcp.WithString("filePath", mcp.Required(), mcp.Description("file path")),
|
mcp.WithString("filePath", mcp.Required(), mcp.Description("file path")),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -47,7 +48,8 @@ var (
|
|||||||
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")),
|
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")),
|
||||||
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")),
|
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")),
|
||||||
mcp.WithString("filePath", mcp.Required(), mcp.Description("file path")),
|
mcp.WithString("filePath", mcp.Required(), mcp.Description("file path")),
|
||||||
mcp.WithString("content", mcp.Required(), mcp.Description("file content")),
|
mcp.WithString("sha", mcp.Required(), mcp.Description("sha is the SHA for the file that already exists")),
|
||||||
|
mcp.WithString("content", mcp.Required(), mcp.Description("raw file content")),
|
||||||
mcp.WithString("message", mcp.Required(), mcp.Description("commit message")),
|
mcp.WithString("message", mcp.Required(), mcp.Description("commit message")),
|
||||||
mcp.WithString("branch_name", mcp.Required(), mcp.Description("branch name")),
|
mcp.WithString("branch_name", mcp.Required(), mcp.Description("branch name")),
|
||||||
)
|
)
|
||||||
@@ -132,11 +134,17 @@ func UpdateFileFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRe
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("filePath is required")
|
return nil, fmt.Errorf("filePath is required")
|
||||||
}
|
}
|
||||||
|
sha, ok := req.Params.Arguments["sha"].(string)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("sha is required")
|
||||||
|
}
|
||||||
content, _ := req.Params.Arguments["content"].(string)
|
content, _ := req.Params.Arguments["content"].(string)
|
||||||
message, _ := req.Params.Arguments["message"].(string)
|
message, _ := req.Params.Arguments["message"].(string)
|
||||||
branchName, _ := req.Params.Arguments["branch_name"].(string)
|
branchName, _ := req.Params.Arguments["branch_name"].(string)
|
||||||
|
|
||||||
opt := gitea_sdk.UpdateFileOptions{
|
opt := gitea_sdk.UpdateFileOptions{
|
||||||
Content: content,
|
SHA: sha,
|
||||||
|
Content: base64.StdEncoding.EncodeToString([]byte(content)),
|
||||||
FileOptions: gitea_sdk.FileOptions{
|
FileOptions: gitea_sdk.FileOptions{
|
||||||
Message: message,
|
Message: message,
|
||||||
BranchName: branchName,
|
BranchName: branchName,
|
||||||
|
Reference in New Issue
Block a user