googleapis/mcp-toolbox · error

%g is above the maximum value

Error message

%g is above the maximum value

What it means

FloatParameter.Parse rejects a float because it exceeds the parameter's configured maxValue. The value parsed as a valid float but is above the upper bound tool authors set (e.g. probabilities must be <= 1). This is expected range validation by the toolbox.

Source

Thrown at internal/util/parameters/parameters.go:935

		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 {
	if p.Default == nil {
		return nil
	}
	return *p.Default
}

// Manifest returns the manifest for the FloatParameter.
func (p *FloatParameter) Manifest() ParameterManifest {
	// only list ParamAuthService names (without fields) in manifest

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Resend with a float <= the configured maxValue (check the tool's parameter manifest/description)
  2. Convert units if needed (percent -> fraction) and clamp client-side, e.g. math.Min(maxValue, value)
  3. If a higher ceiling is valid, raise maxValue in tools.yaml (or WithFloatMaxValue) and redeploy

Example fix

// before
params := map[string]any{"probability": 85} // percent, maxValue is 1.0
// after
params := map[string]any{"probability": 0.85}
Defensive patterns

Strategy: validation

Validate before calling

func validateMaxFloat(v, maxValue float64) error {
    if v > maxValue {
        return fmt.Errorf("%g exceeds maximum %g", v, maxValue)
    }
    return nil
}
// usage: validateMaxFloat(probability, 1.0)

Type guard

func withinMaxFloat(v, maxValue float64) bool { return v <= maxValue }

Try / catch

out, err := tool.Parse(params)
if err != nil && strings.Contains(err.Error(), "is above the maximum value") {
    // clamp: params[key] = maxValue from manifest and retry once
}

Prevention

When it happens

Trigger: Invoking a tool with a float greater than maxValue configured via yaml 'maxValue:' or WithFloatMaxValue. Example: maxValue 1.0 and the request passes 1.5.

Common situations: Sending percentages (85) where fractions (0.85) are expected; LLMs overshooting bounds; computed values like ratios exceeding 1; clients built before maxValue was added to the tool config.

Related errors


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