@@ -228,7 +228,7 @@ func fragmentToIssue(fragment IssueFragment) *github.Issue {
228228}
229229
230230// GetIssue creates a tool to get details of a specific issue in a GitHub repository.
231- func IssueRead (getClient GetClientFn , getGQLClient GetGQLClientFn , t translations.TranslationHelperFunc , flags FeatureFlags ) (tool mcp.Tool , handler server.ToolHandlerFunc ) {
231+ func IssueRead (getClient GetClientFn , getGQLClient GetGQLClientFn , cache * lockdown. RepoAccessCache , t translations.TranslationHelperFunc , flags FeatureFlags ) (tool mcp.Tool , handler server.ToolHandlerFunc ) {
232232 return mcp .NewTool ("issue_read" ,
233233 mcp .WithDescription (t ("TOOL_ISSUE_READ_DESCRIPTION" , "Get information about a specific issue in a GitHub repository." )),
234234 mcp .WithToolAnnotation (mcp.ToolAnnotation {
@@ -297,11 +297,11 @@ Options are:
297297
298298 switch method {
299299 case "get" :
300- return GetIssue (ctx , client , gqlClient , owner , repo , issueNumber , flags )
300+ return GetIssue (ctx , client , cache , owner , repo , issueNumber , flags )
301301 case "get_comments" :
302- return GetIssueComments (ctx , client , gqlClient , owner , repo , issueNumber , pagination , flags )
302+ return GetIssueComments (ctx , client , cache , owner , repo , issueNumber , pagination , flags )
303303 case "get_sub_issues" :
304- return GetSubIssues (ctx , client , gqlClient , owner , repo , issueNumber , pagination , flags )
304+ return GetSubIssues (ctx , client , cache , owner , repo , issueNumber , pagination , flags )
305305 case "get_labels" :
306306 return GetIssueLabels (ctx , gqlClient , owner , repo , issueNumber )
307307 default :
@@ -310,7 +310,7 @@ Options are:
310310 }
311311}
312312
313- func GetIssue (ctx context.Context , client * github.Client , gqlClient * githubv4. Client , owner string , repo string , issueNumber int , flags FeatureFlags ) (* mcp.CallToolResult , error ) {
313+ func GetIssue (ctx context.Context , client * github.Client , cache * lockdown. RepoAccessCache , owner string , repo string , issueNumber int , flags FeatureFlags ) (* mcp.CallToolResult , error ) {
314314 issue , resp , err := client .Issues .Get (ctx , owner , repo , issueNumber )
315315 if err != nil {
316316 return nil , fmt .Errorf ("failed to get issue: %w" , err )
@@ -326,8 +326,12 @@ func GetIssue(ctx context.Context, client *github.Client, gqlClient *githubv4.Cl
326326 }
327327
328328 if flags .LockdownMode {
329- if issue .User != nil {
330- isPrivate , hasPushAccess , err := lockdown .GetRepoAccessInfo (ctx , gqlClient , * issue .User .Login , owner , repo )
329+ if cache == nil {
330+ return nil , fmt .Errorf ("lockdown cache is not configured" )
331+ }
332+ login := issue .GetUser ().GetLogin ()
333+ if login != "" {
334+ isPrivate , hasPushAccess , err := cache .GetRepoAccessInfo (ctx , login , owner , repo )
331335 if err != nil {
332336 return mcp .NewToolResultError (fmt .Sprintf ("failed to check lockdown mode: %v" , err )), nil
333337 }
@@ -355,7 +359,7 @@ func GetIssue(ctx context.Context, client *github.Client, gqlClient *githubv4.Cl
355359 return mcp .NewToolResultText (string (r )), nil
356360}
357361
358- func GetIssueComments (ctx context.Context , client * github.Client , gqlClient * githubv4. Client , owner string , repo string , issueNumber int , pagination PaginationParams , flags FeatureFlags ) (* mcp.CallToolResult , error ) {
362+ func GetIssueComments (ctx context.Context , client * github.Client , cache * lockdown. RepoAccessCache , owner string , repo string , issueNumber int , pagination PaginationParams , flags FeatureFlags ) (* mcp.CallToolResult , error ) {
359363 opts := & github.IssueListCommentsOptions {
360364 ListOptions : github.ListOptions {
361365 Page : pagination .Page ,
@@ -377,9 +381,20 @@ func GetIssueComments(ctx context.Context, client *github.Client, gqlClient *git
377381 return mcp .NewToolResultError (fmt .Sprintf ("failed to get issue comments: %s" , string (body ))), nil
378382 }
379383 if flags .LockdownMode {
380- filteredComments := []* github.IssueComment {}
384+ if cache == nil {
385+ return nil , fmt .Errorf ("lockdown cache is not configured" )
386+ }
387+ filteredComments := make ([]* github.IssueComment , 0 , len (comments ))
381388 for _ , comment := range comments {
382- isPrivate , hasPushAccess , err := lockdown .GetRepoAccessInfo (ctx , gqlClient , * comment .User .Login , owner , repo )
389+ user := comment .User
390+ if user == nil {
391+ continue
392+ }
393+ login := user .GetLogin ()
394+ if login == "" {
395+ continue
396+ }
397+ isPrivate , hasPushAccess , err := cache .GetRepoAccessInfo (ctx , login , owner , repo )
383398 if err != nil {
384399 return mcp .NewToolResultError (fmt .Sprintf ("failed to check lockdown mode: %v" , err )), nil
385400 }
@@ -402,7 +417,7 @@ func GetIssueComments(ctx context.Context, client *github.Client, gqlClient *git
402417 return mcp .NewToolResultText (string (r )), nil
403418}
404419
405- func GetSubIssues (ctx context.Context , client * github.Client , gqlClient * githubv4. Client , owner string , repo string , issueNumber int , pagination PaginationParams , featureFlags FeatureFlags ) (* mcp.CallToolResult , error ) {
420+ func GetSubIssues (ctx context.Context , client * github.Client , cache * lockdown. RepoAccessCache , owner string , repo string , issueNumber int , pagination PaginationParams , featureFlags FeatureFlags ) (* mcp.CallToolResult , error ) {
406421 opts := & github.IssueListOptions {
407422 ListOptions : github.ListOptions {
408423 Page : pagination .Page ,
@@ -430,9 +445,20 @@ func GetSubIssues(ctx context.Context, client *github.Client, gqlClient *githubv
430445 }
431446
432447 if featureFlags .LockdownMode {
433- filteredSubIssues := []* github.SubIssue {}
448+ if cache == nil {
449+ return nil , fmt .Errorf ("lockdown cache is not configured" )
450+ }
451+ filteredSubIssues := make ([]* github.SubIssue , 0 , len (subIssues ))
434452 for _ , subIssue := range subIssues {
435- isPrivate , hasPushAccess , err := lockdown .GetRepoAccessInfo (ctx , gqlClient , * subIssue .User .Login , owner , repo )
453+ user := subIssue .User
454+ if user == nil {
455+ continue
456+ }
457+ login := user .GetLogin ()
458+ if login == "" {
459+ continue
460+ }
461+ isPrivate , hasPushAccess , err := cache .GetRepoAccessInfo (ctx , login , owner , repo )
436462 if err != nil {
437463 return mcp .NewToolResultError (fmt .Sprintf ("failed to check lockdown mode: %v" , err )), nil
438464 }
0 commit comments