feat: add missing administration tools
Add 20+ new MCP tools for repository administration: - Repository: get_repo, repo_write (edit/delete/transfer), list_forks - Branch Protection: read (list/get) and write (create/edit/delete) - Webhooks: read (list/get) and write (create/edit/delete/test) - Collaborators: read (list) and write (add/delete) - Deploy Keys: read (list/get) and write (create/delete) - Topics: read (list) and write (add/delete/set) - Compare: get_compare for branch/tag/commit comparison - Organization: org_read (get/list_teams/get_team/list_team_members/list_team_repos) and org_write (create_team/delete_team/add_team_member/remove_team_member/add_team_repo/remove_team_repo) - PR enhancements: list_files and is_merged methods added to pull_request_read Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -206,6 +206,146 @@ func slimTree(t *gitea_sdk.GitTreeResponse) map[string]any {
|
||||
}
|
||||
}
|
||||
|
||||
func slimRepoDetail(r *gitea_sdk.Repository) map[string]any {
|
||||
if r == nil {
|
||||
return nil
|
||||
}
|
||||
m := slimRepo(r)
|
||||
m["website"] = r.Website
|
||||
m["has_issues"] = r.HasIssues
|
||||
m["has_wiki"] = r.HasWiki
|
||||
m["has_pull_requests"] = r.HasPullRequests
|
||||
m["has_projects"] = r.HasProjects
|
||||
m["mirror"] = r.Mirror
|
||||
m["internal"] = r.Internal
|
||||
m["empty"] = r.Empty
|
||||
m["size"] = r.Size
|
||||
if r.Permissions != nil {
|
||||
m["permissions"] = map[string]any{
|
||||
"admin": r.Permissions.Admin,
|
||||
"push": r.Permissions.Push,
|
||||
"pull": r.Permissions.Pull,
|
||||
}
|
||||
}
|
||||
if r.Parent != nil {
|
||||
m["parent"] = map[string]any{
|
||||
"full_name": r.Parent.FullName,
|
||||
"html_url": r.Parent.HTMLURL,
|
||||
}
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func slimUser(u *gitea_sdk.User) map[string]any {
|
||||
if u == nil {
|
||||
return nil
|
||||
}
|
||||
return map[string]any{
|
||||
"id": u.ID,
|
||||
"login": u.UserName,
|
||||
"full_name": u.FullName,
|
||||
"email": u.Email,
|
||||
"avatar_url": u.AvatarURL,
|
||||
"is_admin": u.IsAdmin,
|
||||
}
|
||||
}
|
||||
|
||||
func slimUsers(users []*gitea_sdk.User) []map[string]any {
|
||||
out := make([]map[string]any, 0, len(users))
|
||||
for _, u := range users {
|
||||
out = append(out, slimUser(u))
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func slimDeployKey(k *gitea_sdk.DeployKey) map[string]any {
|
||||
if k == nil {
|
||||
return nil
|
||||
}
|
||||
return map[string]any{
|
||||
"id": k.ID,
|
||||
"title": k.Title,
|
||||
"fingerprint": k.Fingerprint,
|
||||
"key": k.Key,
|
||||
"url": k.URL,
|
||||
"read_only": k.ReadOnly,
|
||||
"created_at": k.Created,
|
||||
}
|
||||
}
|
||||
|
||||
func slimDeployKeys(keys []*gitea_sdk.DeployKey) []map[string]any {
|
||||
out := make([]map[string]any, 0, len(keys))
|
||||
for _, k := range keys {
|
||||
out = append(out, slimDeployKey(k))
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func slimBranchProtection(bp *gitea_sdk.BranchProtection) map[string]any {
|
||||
if bp == nil {
|
||||
return nil
|
||||
}
|
||||
return map[string]any{
|
||||
"branch_name": bp.BranchName,
|
||||
"rule_name": bp.RuleName,
|
||||
"enable_push": bp.EnablePush,
|
||||
"push_whitelist_usernames": bp.PushWhitelistUsernames,
|
||||
"push_whitelist_teams": bp.PushWhitelistTeams,
|
||||
"enable_merge_whitelist": bp.EnableMergeWhitelist,
|
||||
"merge_whitelist_usernames": bp.MergeWhitelistUsernames,
|
||||
"merge_whitelist_teams": bp.MergeWhitelistTeams,
|
||||
"required_approvals": bp.RequiredApprovals,
|
||||
"enable_approvals_whitelist": bp.EnableApprovalsWhitelist,
|
||||
"block_on_rejected_reviews": bp.BlockOnRejectedReviews,
|
||||
"block_on_outdated_branch": bp.BlockOnOutdatedBranch,
|
||||
"dismiss_stale_approvals": bp.DismissStaleApprovals,
|
||||
"require_signed_commits": bp.RequireSignedCommits,
|
||||
"protected_file_patterns": bp.ProtectedFilePatterns,
|
||||
"unprotected_file_patterns": bp.UnprotectedFilePatterns,
|
||||
"created_at": bp.Created,
|
||||
"updated_at": bp.Updated,
|
||||
}
|
||||
}
|
||||
|
||||
func slimBranchProtections(bps []*gitea_sdk.BranchProtection) []map[string]any {
|
||||
out := make([]map[string]any, 0, len(bps))
|
||||
for _, bp := range bps {
|
||||
out = append(out, slimBranchProtection(bp))
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func slimHook(h *gitea_sdk.Hook) map[string]any {
|
||||
if h == nil {
|
||||
return nil
|
||||
}
|
||||
m := map[string]any{
|
||||
"id": h.ID,
|
||||
"type": h.Type,
|
||||
"active": h.Active,
|
||||
"events": h.Events,
|
||||
"created_at": h.Created,
|
||||
"updated_at": h.Updated,
|
||||
}
|
||||
if h.Config != nil {
|
||||
if url, ok := h.Config["url"]; ok {
|
||||
m["url"] = url
|
||||
}
|
||||
if ct, ok := h.Config["content_type"]; ok {
|
||||
m["content_type"] = ct
|
||||
}
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func slimHooks(hooks []*gitea_sdk.Hook) []map[string]any {
|
||||
out := make([]map[string]any, 0, len(hooks))
|
||||
for _, h := range hooks {
|
||||
out = append(out, slimHook(h))
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func slimDirEntries(entries []*gitea_sdk.ContentsResponse) []map[string]any {
|
||||
out := make([]map[string]any, 0, len(entries))
|
||||
for _, c := range entries {
|
||||
|
||||
Reference in New Issue
Block a user