googleapis/mcp-toolbox · error

invalid '%s' parameter; expected a boolean

Error message

invalid '%s' parameter; expected a boolean

What it means

The `fuzzymatching` DICOM search option must be a JSON boolean. ParseDICOMSearchParameters asserts v.(bool) and returns this error when the value is a string like "true" or any other non-boolean type.

Source

Thrown at internal/tools/cloudhealthcare/common/util.go:78

// search methods.
func ParseDICOMSearchParameters(params parameters.ParamValues, paramKeys []string) ([]googleapi.CallOption, error) {
	var opts []googleapi.CallOption
	for k, v := range params.AsMap() {
		if k == IncludeAttributesKey {
			if _, ok := v.([]any); !ok {
				return nil, fmt.Errorf("invalid '%s' parameter; expected a string array", k)
			}
			attributeIDsSlice, err := parameters.ConvertAnySliceToTyped(v.([]any), "string")
			if err != nil {
				return nil, fmt.Errorf("can't convert '%s' to array of strings: %s", k, err)
			}
			attributeIDs := attributeIDsSlice.([]string)
			if len(attributeIDs) != 0 {
				opts = append(opts, googleapi.QueryParameter(k, strings.Join(attributeIDs, ",")))
			}
		} else if k == EnablePatientNameFuzzyMatchingKey {
			if _, ok := v.(bool); !ok {
				return nil, fmt.Errorf("invalid '%s' parameter; expected a boolean", k)
			}
			opts = append(opts, googleapi.QueryParameter(k, fmt.Sprintf("%t", v.(bool))))
		} else if slices.Contains(paramKeys, k) {
			if _, ok := v.(string); !ok {
				return nil, fmt.Errorf("invalid '%s' parameter; expected a string", k)
			}
			if v.(string) != "" {
				opts = append(opts, googleapi.QueryParameter(k, v.(string)))
			}
		}
	}
	return opts, nil
}

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Send `fuzzymatching` as a JSON boolean: true or false (unquoted).
  2. Remove surrounding quotes from the value in the request payload.
  3. Coerce "true"/"false" strings to booleans client-side before invoking.
  4. Validate the payload against the tool's parameter schema.

Example fix

// before
{"fuzzymatching": "true"}
// after
{"fuzzymatching": true}
Defensive patterns

Strategy: type-guard

Validate before calling

function toBool(v) {
  if (typeof v === 'boolean') return v;
  if (v === 'true') return true;
  if (v === 'false') return false;
  throw new Error('fuzzymatching must be a boolean');
}

Type guard

function isBool(v) { return typeof v === 'boolean'; }

Prevention

When it happens

Trigger: Invoking a DICOM search tool with `fuzzymatching` set to "true"/"false" as a string, or as 1/0, instead of a real boolean.

Common situations: Form-encoded or template-substituted inputs turning booleans into strings; LLM quoting the boolean in JSON; clients built from older schemas that used strings.

Related errors


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