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

Function GetDependabotAlert

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

Source from the content-addressed store, hash-verified

19)
20
21func GetDependabotAlert(t translations.TranslationHelperFunc) inventory.ServerTool {
22 return NewTool(
23 ToolsetMetadataDependabot,
24 mcp.Tool{
25 Name: "get_dependabot_alert",
26 Description: t("TOOL_GET_DEPENDABOT_ALERT_DESCRIPTION", "Get details of a specific dependabot alert in a GitHub repository."),
27 Annotations: &mcp.ToolAnnotations{
28 Title: t("TOOL_GET_DEPENDABOT_ALERT_USER_TITLE", "Get dependabot 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 utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, err
68 }
69
70 alert, resp, err := client.Dependabot.GetRepoAlert(ctx, owner, repo, alertNumber)
71 if err != nil {
72 return ghErrors.NewGitHubAPIErrorResponse(ctx,
73 dependabotErrMsg(fmt.Sprintf("failed to get alert with number '%d'", alertNumber), owner, repo, resp),
74 resp,
75 err,
76 ), nil, nil
77 }
78 defer func() { _ = resp.Body.Close() }()

Callers 2

AllToolsFunction · 0.85
Test_GetDependabotAlertFunction · 0.85

Calls 11

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

Tested by 1

Test_GetDependabotAlertFunction · 0.68