mirror of
				https://gitea.com/gitea/gitea-mcp.git
				synced 2025-10-30 01:41:50 +00:00 
			
		
		
		
	Update
This commit is contained in:
		| @@ -6,7 +6,9 @@ import ( | |||||||
|  |  | ||||||
| 	"gitea.com/gitea/gitea-mcp/pkg/gitea" | 	"gitea.com/gitea/gitea-mcp/pkg/gitea" | ||||||
| 	"gitea.com/gitea/gitea-mcp/pkg/to" | 	"gitea.com/gitea/gitea-mcp/pkg/to" | ||||||
|  |  | ||||||
| 	"github.com/mark3labs/mcp-go/mcp" | 	"github.com/mark3labs/mcp-go/mcp" | ||||||
|  | 	"github.com/mark3labs/mcp-go/server" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| const ( | const ( | ||||||
| @@ -25,20 +27,27 @@ var ( | |||||||
| 			"owner", | 			"owner", | ||||||
| 			mcp.Required(), | 			mcp.Required(), | ||||||
| 			mcp.Description("repository owner"), | 			mcp.Description("repository owner"), | ||||||
|  | 			mcp.DefaultString(""), | ||||||
| 		), | 		), | ||||||
| 		mcp.WithString( | 		mcp.WithString( | ||||||
| 			"repo", | 			"repo", | ||||||
| 			mcp.Required(), | 			mcp.Required(), | ||||||
| 			mcp.Description("repository name"), | 			mcp.Description("repository name"), | ||||||
|  | 			mcp.DefaultString(""), | ||||||
| 		), | 		), | ||||||
| 		mcp.WithNumber( | 		mcp.WithNumber( | ||||||
| 			"index", | 			"index", | ||||||
| 			mcp.Required(), | 			mcp.Required(), | ||||||
| 			mcp.Description("repository issue index"), | 			mcp.Description("repository issue index"), | ||||||
|  | 			mcp.DefaultNumber(0), | ||||||
| 		), | 		), | ||||||
| 	} | 	} | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | func RegisterTool(s *server.MCPServer) { | ||||||
|  | 	s.AddTool(GetIssueByIndexTool, GetIssueByIndexFn) | ||||||
|  | } | ||||||
|  |  | ||||||
| func GetIssueByIndexFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { | func GetIssueByIndexFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { | ||||||
| 	owner := req.Params.Arguments["owner"].(string) | 	owner := req.Params.Arguments["owner"].(string) | ||||||
| 	repo := req.Params.Arguments["repo"].(string) | 	repo := req.Params.Arguments["repo"].(string) | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ import ( | |||||||
| 	"gitea.com/gitea/gitea-mcp/operation/version" | 	"gitea.com/gitea/gitea-mcp/operation/version" | ||||||
| 	"gitea.com/gitea/gitea-mcp/pkg/flag" | 	"gitea.com/gitea/gitea-mcp/pkg/flag" | ||||||
| 	"gitea.com/gitea/gitea-mcp/pkg/log" | 	"gitea.com/gitea/gitea-mcp/pkg/log" | ||||||
|  |  | ||||||
| 	"github.com/mark3labs/mcp-go/server" | 	"github.com/mark3labs/mcp-go/server" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| @@ -18,17 +19,16 @@ var ( | |||||||
|  |  | ||||||
| func RegisterTool(s *server.MCPServer) { | func RegisterTool(s *server.MCPServer) { | ||||||
| 	// User Tool | 	// User Tool | ||||||
| 	s.AddTool(user.GetMyUserInfoTool, user.GetUserInfoFn) | 	user.RegisterTool(s) | ||||||
|  |  | ||||||
| 	// Repo Tool | 	// Repo Tool | ||||||
| 	s.AddTool(repo.CreateRepoTool, repo.CreateRepoFn) | 	repo.RegisterTool(s) | ||||||
| 	s.AddTool(repo.ListMyReposTool, repo.ListMyReposFn) |  | ||||||
|  |  | ||||||
| 	// Issue Tool | 	// Issue Tool | ||||||
| 	s.AddTool(issue.GetIssueByIndexTool, issue.GetIssueByIndexFn) | 	issue.RegisterTool(s) | ||||||
|  |  | ||||||
| 	// Version Tool | 	// Version Tool | ||||||
| 	s.AddTool(version.GetGiteaMCPServerVersionTool, version.GetGiteaMCPServerVersionFn) | 	version.RegisterTool(s) | ||||||
| } | } | ||||||
|  |  | ||||||
| func Run(transport, version string) error { | func Run(transport, version string) error { | ||||||
|   | |||||||
| @@ -6,7 +6,9 @@ import ( | |||||||
| 	"code.gitea.io/sdk/gitea" | 	"code.gitea.io/sdk/gitea" | ||||||
| 	giteaPkg "gitea.com/gitea/gitea-mcp/pkg/gitea" | 	giteaPkg "gitea.com/gitea/gitea-mcp/pkg/gitea" | ||||||
| 	"gitea.com/gitea/gitea-mcp/pkg/to" | 	"gitea.com/gitea/gitea-mcp/pkg/to" | ||||||
|  |  | ||||||
| 	"github.com/mark3labs/mcp-go/mcp" | 	"github.com/mark3labs/mcp-go/mcp" | ||||||
|  | 	"github.com/mark3labs/mcp-go/server" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| const ( | const ( | ||||||
| @@ -22,16 +24,16 @@ var ( | |||||||
|  |  | ||||||
| 	CreateRepoOpt = []mcp.ToolOption{ | 	CreateRepoOpt = []mcp.ToolOption{ | ||||||
| 		mcp.WithDescription("Create repository"), | 		mcp.WithDescription("Create repository"), | ||||||
| 		mcp.WithString("name", mcp.Required(), mcp.Description("Name of the repository to create")), | 		mcp.WithString("name", mcp.Required(), mcp.DefaultString("test"), mcp.Description("Name of the repository to create")), | ||||||
| 		mcp.WithString("description", mcp.Description("Description of the repository to create")), | 		mcp.WithString("description", mcp.DefaultString(""), mcp.Description("Description of the repository to create")), | ||||||
| 		mcp.WithBoolean("private", mcp.Description("Whether the repository is private")), | 		mcp.WithBoolean("private", mcp.DefaultBool(true), mcp.Description("Whether the repository is private")), | ||||||
| 		mcp.WithString("issue_labels", mcp.Description("Issue Label set to use")), | 		mcp.WithString("issue_labels", mcp.DefaultString(""), mcp.Description("Issue Label set to use")), | ||||||
| 		mcp.WithBoolean("auto_init", mcp.Description("Whether the repository should be auto-intialized?")), | 		mcp.WithBoolean("auto_init", mcp.DefaultBool(false), mcp.Description("Whether the repository should be auto-intialized?")), | ||||||
| 		mcp.WithBoolean("template", mcp.Description("Whether the repository is template")), | 		mcp.WithBoolean("template", mcp.DefaultBool(false), mcp.Description("Whether the repository is template")), | ||||||
| 		mcp.WithString("gitignores", mcp.Description("Gitignores to use")), | 		mcp.WithString("gitignores", mcp.DefaultString(""), mcp.Description("Gitignores to use")), | ||||||
| 		mcp.WithString("license", mcp.Description("License to use")), | 		mcp.WithString("license", mcp.DefaultString("MIT"), mcp.Description("License to use")), | ||||||
| 		mcp.WithString("readme", mcp.Description("Readme of the repository to create")), | 		mcp.WithString("readme", mcp.DefaultString(""), mcp.Description("Readme of the repository to create")), | ||||||
| 		mcp.WithString("default_branch", mcp.Description("DefaultBranch of the repository (used when initializes and in template)")), | 		mcp.WithString("default_branch", mcp.DefaultString("main"), mcp.Description("DefaultBranch of the repository (used when initializes and in template)")), | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	ListMyReposTool = mcp.NewTool( | 	ListMyReposTool = mcp.NewTool( | ||||||
| @@ -56,6 +58,11 @@ var ( | |||||||
| 	} | 	} | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | func RegisterTool(s *server.MCPServer) { | ||||||
|  | 	s.AddTool(CreateRepoTool, CreateRepoFn) | ||||||
|  | 	s.AddTool(ListMyReposTool, ListMyReposFn) | ||||||
|  | } | ||||||
|  |  | ||||||
| func CreateRepoFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { | func CreateRepoFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { | ||||||
| 	name := req.Params.Arguments["name"].(string) | 	name := req.Params.Arguments["name"].(string) | ||||||
| 	description := req.Params.Arguments["description"].(string) | 	description := req.Params.Arguments["description"].(string) | ||||||
|   | |||||||
| @@ -7,6 +7,7 @@ import ( | |||||||
| 	"gitea.com/gitea/gitea-mcp/pkg/to" | 	"gitea.com/gitea/gitea-mcp/pkg/to" | ||||||
|  |  | ||||||
| 	"github.com/mark3labs/mcp-go/mcp" | 	"github.com/mark3labs/mcp-go/mcp" | ||||||
|  | 	"github.com/mark3labs/mcp-go/server" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| const ( | const ( | ||||||
| @@ -20,6 +21,10 @@ var ( | |||||||
| 	) | 	) | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | func RegisterTool(s *server.MCPServer) { | ||||||
|  | 	s.AddTool(GetMyUserInfoTool, GetUserInfoFn) | ||||||
|  | } | ||||||
|  |  | ||||||
| func GetUserInfoFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { | func GetUserInfoFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { | ||||||
| 	user, _, err := gitea.Client().GetMyUserInfo() | 	user, _, err := gitea.Client().GetMyUserInfo() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|   | |||||||
| @@ -6,7 +6,9 @@ import ( | |||||||
|  |  | ||||||
| 	"gitea.com/gitea/gitea-mcp/pkg/flag" | 	"gitea.com/gitea/gitea-mcp/pkg/flag" | ||||||
| 	"gitea.com/gitea/gitea-mcp/pkg/to" | 	"gitea.com/gitea/gitea-mcp/pkg/to" | ||||||
|  |  | ||||||
| 	"github.com/mark3labs/mcp-go/mcp" | 	"github.com/mark3labs/mcp-go/mcp" | ||||||
|  | 	"github.com/mark3labs/mcp-go/server" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| const ( | const ( | ||||||
| @@ -20,6 +22,10 @@ var ( | |||||||
| 	) | 	) | ||||||
| ) | ) | ||||||
|  |  | ||||||
|  | func RegisterTool(s *server.MCPServer) { | ||||||
|  | 	s.AddTool(GetGiteaMCPServerVersionTool, GetGiteaMCPServerVersionFn) | ||||||
|  | } | ||||||
|  |  | ||||||
| func GetGiteaMCPServerVersionFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { | func GetGiteaMCPServerVersionFn(ctx context.Context, req mcp.CallToolRequest) (*mcp.CallToolResult, error) { | ||||||
| 	version := flag.Version | 	version := flag.Version | ||||||
| 	if version == "" { | 	if version == "" { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user