Skip to main content
Glama
islobodan

Crucher MCP

sqrt

Read-onlyIdempotent

Compute the square root of a non-negative number. Returns an error for negative input.

Instructions

Square root. Errors on negative input.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
valueYes

Implementation Reference

  • The handler function for the 'sqrt' tool. Takes a 'value' parameter, validates it is non-negative, and returns Math.sqrt(value).
    sqrt: ({ value }) => {
        if (value < 0)
            throw new Error(
                "Cannot calculate the square root of a negative number.",
            );
        return Math.sqrt(value);
    },
  • The schema definition for the 'sqrt' tool. Defines its name, annotations, description, and inputSchema requiring a single 'value' parameter of type 'number'.
        name: "sqrt",
        annotations: {
            title: "Square Root",
            readOnlyHint: true,
            destructiveHint: false,
            idempotentHint: true,
            openWorldHint: false,
        },
        description:
            "Square root. Errors on negative input.",
        inputSchema: {
            type: "object",
            properties: { value: { type: "number" } },
            required: ["value"],
        },
    },
  • cruncher.js:1050-1051 (registration)
    The 'sqrt' tool is registered via the toolsAll array (line 323-339), filtered by tier (TOOL_TIERS.standard includes 'sqrt', line 78), and made available via TOOL_LOOKUP_MAP.
    /** Active tool list — filtered by CRUNCHER_TOOL_SET env var. */
    const TOOLS = filterToolsByTier(toolsAll, TOOL_SET);
  • cruncher.js:136-149 (registration)
    'sqrt' is registered as a main-thread tool (no worker overhead), meaning it executes synchronously on the main thread without spawning a worker.
    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
  • Pre-compiled regex patterns used in evaluate_expression to support 'sqrt()' function calls by converting them to 'Math.sqrt()'.
    const RE_FUNC_SQRT          = /\bsqrt\s*\(/g;
    const RE_FUNC_LOG           = /\blog10\s*\(/g;        // log10() → Math.log10()
    const RE_FUNC_LN            = /\bln\s*\(/g;           // ln() → Math.log()
    const RE_FUNC_LOG_BASE      = /\blog\s*\(([^,)]+)\s*,\s*([^)]+)\)/g;  // log(x,base)
    // Constants pattern: longest names first to avoid partial matches (e_charge before e,
    // euler_mascheroni before e, sqrt2 before pi, tau before tau). Built dynamically.
    const RE_CONSTANTS = (() => {
        const names = Object.keys(CONSTANTS).sort((a, b) => b.length - a.length);
        const escaped = names.map(n => n.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
        return new RegExp(`\\b(${escaped.join('|')})\\b`, 'g');
    })();
    const RE_DISALLOWED_CHARS   = /[^0-9+\-*/().% \t*,Mathabspowrndflceigumsxqtogv1]/;
    const RE_VALID_MATH_CALLS   = /Math\.(pow|abs|round|floor|ceil|min|max|sin|cos|tan|asin|acos|atan|sqrt|log10|log)\(/g;
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already indicate readOnlyHint, destructiveHint, and idempotentHint. The description adds important behavioral information: the tool errors on negative input. This goes beyond the annotations, though additional details (e.g., error type or return value) are missing.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description consists of two short sentences with no unnecessary words. It is appropriately sized for a simple tool, front-loading the core action ('Square root') and then adding a key constraint. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the low complexity and absence of an output schema, the description lacks details about return values (e.g., type or range) and does not specify what 'errors' means (e.g., exception, NaN). While the tool is simple, more context would be helpful for an agent to fully understand its behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema only defines a 'value' parameter with type number, and the description does not add any meaning beyond what is already evident. It implicitly associates 'value' with the number to take the square root of, but given zero schema description coverage, the description fails to compensate with explicit parameter explanations.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool computes square root, which is a specific mathematical operation. It also mentions the constraint about negative input, further clarifying its behavior. Among sibling math functions like sine, cosine, and power, this tool's purpose is distinct and immediately understood.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

There is no guidance on when to use this tool versus alternatives like 'power' or 'logarithm'. The description does not mention scenarios where square root is appropriate or when to avoid it. For a basic math tool, usage may seem obvious, but the rubric expects explicit direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/islobodan/cruncher-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server