Ai
28 Star 261 Fork 75

开源中国/mcp-gitee

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
list_user_repos.go 2.15 KB
一键复制 编辑 原始数据 按行查看 历史
JJ-H 提交于 2025-06-16 16:10 +08:00 . feat: Support streamable http
package repository
import (
"context"
"gitee.com/oschina/mcp-gitee/operations/types"
"gitee.com/oschina/mcp-gitee/utils"
"github.com/mark3labs/mcp-go/mcp"
)
const (
// ListUserReposToolName is the name of the tool
ListUserReposToolName = "list_user_repos"
)
var ListUserReposTool = mcp.NewTool(
ListUserReposToolName,
mcp.WithDescription("List user authorized repositories"),
mcp.WithString(
"visibility",
mcp.Description("Visibility of repository"),
mcp.Enum("public", "private", "all"),
),
mcp.WithString(
"affiliation",
mcp.Description("Affiliation between user and repository"),
mcp.Enum("owner", "collaborator", "organization_member", "enterprise_member", "admin"),
),
mcp.WithString(
"type",
mcp.Description("Filter user repositories: their creation (owner), personal (personal), their membership (member), public (public), private (private), cannot be used together with visibility or affiliation parameters, otherwise a 422 error will be reported"),
mcp.Enum("all", "owner", "personal", "member", "public", "private"),
),
mcp.WithString(
"sort",
mcp.Description("Sorting method: creation time (created), update time (updated), last push time (pushed), warehouse ownership and name (full_name). Default: full_name"),
mcp.Enum("created", "updated", "pushed", "full_name"),
mcp.DefaultString("full_name"),
),
mcp.WithString(
"direction",
mcp.Description("Sorting direction: ascending (asc), descending (desc). Default: asc"),
mcp.Enum("asc", "desc"),
mcp.DefaultString("asc"),
),
mcp.WithString(
"q",
mcp.Description("Search keywords"),
),
mcp.WithNumber(
"page",
mcp.Description("Page number"),
mcp.DefaultNumber(1),
),
mcp.WithNumber(
"per_page",
mcp.Description("Number of results per page"),
mcp.DefaultNumber(20),
),
)
func ListUserReposHandler(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
apiUrl := "/user/repos"
args, _ := utils.ConvertArgumentsToMap(request.Params.Arguments)
giteeClient := utils.NewGiteeClient("GET", apiUrl, utils.WithContext(ctx), utils.WithQuery(args))
repositories := make([]types.Project, 0)
return giteeClient.HandleMCPResult(&repositories)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/oschina/mcp-gitee.git
git@gitee.com:oschina/mcp-gitee.git
oschina
mcp-gitee
mcp-gitee
v0.1.13

搜索帮助