googleapis/mcp-toolbox · error
templateParameter only supports string arrays
Error message
templateParameter only supports string arrays
What it means
ConvertArrayParamToString is the implementation of the {{array ...}} Go template helper, which joins array parameters into a comma-separated string. When the value is a []any but any element is not a string, it fails with this error. Only arrays whose items are all strings are supported.
Source
Thrown at internal/util/parameters/parameters.go:255
}
formattedVector := formatter(rawVector)
finalValue = formattedVector
paramValues[item.Index].Value = finalValue
}
}
return paramValues, nil
}
// helper function to convert a string array parameter to a comma separated string
func ConvertArrayParamToString(param any) (string, error) {
switch v := param.(type) {
case []any:
var stringValues []string
for _, item := range v {
stringVal, ok := item.(string)
if !ok {
return "", fmt.Errorf("templateParameter only supports string arrays")
}
stringValues = append(stringValues, stringVal)
}
return strings.Join(stringValues, ", "), nil
default:
return "", fmt.Errorf("invalid parameter type, expected array of type string")
}
}
// GetParams return the ParamValues that are associated with the Parameters.
func GetParams(params Parameters, paramValuesMap map[string]any) (ParamValues, error) {
resultParamValues := make(ParamValues, 0)
for _, p := range params {
k := p.GetName()
v, ok := paramValuesMap[k]
if !ok {
return nil, fmt.Errorf("missing parameter %s", k)
}View on GitHub (pinned to 8cc6e09de2)
Solutions
- Coerce elements to strings before invoking the tool (send ["1", "2"] instead of [1, 2]).
- Tighten the parameter schema so items are typed as strings, rejecting mixed arrays earlier.
- Remove the {{array}} helper for non-string arrays and use default template rendering or another helper.
- Add a client-side check that every element is a string before the call.
Example fix
// before (numeric elements fail)
{"ids": [1, 2, 3]}
// after (string elements)
{"ids": ["1", "2", "3"]} Defensive patterns
Strategy: validation
Validate before calling
func isStringArray(v any) bool {
arr, ok := v.([]any)
if !ok { return false }
for _, it := range arr {
if _, ok := it.(string); !ok { return false }
}
return true
} Type guard
func toStringArray(v any) ([]string, bool) {
arr, ok := v.([]any)
if !ok { return nil, false }
out := make([]string, 0, len(arr))
for _, it := range arr {
s, ok := it.(string)
if !ok { return nil, false }
out = append(out, s)
}
return out, true
} Try / catch
joined, err := params.ConvertArrayParamToString(v)
if err != nil && strings.Contains(err.Error(), "only supports string arrays") {
// convert elements to strings or use plain rendering
return fallbackRender(v)
} Prevention
- Type array parameters with string items in the tool schema.
- Convert numeric IDs to strings at the client boundary.
- Document that {{array}} accepts only string arrays.
- Add integration tests that pass realistic client payloads.
When it happens
Trigger: Using {{array .param}} in a statement where the parameter's runtime value is an array containing non-string elements — numbers, booleans, nulls, nested objects or arrays, e.g. ids = [1, 2, 3].
Common situations: LLM clients sending numeric ID arrays; JSON request bodies with mixed-type arrays; template authors applying the array helper to parameters they assumed were string-typed; schemas declaring 'array' without restricting item type.
Related errors
- invalid parameter type, expected array of type string
- error embedding parameters: %w
- unable to bind: %w
- 'model' must be a string, got %T
- 'explore' must be a string, got %T
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/620156034cebf0c5.
Report an issue: GitHub.