googleapis/mcp-toolbox · error

log format must be one of "standard", or "json"

Error message

log format must be one of "standard", or "json"

What it means

This error comes from the logFormat flag type's Set method, used by Cobra/pflag when parsing the --log-format CLI flag. Only "standard" or "json" (case-insensitive) are accepted; anything else returns this validation error and the server fails to start.

Source

Thrown at internal/server/config.go:127

type logFormat string

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

// validate logging format flag
func (f *logFormat) Set(v string) error {
	switch strings.ToLower(v) {
	case "standard", "json":
		*f = logFormat(v)
		return nil
	default:
		return fmt.Errorf(`log format must be one of "standard", or "json"`)
	}
}

// Type is used in Cobra help text
func (f *logFormat) Type() string {
	return "logFormat"
}

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"
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Use --log-format=standard or --log-format=json
  2. Remove the flag entirely to use the default
  3. Check --help for the accepted logFormat values

Example fix

// before
toolbox --log-format text
// after
toolbox --log-format json
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = ['standard', 'json'];
if (!ALLOWED.includes(logFormat.toLowerCase())) {
  throw new Error(`log format must be one of ${ALLOWED}`);
}

Prevention

When it happens

Trigger: Starting the toolbox binary with --log-format set to an unsupported value such as "text", "pretty", "", or a typo like "jsn".

Common situations: Copying flags from other Go services that accept "text", CI scripts with wrong flag values, autocomplete mistakes.

Related errors


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