MCPcopy Create free account
hub / github.com/github/github-mcp-server / completeOwner

Function completeOwner

pkg/github/repository_resource_completions.go:76–121  ·  view source on GitHub ↗

--- Per-argument resolver functions ---

(ctx context.Context, client *github.Client, _ map[string]string, argValue string)

Source from the content-addressed store, hash-verified

74// --- Per-argument resolver functions ---
75
76func completeOwner(ctx context.Context, client *github.Client, _ map[string]string, argValue string) ([]string, error) {
77 var values []string
78 user, _, err := client.Users.Get(ctx, "")
79 if err == nil && user.GetLogin() != "" {
80 values = append(values, user.GetLogin())
81 }
82
83 orgs, _, err := client.Organizations.List(ctx, "", &github.ListOptions{PerPage: 100})
84 if err != nil {
85 return nil, err
86 }
87 for _, org := range orgs {
88 values = append(values, org.GetLogin())
89 }
90
91 // filter values based on argValue and replace values slice
92 if argValue != "" {
93 var filteredValues []string
94 for _, value := range values {
95 if strings.Contains(value, argValue) {
96 filteredValues = append(filteredValues, value)
97 }
98 }
99 values = filteredValues
100 }
101 if len(values) > 100 {
102 values = values[:100]
103 return values, nil // Limit to 100 results
104 }
105 // Else also do a client.Search.Users()
106 if argValue == "" {
107 return values, nil // No need to search if no argValue
108 }
109 users, _, err := client.Search.Users(ctx, argValue, &github.SearchOptions{ListOptions: github.ListOptions{PerPage: 100 - len(values)}})
110 if err != nil || users == nil {
111 return nil, err
112 }
113 for _, user := range users.Users {
114 values = append(values, user.GetLogin())
115 }
116
117 if len(values) > 100 {
118 values = values[:100]
119 }
120 return values, nil
121}
122
123func completeRepo(ctx context.Context, client *github.Client, resolved map[string]string, argValue string) ([]string, error) {
124 var values []string

Callers

nothing calls this directly

Calls 1

ListMethod · 0.80

Tested by

no test coverage detected