Skip to content

Commit ff0e67e

Browse files
Add formatScopeDisplay helper and improve empty scope handling
Co-authored-by: SamMorrowDrums <[email protected]>
1 parent 33014a6 commit ff0e67e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

cmd/github-mcp-server/list_scopes.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ func init() {
7575
rootCmd.AddCommand(listScopesCmd)
7676
}
7777

78+
// formatScopeDisplay formats a scope string for display, handling empty scopes.
79+
func formatScopeDisplay(scope string) string {
80+
if scope == "" {
81+
return "(no scope required for public read access)"
82+
}
83+
return scope
84+
}
85+
7886
func runListScopes() error {
7987
// Get toolsets configuration (same logic as stdio command)
8088
var enabledToolsets []string
@@ -217,11 +225,7 @@ func outputSummary(output ScopesOutput) error {
217225
fmt.Println("Required OAuth scopes for enabled tools:")
218226
fmt.Println()
219227
for _, scope := range output.UniqueScopes {
220-
if scope == "" {
221-
fmt.Println(" (no scope required for public read access)")
222-
} else {
223-
fmt.Printf(" %s\n", scope)
224-
}
228+
fmt.Printf(" %s\n", formatScopeDisplay(scope))
225229
}
226230
fmt.Printf("\nTotal: %d unique scope(s)\n", len(output.UniqueScopes))
227231
return nil
@@ -275,11 +279,7 @@ func outputText(output ScopesOutput) error {
275279
} else {
276280
fmt.Println("Unique scopes required:")
277281
for _, scope := range output.UniqueScopes {
278-
if scope == "" {
279-
fmt.Println(" • (no scope - public read access)")
280-
} else {
281-
fmt.Printf(" • %s\n", scope)
282-
}
282+
fmt.Printf(" • %s\n", formatScopeDisplay(scope))
283283
}
284284
}
285285
fmt.Printf("\nTotal: %d tools, %d unique scopes\n", len(output.Tools), len(output.UniqueScopes))

0 commit comments

Comments
 (0)