@@ -94,6 +94,41 @@ func GetCodeScanningAlert(t translations.TranslationHelperFunc) inventory.Server
9494}
9595
9696func ListCodeScanningAlerts (t translations.TranslationHelperFunc ) inventory.ServerTool {
97+ schema := & jsonschema.Schema {
98+ Type : "object" ,
99+ Properties : map [string ]* jsonschema.Schema {
100+ "owner" : {
101+ Type : "string" ,
102+ Description : "The owner of the repository." ,
103+ },
104+ "repo" : {
105+ Type : "string" ,
106+ Description : "The name of the repository." ,
107+ },
108+ "state" : {
109+ Type : "string" ,
110+ Description : "Filter code scanning alerts by state. Defaults to open" ,
111+ Enum : []any {"open" , "closed" , "dismissed" , "fixed" },
112+ Default : json .RawMessage (`"open"` ),
113+ },
114+ "ref" : {
115+ Type : "string" ,
116+ Description : "The Git reference for the results you want to list." ,
117+ },
118+ "severity" : {
119+ Type : "string" ,
120+ Description : "Filter code scanning alerts by severity" ,
121+ Enum : []any {"critical" , "high" , "medium" , "low" , "warning" , "note" , "error" },
122+ },
123+ "tool_name" : {
124+ Type : "string" ,
125+ Description : "The name of the tool used for code scanning." ,
126+ },
127+ },
128+ Required : []string {"owner" , "repo" },
129+ }
130+ WithPagination (schema )
131+
97132 return NewTool (
98133 ToolsetMetadataCodeSecurity ,
99134 mcp.Tool {
@@ -103,39 +138,7 @@ func ListCodeScanningAlerts(t translations.TranslationHelperFunc) inventory.Serv
103138 Title : t ("TOOL_LIST_CODE_SCANNING_ALERTS_USER_TITLE" , "List code scanning alerts" ),
104139 ReadOnlyHint : true ,
105140 },
106- InputSchema : & jsonschema.Schema {
107- Type : "object" ,
108- Properties : map [string ]* jsonschema.Schema {
109- "owner" : {
110- Type : "string" ,
111- Description : "The owner of the repository." ,
112- },
113- "repo" : {
114- Type : "string" ,
115- Description : "The name of the repository." ,
116- },
117- "state" : {
118- Type : "string" ,
119- Description : "Filter code scanning alerts by state. Defaults to open" ,
120- Enum : []any {"open" , "closed" , "dismissed" , "fixed" },
121- Default : json .RawMessage (`"open"` ),
122- },
123- "ref" : {
124- Type : "string" ,
125- Description : "The Git reference for the results you want to list." ,
126- },
127- "severity" : {
128- Type : "string" ,
129- Description : "Filter code scanning alerts by severity" ,
130- Enum : []any {"critical" , "high" , "medium" , "low" , "warning" , "note" , "error" },
131- },
132- "tool_name" : {
133- Type : "string" ,
134- Description : "The name of the tool used for code scanning." ,
135- },
136- },
137- Required : []string {"owner" , "repo" },
138- },
141+ InputSchema : schema ,
139142 },
140143 []scopes.Scope {scopes .SecurityEvents },
141144 func (ctx context.Context , deps ToolDependencies , _ * mcp.CallToolRequest , args map [string ]any ) (* mcp.CallToolResult , any , error ) {
@@ -164,11 +167,25 @@ func ListCodeScanningAlerts(t translations.TranslationHelperFunc) inventory.Serv
164167 return utils .NewToolResultError (err .Error ()), nil , nil
165168 }
166169
170+ pagination , err := OptionalPaginationParams (args )
171+ if err != nil {
172+ return utils .NewToolResultError (err .Error ()), nil , nil
173+ }
174+
167175 client , err := deps .GetClient (ctx )
168176 if err != nil {
169177 return utils .NewToolResultErrorFromErr ("failed to get GitHub client" , err ), nil , nil
170178 }
171- alerts , resp , err := client .CodeScanning .ListAlertsForRepo (ctx , owner , repo , & github.AlertListOptions {Ref : ref , State : state , Severity : severity , ToolName : toolName })
179+ alerts , resp , err := client .CodeScanning .ListAlertsForRepo (ctx , owner , repo , & github.AlertListOptions {
180+ Ref : ref ,
181+ State : state ,
182+ Severity : severity ,
183+ ToolName : toolName ,
184+ ListOptions : github.ListOptions {
185+ Page : pagination .Page ,
186+ PerPage : pagination .PerPage ,
187+ },
188+ })
172189 if err != nil {
173190 return ghErrors .NewGitHubAPIErrorResponse (ctx ,
174191 "failed to list alerts" ,
0 commit comments