googleapis/mcp-toolbox · error

log level must be one of "debug", "info", "warn", or "error"

Error message

log level must be one of "debug", "info", "warn", or "error"

What it means

StringLevel is the pflag type for the --log-level flag; its Set method accepts only debug, info, warn, or error (case-insensitive). Any other value returns this error and prevents startup. It is a strict CLI argument validation.

Source

Thrown at internal/server/config.go:153

type StringLevel string

// String is used by both fmt.Print and by Cobra in help text
func (s *StringLevel) String() string {
	if string(*s) != "" {
		return strings.ToLower(string(*s))
	}
	return "info"
}

// validate log level flag
func (s *StringLevel) Set(v string) error {
	switch strings.ToLower(v) {
	case "debug", "info", "warn", "error":
		*s = StringLevel(v)
		return nil
	default:
		return fmt.Errorf(`log level must be one of "debug", "info", "warn", or "error"`)
	}
}

// Type is used in Cobra help text
func (s *StringLevel) Type() string {
	return "stringLevel"
}

type SourceConfigs map[string]sources.SourceConfig
type AuthServiceConfigs map[string]auth.AuthServiceConfig
type EmbeddingModelConfigs map[string]embeddingmodels.EmbeddingModelConfig
type ToolConfigs map[string]tools.ToolConfig
type PromptConfigs map[string]prompts.PromptConfig
type GroupConfigs map[string]group.GroupConfig

func UnmarshalPrimitiveConfig(ctx context.Context, raw []byte) (SourceConfigs, AuthServiceConfigs, EmbeddingModelConfigs, ToolConfigs, PromptConfigs, GroupConfigs, error) {
	// prepare configs map
	var sourceConfigs SourceConfigs

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Use one of: --log-level=debug, info, warn, or error
  2. Replace "warning" with "warn" or "fatal" with "error"
  3. Omit the flag to use the default level

Example fix

// before
toolbox --log-level warning
// after
toolbox --log-level warn
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = ['debug', 'info', 'warn', 'error'];
if (!ALLOWED.includes(logLevel.toLowerCase())) {
  throw new Error(`log level must be one of ${ALLOWED}`);
}

Prevention

When it happens

Trigger: Running the toolbox with --log-level set to values like "trace", "verbose", "fatal", "warning", or "0".

Common situations: Migrating from other loggers that use "warning"/"fatal" levels, scripting with numeric levels, typos such as "infO " with whitespace.

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/47d4fa896d6b2903. Report an issue: GitHub.