| 101 | } |
| 102 | |
| 103 | func ListSecretScanningAlerts(t translations.TranslationHelperFunc) inventory.ServerTool { |
| 104 | schema := &jsonschema.Schema{ |
| 105 | Type: "object", |
| 106 | Properties: map[string]*jsonschema.Schema{ |
| 107 | "owner": { |
| 108 | Type: "string", |
| 109 | Description: "The owner of the repository.", |
| 110 | }, |
| 111 | "repo": { |
| 112 | Type: "string", |
| 113 | Description: "The name of the repository.", |
| 114 | }, |
| 115 | "state": { |
| 116 | Type: "string", |
| 117 | Description: "Filter by state", |
| 118 | Enum: []any{"open", "resolved"}, |
| 119 | }, |
| 120 | "secret_type": { |
| 121 | Type: "string", |
| 122 | Description: "A comma-separated list of secret types to return. All default secret patterns are returned. To return generic patterns, pass the token name(s) in the parameter.", |
| 123 | }, |
| 124 | "resolution": { |
| 125 | Type: "string", |
| 126 | Description: "Filter by resolution", |
| 127 | Enum: []any{"false_positive", "wont_fix", "revoked", "pattern_edited", "pattern_deleted", "used_in_tests"}, |
| 128 | }, |
| 129 | }, |
| 130 | Required: []string{"owner", "repo"}, |
| 131 | } |
| 132 | WithPagination(schema) |
| 133 | |
| 134 | return NewTool( |
| 135 | ToolsetMetadataSecretProtection, |
| 136 | mcp.Tool{ |
| 137 | Name: "list_secret_scanning_alerts", |
| 138 | Description: t("TOOL_LIST_SECRET_SCANNING_ALERTS_DESCRIPTION", "List secret scanning alerts in a GitHub repository."), |
| 139 | Annotations: &mcp.ToolAnnotations{ |
| 140 | Title: t("TOOL_LIST_SECRET_SCANNING_ALERTS_USER_TITLE", "List secret scanning alerts"), |
| 141 | ReadOnlyHint: true, |
| 142 | }, |
| 143 | InputSchema: schema, |
| 144 | }, |
| 145 | []scopes.Scope{scopes.SecurityEvents}, |
| 146 | func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) { |
| 147 | owner, err := RequiredParam[string](args, "owner") |
| 148 | if err != nil { |
| 149 | return utils.NewToolResultError(err.Error()), nil, nil |
| 150 | } |
| 151 | repo, err := RequiredParam[string](args, "repo") |
| 152 | if err != nil { |
| 153 | return utils.NewToolResultError(err.Error()), nil, nil |
| 154 | } |
| 155 | state, err := OptionalParam[string](args, "state") |
| 156 | if err != nil { |
| 157 | return utils.NewToolResultError(err.Error()), nil, nil |
| 158 | } |
| 159 | secretType, err := OptionalParam[string](args, "secret_type") |
| 160 | if err != nil { |