max
Calculate the maximum value from an array of numbers.
Instructions
Maximum of numbers.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| numbers | Yes |
Implementation Reference
- cruncher.js:622-639 (schema)The 'max' tool schema definition, including its name, annotations, description, and inputSchema (accepts an array of 'numbers').
{ name: "max", annotations: { title: "Maximum", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, description: "Maximum of numbers.", inputSchema: { type: "object", properties: { numbers: { type: "array", items: { type: "number" } }, }, required: ["numbers"], }, }, - cruncher.js:1553-1557 (handler)The 'max' tool handler function that computes the maximum of an array of numbers using Math.max(). Throws if the array is empty.
max: ({ numbers }) => { if (numbers.length === 0) throw new Error("Cannot find the maximum of an empty list."); return Math.max(...numbers); }, - cruncher.js:130-149 (registration)MAIN_THREAD_TOOLS set that includes 'max', indicating it runs on the main thread (no worker overhead).
const MAIN_THREAD_TOOLS = new Set([ // Angle management "set_angle_mode", "get_angle_mode", // Trigonometry (instant Math calls) "sine", "cosine", "tangent", "asin", "acos", "atan", // Cache management "cache_clear", "cache_info", // Simple stats (zero-cost) "count", "min", "max", "variance", "std_dev", // Percentage "percentage_of", "percentage_change", "percentage_reverse", // Math one-liners "power", "sqrt", "logarithm", "natural_log", "absolute", // Constant lookup "get_constant", // Memory recall (single variable read) "memory_recall", // Unit conversion "convert_unit", ]); - cruncher.js:76-80 (registration)TOOL_TIERS.standard array lists 'max' as part of the standard tool set (34 tools).
"sum", "avg", "min", "max", "count", "variance", "std_dev", "percentage_of", "percentage_change", "percentage_reverse", "median", "range", "convert_unit", ], - cruncher.js:196-202 (helper)Regex RE_FUNC_MAX_FUNC used in evaluate_expression to replace max() calls with Math.max().
const RE_SCIENTIFIC_NOTATION = /(\d+\.?\d*)e([+-]?\d+)/gi; const RE_FUNC_ABS = /\babs\s*\(/g; const RE_FUNC_ROUND = /\bround\s*\(/g; const RE_FUNC_FLOOR = /\bfloor\s*\(/g; const RE_FUNC_CEIL = /\bceil\s*\(/g; const RE_FUNC_MIN_FUNC = /\bmin\s*\(/g; const RE_FUNC_MAX_FUNC = /\bmax\s*\(/g;