@@ -39,6 +39,10 @@ type MCPServerConfig struct {
3939 // See: https://github.com/github/github-mcp-server?tab=readme-ov-file#tool-configuration
4040 EnabledToolsets []string
4141
42+ // EnabledTools is a list of specific tools to enable (takes priority over toolsets)
43+ // When specified, only these tools will be registered, bypassing toolset enablement
44+ EnabledTools []string
45+
4246 // Whether to enable dynamic toolsets
4347 // See: https://github.com/github/github-mcp-server?tab=readme-ov-file#dynamic-tool-discovery
4448 DynamicToolsets bool
@@ -155,18 +159,42 @@ func NewMCPServer(cfg MCPServerConfig) (*server.MCPServer, error) {
155159
156160 // Create default toolsets
157161 tsg := github .DefaultToolsetGroup (cfg .ReadOnly , getClient , getGQLClient , getRawClient , cfg .Translator , cfg .ContentWindowSize )
158- err = tsg .EnableToolsets (enabledToolsets , nil )
159162
160- if err != nil {
161- return nil , fmt .Errorf ("failed to enable toolsets: %w" , err )
162- }
163+ // PRIORITY: If specific tools are configured, use tool-level registration
164+ if len (cfg .EnabledTools ) > 0 {
165+ // Clean and validate tool names
166+ enabledTools , invalidTools := github .CleanTools (cfg .EnabledTools )
167+
168+ if len (invalidTools ) > 0 {
169+ fmt .Fprintf (os .Stderr , "Invalid tools ignored: %s\n " , strings .Join (invalidTools , ", " ))
170+ }
163171
164- // Register all mcp functionality with the server
165- tsg .RegisterAll (ghServer )
172+ // Register only the specified tools (bypasses toolset enablement)
173+ err = tsg .RegisterSpecificTools (ghServer , enabledTools , cfg .ReadOnly )
174+ if err != nil {
175+ return nil , fmt .Errorf ("failed to register tools: %w" , err )
176+ }
166177
167- if cfg .DynamicToolsets {
168- dynamic := github .InitDynamicToolset (ghServer , tsg , cfg .Translator )
169- dynamic .RegisterTools (ghServer )
178+ // Still register resources and prompts from all toolsets to maintain functionality
179+ for _ , toolset := range tsg .Toolsets {
180+ toolset .RegisterResourcesTemplates (ghServer )
181+ toolset .RegisterPrompts (ghServer )
182+ }
183+ } else {
184+ // EXISTING FLOW: Use toolset-based registration
185+ err = tsg .EnableToolsets (enabledToolsets , nil )
186+ if err != nil {
187+ return nil , fmt .Errorf ("failed to enable toolsets: %w" , err )
188+ }
189+
190+ // Register all mcp functionality with the server
191+ tsg .RegisterAll (ghServer )
192+
193+ // Dynamic toolsets only work if no specific tools configured
194+ if cfg .DynamicToolsets {
195+ dynamic := github .InitDynamicToolset (ghServer , tsg , cfg .Translator )
196+ dynamic .RegisterTools (ghServer )
197+ }
170198 }
171199
172200 return ghServer , nil
@@ -186,6 +214,10 @@ type StdioServerConfig struct {
186214 // See: https://github.com/github/github-mcp-server?tab=readme-ov-file#tool-configuration
187215 EnabledToolsets []string
188216
217+ // EnabledTools is a list of specific tools to enable (takes priority over toolsets)
218+ // When specified, only these tools will be registered, bypassing toolset enablement
219+ EnabledTools []string
220+
189221 // Whether to enable dynamic toolsets
190222 // See: https://github.com/github/github-mcp-server?tab=readme-ov-file#dynamic-tool-discovery
191223 DynamicToolsets bool
@@ -220,6 +252,7 @@ func RunStdioServer(cfg StdioServerConfig) error {
220252 Host : cfg .Host ,
221253 Token : cfg .Token ,
222254 EnabledToolsets : cfg .EnabledToolsets ,
255+ EnabledTools : cfg .EnabledTools ,
223256 DynamicToolsets : cfg .DynamicToolsets ,
224257 ReadOnly : cfg .ReadOnly ,
225258 Translator : t ,
0 commit comments