sum
Compute the total of a list of numbers. Provide an array of numeric values to get their sum.
Instructions
Sum of numbers.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| numbers | Yes |
Implementation Reference
- cruncher.js:1519-1520 (handler)The handler function for the 'sum' tool. It takes an array of numbers and reduces them using safeMath.add to avoid floating-point errors, starting from 0.
sum: ({ numbers }) => numbers.reduce((acc, val) => safeMath.add(acc, val), 0), - cruncher.js:556-572 (schema)The schema/definition for the 'sum' tool, specifying the name, annotations, description, and inputSchema (an object with a required 'numbers' array of numbers).
name: "sum", annotations: { title: "Sum", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, description: "Sum of numbers.", inputSchema: { type: "object", properties: { numbers: { type: "array", items: { type: "number" } }, }, required: ["numbers"], }, }, - cruncher.js:75-86 (registration)The 'sum' tool is registered in the 'standard' tool tier list, which controls which tools are exposed via the CRUNCHER_TOOL_SET environment variable.
standard: [ "evaluate_expression", "add", "subtract", "multiply", "divide", "sqrt", "power", "absolute", "modulo", "factorial", "logarithm", "natural_log", "get_constant", "sine", "cosine", "tangent", "asin", "acos", "atan", "set_angle_mode", "get_angle_mode", "sum", "avg", "min", "max", "count", "variance", "std_dev", "percentage_of", "percentage_change", "percentage_reverse", "median", "range", "convert_unit", ],