googleapis/mcp-toolbox · error
%g is not an allowed value
Error message
%g is not an allowed value
What it means
FloatParameter.Parse rejects a float because it is not present in the parameter's allowedValues list. Tool authors can constrain numeric (double) parameters to a fixed set of acceptable values; any other number is rejected during parsing. The value parsed fine as a float — it just is not whitelisted.
Source
Thrown at internal/util/parameters/parameters.go:926
func (p *FloatParameter) Parse(v any) (any, error) {
var out float64
switch newV := v.(type) {
default:
return nil, &ParseTypeError{p.Name, p.Type, v}
case float32:
out = float64(newV)
case float64:
out = newV
case json.Number:
newI, err := newV.Float64()
if err != nil {
return nil, &ParseTypeError{p.Name, p.Type, v}
}
out = float64(newI)
}
if !p.IsAllowedValues(out) {
return nil, fmt.Errorf("%g is not an allowed value", out)
}
if p.IsExcludedValues(out) {
return nil, fmt.Errorf("%g is an excluded value", out)
}
if p.MinValue != nil && out < *p.MinValue {
return nil, fmt.Errorf("%g is under the minimum value", out)
}
if p.MaxValue != nil && out > *p.MaxValue {
return nil, fmt.Errorf("%g is above the maximum value", out)
}
return out, nil
}
func (p *FloatParameter) GetAuthServices() []ParamAuthService {
return p.AuthServices
}
func (p *FloatParameter) GetDefault() any {View on GitHub (pinned to 8cc6e09de2)
Solutions
- Send one of the exact allowedValues listed in the tool's parameter schema/manifest
- If the caller is an LLM, enumerate the valid values explicitly in the parameter description
- If more values are needed, extend allowedValues in tools.yaml (or WithFloatAllowedValues) and redeploy
- Beware floating-point formatting: send values that compare equal to listed ones (e.g. 1.0 not 0.9999)
Example fix
// before
params := map[string]any{"threshold": 0.7} // allowedValues are [0.5, 1.0]
// after
params := map[string]any{"threshold": 1.0} Defensive patterns
Strategy: validation
Validate before calling
allowed := []float64{0.5, 1.0, 2.5}
func validateAllowedFloat(v float64, allowed []float64) error {
for _, a := range allowed {
if v == a { return nil }
}
return fmt.Errorf("%g is not in allowedValues %v", v, allowed)
} Type guard
func isAllowedFloat(v float64, allowed []float64) bool {
for _, a := range allowed { if v == a { return true } }
return false
} Try / catch
out, err := tool.Parse(params)
if err != nil && strings.Contains(err.Error(), "is not an allowed value") {
// pick the nearest allowed value from the manifest and retry
} Prevention
- Read allowedValues from the tool manifest and send exact matches
- Beware float formatting: send 1.0 not 0.9999 for a listed 1.0
- Enumerate valid decimals in the parameter description for LLMs
- Extend allowedValues in config when new legitimate values are needed
When it happens
Trigger: Calling a tool with a float argument not listed in the FloatParameter's allowedValues (yaml 'allowedValues:' or WithFloatAllowedValues). Example: allowedValues [0.5, 1.0, 2.5] but the request passes 0.7.
Common situations: LLMs inventing arbitrary decimal values for thresholds/ratios/temperature-like settings; clients sending computed floats that miss the whitelist; configs where allowedValues uses ints (1) while the caller sends floats (1.0 formatted differently upstream).
Related errors
- %g is an excluded value
- unable to process parameters: %w
- %d is not an allowed value
- %d is an excluded value
- %d is under the minimum value
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/635884755949796f.
Report an issue: GitHub.