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

Function runListScopes

cmd/github-mcp-server/list_scopes.go:86–141  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

84}
85
86func runListScopes() error {
87 // Get toolsets configuration (same logic as stdio command)
88 var enabledToolsets []string
89 if viper.IsSet("toolsets") {
90 if err := viper.UnmarshalKey("toolsets", &enabledToolsets); err != nil {
91 return fmt.Errorf("failed to unmarshal toolsets: %w", err)
92 }
93 }
94 // else: enabledToolsets stays nil, meaning "use defaults"
95
96 // Get specific tools (similar to toolsets)
97 var enabledTools []string
98 if viper.IsSet("tools") {
99 if err := viper.UnmarshalKey("tools", &enabledTools); err != nil {
100 return fmt.Errorf("failed to unmarshal tools: %w", err)
101 }
102 }
103
104 readOnly := viper.GetBool("read-only")
105 outputFormat := viper.GetString("list-scopes-output")
106
107 // Create translation helper
108 t, _ := translations.TranslationHelper()
109
110 // Build inventory using the same logic as the stdio server
111 inventoryBuilder := github.NewInventory(t).
112 WithReadOnly(readOnly)
113
114 // Configure toolsets (same as stdio)
115 if enabledToolsets != nil {
116 inventoryBuilder = inventoryBuilder.WithToolsets(enabledToolsets)
117 }
118
119 // Configure specific tools
120 if len(enabledTools) > 0 {
121 inventoryBuilder = inventoryBuilder.WithTools(enabledTools)
122 }
123
124 inv, err := inventoryBuilder.Build()
125 if err != nil {
126 return fmt.Errorf("failed to build inventory: %w", err)
127 }
128
129 // Collect all tools and their scopes
130 output := collectToolScopes(inv, readOnly)
131
132 // Output based on format
133 switch outputFormat {
134 case "json":
135 return outputJSON(output)
136 case "summary":
137 return outputSummary(output)
138 default:
139 return outputText(output)
140 }
141}
142
143func collectToolScopes(inv *inventory.Inventory, readOnly bool) ScopesOutput {

Callers 1

list_scopes.goFile · 0.85

Calls 10

TranslationHelperFunction · 0.92
NewInventoryFunction · 0.92
collectToolScopesFunction · 0.85
outputJSONFunction · 0.85
outputSummaryFunction · 0.85
outputTextFunction · 0.85
WithReadOnlyMethod · 0.80
WithToolsetsMethod · 0.80
WithToolsMethod · 0.80
BuildMethod · 0.80

Tested by

no test coverage detected