GetLabel retrieves a specific label by name from a GitHub repository
(t translations.TranslationHelperFunc)
| 19 | |
| 20 | // GetLabel retrieves a specific label by name from a GitHub repository |
| 21 | func GetLabel(t translations.TranslationHelperFunc) inventory.ServerTool { |
| 22 | return NewTool( |
| 23 | ToolsetMetadataIssues, |
| 24 | mcp.Tool{ |
| 25 | Name: "get_label", |
| 26 | Description: t("TOOL_GET_LABEL_DESCRIPTION", "Get a specific label from a repository."), |
| 27 | Annotations: &mcp.ToolAnnotations{ |
| 28 | Title: t("TOOL_GET_LABEL_TITLE", "Get a specific label from a repository"), |
| 29 | ReadOnlyHint: true, |
| 30 | }, |
| 31 | InputSchema: &jsonschema.Schema{ |
| 32 | Type: "object", |
| 33 | Properties: map[string]*jsonschema.Schema{ |
| 34 | "owner": { |
| 35 | Type: "string", |
| 36 | Description: "Repository owner (username or organization name)", |
| 37 | }, |
| 38 | "repo": { |
| 39 | Type: "string", |
| 40 | Description: "Repository name", |
| 41 | }, |
| 42 | "name": { |
| 43 | Type: "string", |
| 44 | Description: "Label name.", |
| 45 | }, |
| 46 | }, |
| 47 | Required: []string{"owner", "repo", "name"}, |
| 48 | }, |
| 49 | }, |
| 50 | []scopes.Scope{scopes.Repo}, |
| 51 | func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) { |
| 52 | owner, err := RequiredParam[string](args, "owner") |
| 53 | if err != nil { |
| 54 | return utils.NewToolResultError(err.Error()), nil, nil |
| 55 | } |
| 56 | |
| 57 | repo, err := RequiredParam[string](args, "repo") |
| 58 | if err != nil { |
| 59 | return utils.NewToolResultError(err.Error()), nil, nil |
| 60 | } |
| 61 | |
| 62 | name, err := RequiredParam[string](args, "name") |
| 63 | if err != nil { |
| 64 | return utils.NewToolResultError(err.Error()), nil, nil |
| 65 | } |
| 66 | |
| 67 | var query struct { |
| 68 | Repository struct { |
| 69 | Label struct { |
| 70 | ID githubv4.ID |
| 71 | Name githubv4.String |
| 72 | Color githubv4.String |
| 73 | Description githubv4.String |
| 74 | } `graphql:"label(name: $name)"` |
| 75 | } `graphql:"repository(owner: $owner, name: $repo)"` |
| 76 | } |
| 77 | |
| 78 | vars := map[string]any{ |