Skip to content

Commit 7fbcae2

Browse files
fix: restore correct behavior for --tools and --toolsets flags
Two behavioral regressions were fixed in resolveEnabledToolsets(): 1. When --tools=X is used without --toolsets, the server should only register the specified tools, not the default toolsets. Now returns an empty slice instead of nil when EnabledTools is set. 2. When --toolsets=all --dynamic-toolsets is used, the 'all' and 'default' pseudo-toolsets should be removed so only the dynamic management tools are registered. This matches the original pre-refactor behavior.
1 parent cd55f6f commit 7fbcae2

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

internal/ghmcp/server.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,26 @@ func createGitHubClients(cfg MCPServerConfig, apiHost apiHost) (*githubClients,
123123
// resolveEnabledToolsets determines which toolsets should be enabled based on config.
124124
// Returns nil for "use defaults", empty slice for "none", or explicit list.
125125
func resolveEnabledToolsets(cfg MCPServerConfig) []string {
126-
if cfg.EnabledToolsets != nil {
127-
return cfg.EnabledToolsets
126+
enabledToolsets := cfg.EnabledToolsets
127+
128+
// In dynamic mode, remove "all" and "default" since users enable toolsets on demand
129+
if cfg.DynamicToolsets && enabledToolsets != nil {
130+
enabledToolsets = github.RemoveToolset(enabledToolsets, string(github.ToolsetMetadataAll.ID))
131+
enabledToolsets = github.RemoveToolset(enabledToolsets, string(github.ToolsetMetadataDefault.ID))
132+
}
133+
134+
if enabledToolsets != nil {
135+
return enabledToolsets
128136
}
129137
if cfg.DynamicToolsets {
130138
// Dynamic mode with no toolsets specified: start empty so users enable on demand
131139
return []string{}
132140
}
141+
if len(cfg.EnabledTools) > 0 {
142+
// When specific tools are requested but no toolsets, don't use default toolsets
143+
// This matches the original behavior: --tools=X alone registers only X
144+
return []string{}
145+
}
133146
// nil means "use defaults" in WithToolsets
134147
return nil
135148
}

0 commit comments

Comments
 (0)