Summary
Passing only --tools (without --toolsets) on the command line causes the server to exit immediately with:
Cannot use both --tools and --toolsets flags together
Repro
$ go build -o ./terraform-mcp-server ./cmd/terraform-mcp-server/
$ ./terraform-mcp-server --tools=search_providers,get_provider_details
time="..." level=fatal msg="Cannot use both --tools and --toolsets flags together"
$ echo $?
1
The same Fatal fires whether the transport is stdio, the streamable-http subcommand, or the env-var-driven HTTP path (TRANSPORT_MODE=streamable-http ./terraform-mcp-server --tools=...).
Root cause
getToolsetsFromCmd in cmd/terraform-mcp-server/main.go reads the --toolsets value with GetString and rejects anything that is non-empty and not "default":
toolsetsFlag, _ := cmd.Flags().GetString("toolsets")
if toolsetsFlag == "" {
toolsetsFlag, _ = cmd.Root().PersistentFlags().GetString("toolsets")
}
if toolsetsFlag != "" && toolsetsFlag != "default" {
logger.Fatal("Cannot use both --tools and --toolsets flags together")
}
The --toolsets persistent flag is declared with default "all" in init.go. GetString returns the default when the user has not passed the flag, so the check fires whenever the operator passes only --tools.
Workaround: pass --toolsets="" explicitly along with --tools=....
Suggested fix
Use pflag.Flag.Changed, which is true only when the operator set the flag on the command line. That maps 1:1 to the intent of the check ("did the user pass --toolsets?") without coupling to the declared default.
I have a fix prepared in #380.
Summary
Passing only
--tools(without--toolsets) on the command line causes the server to exit immediately with:Repro
The same Fatal fires whether the transport is
stdio, thestreamable-httpsubcommand, or the env-var-driven HTTP path (TRANSPORT_MODE=streamable-http ./terraform-mcp-server --tools=...).Root cause
getToolsetsFromCmdincmd/terraform-mcp-server/main.goreads the--toolsetsvalue withGetStringand rejects anything that is non-empty and not"default":The
--toolsetspersistent flag is declared with default"all"ininit.go.GetStringreturns the default when the user has not passed the flag, so the check fires whenever the operator passes only--tools.Workaround: pass
--toolsets=""explicitly along with--tools=....Suggested fix
Use
pflag.Flag.Changed, which istrueonly when the operator set the flag on the command line. That maps 1:1 to the intent of the check ("did the user pass--toolsets?") without coupling to the declared default.I have a fix prepared in #380.