MCPcopy Index your code
hub / github.com/github/github-mcp-server / ListLabels

Function ListLabels

pkg/github/labels.go:127–219  ·  view source on GitHub ↗

ListLabels lists labels from a repository

(t translations.TranslationHelperFunc)

Source from the content-addressed store, hash-verified

125
126// ListLabels lists labels from a repository
127func ListLabels(t translations.TranslationHelperFunc) inventory.ServerTool {
128 return NewTool(
129 ToolsetLabels,
130 mcp.Tool{
131 Name: "list_label",
132 Description: t("TOOL_LIST_LABEL_DESCRIPTION", "List labels from a repository"),
133 Annotations: &mcp.ToolAnnotations{
134 Title: t("TOOL_LIST_LABEL_DESCRIPTION", "List labels from a repository"),
135 ReadOnlyHint: true,
136 },
137 InputSchema: &jsonschema.Schema{
138 Type: "object",
139 Properties: map[string]*jsonschema.Schema{
140 "owner": {
141 Type: "string",
142 Description: "Repository owner (username or organization name) - required for all operations",
143 },
144 "repo": {
145 Type: "string",
146 Description: "Repository name - required for all operations",
147 },
148 },
149 Required: []string{"owner", "repo"},
150 },
151 },
152 []scopes.Scope{scopes.Repo},
153 func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
154 owner, err := RequiredParam[string](args, "owner")
155 if err != nil {
156 return utils.NewToolResultError(err.Error()), nil, nil
157 }
158
159 repo, err := RequiredParam[string](args, "repo")
160 if err != nil {
161 return utils.NewToolResultError(err.Error()), nil, nil
162 }
163
164 client, err := deps.GetGQLClient(ctx)
165 if err != nil {
166 return nil, nil, fmt.Errorf("failed to get GitHub client: %w", err)
167 }
168
169 var query struct {
170 Repository struct {
171 Labels struct {
172 Nodes []struct {
173 ID githubv4.ID
174 Name githubv4.String
175 Color githubv4.String
176 Description githubv4.String
177 }
178 TotalCount githubv4.Int
179 } `graphql:"labels(first: 100)"`
180 } `graphql:"repository(owner: $owner, name: $repo)"`
181 }
182
183 vars := map[string]any{
184 "owner": githubv4.String(owner),

Callers 2

AllToolsFunction · 0.85
TestListLabelsFunction · 0.85

Calls 7

NewToolResultErrorFunction · 0.92
NewToolResultTextFunction · 0.92
NewToolFunction · 0.85
GetGQLClientMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by 1

TestListLabelsFunction · 0.68