Skip to content

Commit c06ace3

Browse files
CopilotomgitsadsLuluBeatson
authored
Migrate security_advisories toolset to modelcontextprotocol/go-sdk (#1434)
* Initial plan * Migrate security_advisories toolset to modelcontextprotocol/go-sdk Co-authored-by: omgitsads <[email protected]> * Add toolsnaps tests and snapshots for security_advisories Co-authored-by: omgitsads <[email protected]> * Dont bubble up an error for getClient We should do this eventually, but to keep the existing behavior, we just return the error to the client. * re-add security_advisories toolset * Revert this change from the base PR --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: omgitsads <[email protected]> Co-authored-by: Adam Holt <[email protected]> Co-authored-by: LuluBeatson <[email protected]>
1 parent a405519 commit c06ace3

9 files changed

+651
-369
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"annotations": {
3+
"readOnlyHint": true,
4+
"title": "Get a global security advisory"
5+
},
6+
"description": "Get a global security advisory",
7+
"inputSchema": {
8+
"type": "object",
9+
"required": [
10+
"ghsaId"
11+
],
12+
"properties": {
13+
"ghsaId": {
14+
"type": "string",
15+
"description": "GitHub Security Advisory ID (format: GHSA-xxxx-xxxx-xxxx)."
16+
}
17+
}
18+
},
19+
"name": "get_global_security_advisory"
20+
}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"annotations": {
3+
"readOnlyHint": true,
4+
"title": "List global security advisories"
5+
},
6+
"description": "List global security advisories from GitHub.",
7+
"inputSchema": {
8+
"type": "object",
9+
"properties": {
10+
"affects": {
11+
"type": "string",
12+
"description": "Filter advisories by affected package or version (e.g. \"package1,[email protected]\")."
13+
},
14+
"cveId": {
15+
"type": "string",
16+
"description": "Filter by CVE ID."
17+
},
18+
"cwes": {
19+
"type": "array",
20+
"description": "Filter by Common Weakness Enumeration IDs (e.g. [\"79\", \"284\", \"22\"]).",
21+
"items": {
22+
"type": "string"
23+
}
24+
},
25+
"ecosystem": {
26+
"type": "string",
27+
"description": "Filter by package ecosystem.",
28+
"enum": [
29+
"actions",
30+
"composer",
31+
"erlang",
32+
"go",
33+
"maven",
34+
"npm",
35+
"nuget",
36+
"other",
37+
"pip",
38+
"pub",
39+
"rubygems",
40+
"rust"
41+
]
42+
},
43+
"ghsaId": {
44+
"type": "string",
45+
"description": "Filter by GitHub Security Advisory ID (format: GHSA-xxxx-xxxx-xxxx)."
46+
},
47+
"isWithdrawn": {
48+
"type": "boolean",
49+
"description": "Whether to only return withdrawn advisories."
50+
},
51+
"modified": {
52+
"type": "string",
53+
"description": "Filter by publish or update date or date range (ISO 8601 date or range)."
54+
},
55+
"published": {
56+
"type": "string",
57+
"description": "Filter by publish date or date range (ISO 8601 date or range)."
58+
},
59+
"severity": {
60+
"type": "string",
61+
"description": "Filter by severity.",
62+
"enum": [
63+
"unknown",
64+
"low",
65+
"medium",
66+
"high",
67+
"critical"
68+
]
69+
},
70+
"type": {
71+
"type": "string",
72+
"description": "Advisory type.",
73+
"default": "reviewed",
74+
"enum": [
75+
"reviewed",
76+
"malware",
77+
"unreviewed"
78+
]
79+
},
80+
"updated": {
81+
"type": "string",
82+
"description": "Filter by update date or date range (ISO 8601 date or range)."
83+
}
84+
}
85+
},
86+
"name": "list_global_security_advisories"
87+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"annotations": {
3+
"readOnlyHint": true,
4+
"title": "List org repository security advisories"
5+
},
6+
"description": "List repository security advisories for a GitHub organization.",
7+
"inputSchema": {
8+
"type": "object",
9+
"required": [
10+
"org"
11+
],
12+
"properties": {
13+
"direction": {
14+
"type": "string",
15+
"description": "Sort direction.",
16+
"enum": [
17+
"asc",
18+
"desc"
19+
]
20+
},
21+
"org": {
22+
"type": "string",
23+
"description": "The organization login."
24+
},
25+
"sort": {
26+
"type": "string",
27+
"description": "Sort field.",
28+
"enum": [
29+
"created",
30+
"updated",
31+
"published"
32+
]
33+
},
34+
"state": {
35+
"type": "string",
36+
"description": "Filter by advisory state.",
37+
"enum": [
38+
"triage",
39+
"draft",
40+
"published",
41+
"closed"
42+
]
43+
}
44+
}
45+
},
46+
"name": "list_org_repository_security_advisories"
47+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"annotations": {
3+
"readOnlyHint": true,
4+
"title": "List repository security advisories"
5+
},
6+
"description": "List repository security advisories for a GitHub repository.",
7+
"inputSchema": {
8+
"type": "object",
9+
"required": [
10+
"owner",
11+
"repo"
12+
],
13+
"properties": {
14+
"direction": {
15+
"type": "string",
16+
"description": "Sort direction.",
17+
"enum": [
18+
"asc",
19+
"desc"
20+
]
21+
},
22+
"owner": {
23+
"type": "string",
24+
"description": "The owner of the repository."
25+
},
26+
"repo": {
27+
"type": "string",
28+
"description": "The name of the repository."
29+
},
30+
"sort": {
31+
"type": "string",
32+
"description": "Sort field.",
33+
"enum": [
34+
"created",
35+
"updated",
36+
"published"
37+
]
38+
},
39+
"state": {
40+
"type": "string",
41+
"description": "Filter by advisory state.",
42+
"enum": [
43+
"triage",
44+
"draft",
45+
"published",
46+
"closed"
47+
]
48+
}
49+
}
50+
},
51+
"name": "list_repository_security_advisories"
52+
}

pkg/github/context_tools.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func GetMe(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Too
4747
mcp.ToolHandlerFor[map[string]any, any](func(ctx context.Context, _ *mcp.CallToolRequest, _ map[string]any) (*mcp.CallToolResult, any, error) {
4848
client, err := getClient(ctx)
4949
if err != nil {
50-
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, err
50+
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil
5151
}
5252

5353
user, res, err := client.Users.Get(ctx, "")

pkg/github/context_tools_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ func Test_GetMe(t *testing.T) {
115115
textContent := getTextResult(t, result)
116116

117117
if tc.expectToolError {
118-
assert.Error(t, err)
119118
assert.True(t, result.IsError, "expected tool call result to be an error")
120119
assert.Contains(t, textContent.Text, tc.expectedToolErrMsg)
121120
return

0 commit comments

Comments
 (0)