mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2025-08-23 22:33:05 +00:00
Update
This commit is contained in:
@@ -4,10 +4,11 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
gitea_sdk "code.gitea.io/sdk/gitea"
|
||||
"gitea.com/gitea/gitea-mcp/pkg/gitea"
|
||||
"gitea.com/gitea/gitea-mcp/pkg/log"
|
||||
"gitea.com/gitea/gitea-mcp/pkg/to"
|
||||
|
||||
gitea_sdk "code.gitea.io/sdk/gitea"
|
||||
"github.com/mark3labs/mcp-go/mcp"
|
||||
)
|
||||
|
||||
@@ -19,24 +20,32 @@ var (
|
||||
ListRepoCommitsTool = mcp.NewTool(
|
||||
ListRepoCommitsToolName,
|
||||
mcp.WithDescription("List repository commits"),
|
||||
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner"), mcp.DefaultString("")),
|
||||
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name"), mcp.DefaultString("")),
|
||||
mcp.WithString("sha", mcp.Description("sha"), mcp.DefaultString("")),
|
||||
mcp.WithString("path", mcp.Description("path"), mcp.DefaultString("")),
|
||||
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")),
|
||||
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")),
|
||||
mcp.WithString("sha", mcp.Description("sha")),
|
||||
mcp.WithString("path", mcp.Description("path")),
|
||||
)
|
||||
)
|
||||
|
||||
func ListRepoCommitsFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
log.Debugf("Called ListRepoCommitsFn")
|
||||
owner := req.Params.Arguments["owner"].(string)
|
||||
repo := req.Params.Arguments["repo"].(string)
|
||||
owner, ok := req.Params.Arguments["owner"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("owner is required")
|
||||
}
|
||||
repo, ok := req.Params.Arguments["repo"].(string)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("repo is required")
|
||||
}
|
||||
sha, _ := req.Params.Arguments["sha"].(string)
|
||||
path, _ := req.Params.Arguments["path"].(string)
|
||||
opt := gitea_sdk.ListCommitOptions{
|
||||
ListOptions: gitea_sdk.ListOptions{
|
||||
Page: 1,
|
||||
PageSize: 1000,
|
||||
},
|
||||
SHA: req.Params.Arguments["sha"].(string),
|
||||
Path: req.Params.Arguments["path"].(string),
|
||||
SHA: sha,
|
||||
Path: path,
|
||||
}
|
||||
commits, _, err := gitea.Client().ListRepoCommits(owner, repo, opt)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user