googleapis/mcp-toolbox · error · Error

Invalid number input for ${NAME}: ${RAW_VALUE}

Error message

Invalid number input for ${NAME}: ${RAW_VALUE}

What it means

When converting an "arrayValue", each element is recursively converted via JSONToFirestoreValue. If any element fails, its error is wrapped as "array item %d: %w" with the failing index. This is a wrapper error — fix the underlying cause reported after the colon.

Source

Thrown at internal/server/static/js/runTool.js:63

            if (VALUE_TYPE === 'boolean') {
                typedParams[NAME] = RAW_VALUE !== null;
                console.debug(`Parameter ${NAME} (boolean) set to: ${typedParams[NAME]}`);
                continue; 
            }

            // process remaining types
            if (VALUE_TYPE && VALUE_TYPE.startsWith('array<')) {
                typedParams[NAME] = parseArrayParameter(RAW_VALUE, VALUE_TYPE, NAME);
            } else {
                switch (VALUE_TYPE) {
                    case 'number':
                        if (RAW_VALUE === "") {
                            console.debug(`Param ${NAME} was empty, setting to empty string.`)
                            typedParams[NAME] = "";
                        } else {
                            const num = Number(RAW_VALUE);
                            if (isNaN(num)) {
                                throw new Error(`Invalid number input for ${NAME}: ${RAW_VALUE}`);
                            }
                            typedParams[NAME] = num;
                        }
                        break;
                    case 'string':
                    default:
                        typedParams[NAME] = RAW_VALUE;
                        break;
                }
            }
        } catch (error) {
            console.error('Error processing parameter:', NAME, error);
            responseArea.value = `Error for ${NAME}: ${error.message}`;
            return; 
        }
    }

    console.debug('Running tool:', toolId, 'with typed params:', typedParams);

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Read the wrapped inner error to identify the real problem with element at the given index.
  2. Validate each array element individually with JSONToFirestoreValue before submitting the whole array.
  3. Fix the element's type/format per the inner error's guidance (e.g. RFC 3339 timestamp).

Example fix

// before
{"arrayValue": {"values": [{"timestampValue": "not-a-date"}]}}
// after
{"arrayValue": {"values": [{"timestampValue": "2024-01-01T00:00:00Z"}]}}
Defensive patterns

Strategy: try-catch

Validate before calling

for i, item := range values {
    if _, err := JSONToFirestoreValue(item, client); err != nil { return fmt.Errorf("array item %d invalid: %w", i, err) }
}

Try / catch

if _, err := JSONToFirestoreValue(arrVal, client); err != nil {
    var idx int
    if n, _ := fmt.Sscanf(err.Error(), "array item %d", &idx); n == 1 { /* inspect element idx */ }
}

Prevention

When it happens

Trigger: Passing {"arrayValue": {"values": [...]}} where any element is itself invalid, e.g. a bad timestampValue or malformed mapValue inside the array.

Common situations: Arrays of mixed-type documents where one nested element has a mistyped timestamp or geopoint; large arrays where the offending index is not obvious.

Related errors


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