MCPcopy
hub / github.com/github/github-mcp-server / GetSecretScanningAlert

Function GetSecretScanningAlert

pkg/github/secret_scanning.go:21–101  ·  view source on GitHub ↗
(t translations.TranslationHelperFunc)

Source from the content-addressed store, hash-verified

19)
20
21func GetSecretScanningAlert(t translations.TranslationHelperFunc) inventory.ServerTool {
22 return NewTool(
23 ToolsetMetadataSecretProtection,
24 mcp.Tool{
25 Name: "get_secret_scanning_alert",
26 Description: t("TOOL_GET_SECRET_SCANNING_ALERT_DESCRIPTION", "Get details of a specific secret scanning alert in a GitHub repository."),
27 Annotations: &mcp.ToolAnnotations{
28 Title: t("TOOL_GET_SECRET_SCANNING_ALERT_USER_TITLE", "Get secret scanning alert"),
29 ReadOnlyHint: true,
30 },
31 InputSchema: &jsonschema.Schema{
32 Type: "object",
33 Properties: map[string]*jsonschema.Schema{
34 "owner": {
35 Type: "string",
36 Description: "The owner of the repository.",
37 },
38 "repo": {
39 Type: "string",
40 Description: "The name of the repository.",
41 },
42 "alertNumber": {
43 Type: "number",
44 Description: "The number of the alert.",
45 },
46 },
47 Required: []string{"owner", "repo", "alertNumber"},
48 },
49 },
50 []scopes.Scope{scopes.SecurityEvents},
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 repo, err := RequiredParam[string](args, "repo")
57 if err != nil {
58 return utils.NewToolResultError(err.Error()), nil, nil
59 }
60 alertNumber, err := RequiredInt(args, "alertNumber")
61 if err != nil {
62 return utils.NewToolResultError(err.Error()), nil, nil
63 }
64
65 client, err := deps.GetClient(ctx)
66 if err != nil {
67 return nil, nil, fmt.Errorf("failed to get GitHub client: %w", err)
68 }
69
70 alert, resp, err := client.SecretScanning.GetAlert(ctx, owner, repo, int64(alertNumber))
71 if err != nil {
72 return ghErrors.NewGitHubAPIErrorResponse(ctx,
73 fmt.Sprintf("failed to get alert with number '%d'", alertNumber),
74 resp,
75 err,
76 ), nil, nil
77 }
78 defer func() { _ = resp.Body.Close() }()

Callers 2

AllToolsFunction · 0.85

Calls 9

NewToolResultErrorFunction · 0.92
NewToolResultTextFunction · 0.92
LabelSecurityAlertFunction · 0.92
NewToolFunction · 0.85
RequiredIntFunction · 0.85
attachStaticIFCLabelFunction · 0.85
CloseMethod · 0.80
GetClientMethod · 0.65
ErrorMethod · 0.45

Tested by 1