googleapis/mcp-toolbox · error
invalid '%s' parameter; expected a string
Error message
invalid '%s' parameter; expected a string
What it means
Every other recognized DICOM search parameter (keys listed in paramKeys, e.g. patient name, date ranges) must be a string. If a value arrives as a number, bool, array or object, the assertion fails and this error is returned.
Source
Thrown at internal/tools/cloudhealthcare/common/util.go:83
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
- Quote the value so it is a JSON string, e.g. "19991231-20201231".
- Convert numbers to their DICOM string representation before sending.
- Check the tool's parameter schema for which keys expect strings.
- Validate payload types before invoking.
Example fix
// before
{"studydate": 20201231}
// after
{"studydate": "20201231"} Defensive patterns
Strategy: validation
Validate before calling
function assertStringParams(obj, keys) {
for (const k of keys) {
if (k in obj && typeof obj[k] !== 'string') {
throw new Error(`parameter ${k} must be a string`);
}
}
}
// e.g. assertStringParams(params, ['patientid','studydate','modality']) Type guard
function isString(v) { return typeof v === 'string'; } Prevention
- Format dates as DICOM strings (YYYYMMDD) before sending
- Never rely on JSON numbers for string-typed search params
- Validate payloads against the tool's declared parameter schema
- Wrap LLM tool-call arguments in a type-checking adapter
When it happens
Trigger: Invoking a DICOM search tool with a search parameter (one of paramKeys) whose value is not a string, e.g. {"limit": 10} on a string-typed key or a numeric patient ID.
Common situations: LLM sending unquoted numbers or dates as JSON numbers; clients serializing dates as timestamps instead of DICOM date strings (e.g. "19991231"); mixed payloads from dynamic UIs.
Related errors
- invalid '%s' parameter; expected a string array
- can't convert '%s' to array of strings: %s
- invalid '%s' parameter; expected a boolean
- invalid source for %q tool: source %q is not a compatible ty
- source is not compatible with the tool
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/dcb6191f3e7148c5.
Report an issue: GitHub.