get_constant
Retrieve a mathematical, physical, or chemical constant by selecting from a predefined list of common values like pi, e, or the speed of light.
Instructions
Returns a mathematical, physical, or chemical constant. See enum values.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Implementation Reference
- cruncher.js:509-546 (schema)The tool schema/definition for get_constant, including its inputSchema with an enum of constant names (pi, e, tau, phi, etc.) and required parameter 'name'.
{ name: "get_constant", annotations: { title: "Get Constant", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, description: "Returns a mathematical, physical, or chemical constant. See enum values.", inputSchema: { type: "object", properties: { name: { type: "string", enum: [ "pi", "e", "tau", "phi", "sqrt2", "euler_mascheroni", "c", "g", "G", "h", "k", "R", "NA", "e_charge", "m_e", "m_p", ], }, }, required: ["name"], }, - cruncher.js:1485-1488 (handler)The handler function for the get_constant tool. Looks up the constant name in the CONSTANTS object and returns its value, or throws if unknown.
get_constant: ({ name }) => { if (name in CONSTANTS) return CONSTANTS[name]; throw new Error(`Unknown constant: ${name}`); }, - cruncher.js:173-192 (helper)The CONSTANTS object shared between get_constant and evaluate_expression, containing mathematical (pi, e, tau, phi, sqrt2, euler_mascheroni) and physical/chemical (c, g, G, h, k, R, NA, e_charge, m_e, m_p) constants with their values.
const CONSTANTS = { // Math pi: Math.PI, e: Math.E, tau: 2 * Math.PI, phi: 1.618033988749895, sqrt2: Math.SQRT2, euler_mascheroni: 0.5772156649015329, // Physics (SI Units) c: 299792458, g: 9.80665, G: 6.6743e-11, h: 6.62607015e-34, k: 1.380649e-23, R: 8.314462618, NA: 6.02214076e23, e_charge: 1.602176634e-19, m_e: 9.1093837015e-31, m_p: 1.67262192369e-27, }; - cruncher.js:130-145 (registration)Registration of get_constant in the MAIN_THREAD_TOOLS set, meaning it runs directly on the main thread without worker overhead for performance.
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)