@@ -38,6 +38,8 @@ type MCPServerConfig struct {
3838 // See: https://github.com/github/github-mcp-server?tab=readme-ov-file#tool-configuration
3939 EnabledToolsets []string
4040
41+ EnabledTools []string
42+
4143 // Whether to enable dynamic toolsets
4244 // See: https://github.com/github/github-mcp-server?tab=readme-ov-file#dynamic-tool-discovery
4345 DynamicToolsets bool
@@ -141,11 +143,61 @@ func NewMCPServer(cfg MCPServerConfig) (*server.MCPServer, error) {
141143 }
142144
143145 // Create default toolsets
144- tsg := github .DefaultToolsetGroup (cfg .ReadOnly , getClient , getGQLClient , getRawClient , cfg .Translator , cfg .ContentWindowSize )
145- err = tsg .EnableToolsets (enabledToolsets )
146-
147- if err != nil {
148- return nil , fmt .Errorf ("failed to enable toolsets: %w" , err )
146+ tsg := github .DefaultToolsetGroup (cfg .ReadOnly , getClient , getGQLClient , getRawClient , cfg .Translator , cfg .ContentWindowSize )
147+
148+ // When tools are specified, we enable only those tools
149+ if len (cfg .EnabledTools ) > 0 {
150+ fmt .Fprintf (os .Stderr , "DEBUG: Specific tools mode activated with tools: %v\n " , cfg .EnabledTools )
151+
152+ // Build a map of tool name -> toolset name
153+ toolToToolsetMap := make (map [string ]string )
154+ for toolsetName , toolset := range tsg .Toolsets {
155+ for _ , tool := range toolset .GetAvailableTools () {
156+ toolToToolsetMap [tool .Tool .Name ] = toolsetName
157+ }
158+ }
159+
160+ fmt .Fprintf (os .Stderr , "DEBUG: Built tool map with %d tools\n " , len (toolToToolsetMap ))
161+
162+ // Determine which toolsets need to be enabled based on requested tools
163+ toolsetToToolsMap := make (map [string ][]string )
164+ for _ , toolName := range cfg .EnabledTools {
165+ if toolsetName , ok := toolToToolsetMap [toolName ]; ok {
166+ toolsetToToolsMap [toolsetName ] = append (toolsetToToolsMap [toolsetName ], toolName )
167+ fmt .Fprintf (os .Stderr , "DEBUG: Tool '%s' belongs to toolset '%s'\n " , toolName , toolsetName )
168+ } else {
169+ fmt .Fprintf (os .Stderr , "DEBUG: WARNING - Tool '%s' not found in any toolset!\n " , toolName )
170+ }
171+ }
172+
173+ // Enable the required toolsets
174+ requiredToolsets := make ([]string , 0 , len (toolsetToToolsMap ))
175+ for toolsetName := range toolsetToToolsMap {
176+ requiredToolsets = append (requiredToolsets , toolsetName )
177+ }
178+
179+ fmt .Fprintf (os .Stderr , "DEBUG: Enabling %d toolsets: %v\n " , len (requiredToolsets ), requiredToolsets )
180+
181+ err = tsg .EnableToolsets (requiredToolsets )
182+ if err != nil {
183+ return nil , fmt .Errorf ("failed to enable toolsets: %w" , err )
184+ }
185+
186+ // Enable only specific tools in each toolset
187+ for toolsetName , toolNames := range toolsetToToolsMap {
188+ toolset , err := tsg .GetToolset (toolsetName )
189+ if err != nil {
190+ return nil , fmt .Errorf ("failed to get toolset %s: %w" , toolsetName , err )
191+ }
192+ fmt .Fprintf (os .Stderr , "DEBUG: Enabling specific tools %v for toolset '%s'\n " , toolNames , toolsetName )
193+ toolset .EnableSpecificTools (toolNames )
194+ }
195+ } else {
196+ // Normal toolset mode - enable requested toolsets (or all by default)
197+ err = tsg .EnableToolsets (enabledToolsets )
198+ if err != nil {
199+ return nil , fmt .Errorf ("failed to enable toolsets: %w" , err )
200+ }
149201 }
150202
151203 // Register all mcp functionality with the server
@@ -173,6 +225,8 @@ type StdioServerConfig struct {
173225 // See: https://github.com/github/github-mcp-server?tab=readme-ov-file#tool-configuration
174226 EnabledToolsets []string
175227
228+ EnabledTools []string
229+
176230 // Whether to enable dynamic toolsets
177231 // See: https://github.com/github/github-mcp-server?tab=readme-ov-file#dynamic-tool-discovery
178232 DynamicToolsets bool
@@ -207,6 +261,7 @@ func RunStdioServer(cfg StdioServerConfig) error {
207261 Host : cfg .Host ,
208262 Token : cfg .Token ,
209263 EnabledToolsets : cfg .EnabledToolsets ,
264+ EnabledTools : cfg .EnabledTools ,
210265 DynamicToolsets : cfg .DynamicToolsets ,
211266 ReadOnly : cfg .ReadOnly ,
212267 Translator : t ,
0 commit comments