add
Add two numbers to obtain their total sum. Performs basic arithmetic addition.
Instructions
Adds two numbers.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes |
Implementation Reference
- cruncher.js:1346-1346 (handler)The tool handler for 'add' — calls safeMath.add(a, b) to sum two numbers.
add: ({ a, b }) => safeMath.add(a, b), - cruncher.js:234-251 (schema)The input schema for 'add' tool: definition of parameters 'a' and 'b' (both type: number).
// --- Basic Arithmetic (use evaluate_expression for complex math) --- { name: "add", annotations: { title: "Add", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, description: "Adds two numbers.", inputSchema: { type: "object", properties: { a: { type: "number" }, b: { type: "number" } }, required: ["a", "b"], }, }, - cruncher.js:70-73 (registration)Tool name 'add' listed under minimal, standard, and full tool tiers in TOOL_TIERS.
// Minimal: math primitives + evaluate_expression (5 tools) minimal: [ "evaluate_expression", "add", "subtract", "multiply", "divide", ], - cruncher.js:1244-1254 (helper)safeMath.add helper function that performs integer-scaling arithmetic to avoid floating-point errors.
const safeMath = { add: (a, b) => { const d1 = countDecimals(a); const d2 = countDecimals(b); const maxDecimals = Math.max(d1, d2); const multiplier = Math.pow(10, maxDecimals); return ( (Math.round(a * multiplier) + Math.round(b * multiplier)) / multiplier ); },