mirror of
				https://gitea.com/gitea/gitea-mcp.git
				synced 2025-11-04 04:11:50 +00:00 
			
		
		
		
	fix
This commit is contained in:
		@@ -22,8 +22,10 @@ var (
 | 
			
		||||
		mcp.WithDescription("List repository commits"),
 | 
			
		||||
		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")),
 | 
			
		||||
		mcp.WithString("sha", mcp.Description("SHA or branch to start listing commits from")),
 | 
			
		||||
		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 {
 | 
			
		||||
		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)
 | 
			
		||||
	path, _ := req.Params.Arguments["path"].(string)
 | 
			
		||||
	opt := gitea_sdk.ListCommitOptions{
 | 
			
		||||
		ListOptions: gitea_sdk.ListOptions{
 | 
			
		||||
			Page:     1,
 | 
			
		||||
			PageSize: 1000,
 | 
			
		||||
			Page:     int(page),
 | 
			
		||||
			PageSize: int(pageSize),
 | 
			
		||||
		},
 | 
			
		||||
		SHA:  sha,
 | 
			
		||||
		Path: path,
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@ package repo
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"encoding/base64"
 | 
			
		||||
	"fmt"
 | 
			
		||||
 | 
			
		||||
	"gitea.com/gitea/gitea-mcp/pkg/gitea"
 | 
			
		||||
@@ -25,7 +26,7 @@ var (
 | 
			
		||||
		mcp.WithDescription("Get file"),
 | 
			
		||||
		mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")),
 | 
			
		||||
		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")),
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
@@ -47,7 +48,8 @@ var (
 | 
			
		||||
		mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")),
 | 
			
		||||
		mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")),
 | 
			
		||||
		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("branch_name", mcp.Required(), mcp.Description("branch name")),
 | 
			
		||||
	)
 | 
			
		||||
@@ -132,11 +134,17 @@ func UpdateFileFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolRe
 | 
			
		||||
	if !ok {
 | 
			
		||||
		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)
 | 
			
		||||
	message, _ := req.Params.Arguments["message"].(string)
 | 
			
		||||
	branchName, _ := req.Params.Arguments["branch_name"].(string)
 | 
			
		||||
 | 
			
		||||
	opt := gitea_sdk.UpdateFileOptions{
 | 
			
		||||
		Content: content,
 | 
			
		||||
		SHA:     sha,
 | 
			
		||||
		Content: base64.StdEncoding.EncodeToString([]byte(content)),
 | 
			
		||||
		FileOptions: gitea_sdk.FileOptions{
 | 
			
		||||
			Message:    message,
 | 
			
		||||
			BranchName: branchName,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user