Skip to main content
Glama
islobodan

Crucher MCP

avg

Read-onlyIdempotent

Calculates the average (mean) of a list of numbers. Provide a set of numeric values to get their arithmetic mean.

Instructions

Average (mean) of numbers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
numbersYes

Implementation Reference

  • Input schema definition for the 'avg' tool. Takes an array of numbers and computes the average (mean).
    {
        name: "avg",
        annotations: {
            title: "Average",
            readOnlyHint: true,
            destructiveHint: false,
            idempotentHint: true,
            openWorldHint: false,
        },
        description: "Average (mean) of numbers.",
        inputSchema: {
            type: "object",
            properties: {
                numbers: { type: "array", items: { type: "number" } },
            },
            required: ["numbers"],
        },
    },
  • Handler function for the 'avg' tool. Computes the arithmetic mean of an array of numbers using safeMath.add and safeMath.divide to avoid floating-point errors. Throws if the array is empty.
    avg: ({ numbers }) => {
        if (numbers.length === 0)
            throw new Error("Cannot calculate the average of an empty list.");
        return safeMath.divide(
            numbers.reduce((acc, val) => safeMath.add(acc, val), 0),
            numbers.length,
        );
    },
  • cruncher.js:82-82 (registration)
    Tool name 'avg' registered in the 'standard' tier of the TOOL_TIERS configuration. This controls which tool set is exposed based on the CRUNCHER_TOOL_SET environment variable.
    "sum", "avg", "min", "max", "count", "variance", "std_dev",
  • The safeMath helper object, used by the avg handler to safely add and divide numbers with integer-scaling to avoid floating-point precision 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
            );
        },
        subtract: (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
            );
        },
        multiply: (a, b) => {
            const d1 = countDecimals(a);
            const d2 = countDecimals(b);
            const multiplier1 = Math.pow(10, d1);
            const multiplier2 = Math.pow(10, d2);
            return (
                (Math.round(a * multiplier1) * Math.round(b * multiplier2)) /
                (multiplier1 * multiplier2)
            );
        },
        divide: (a, b) => {
            if (b === 0) throw new Error("Division by zero is not allowed.");
            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);
        },
        modulo: (a, b) => {
            if (b === 0) throw new Error("Modulo by zero is not allowed.");
            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
            );
        },
    };
Behavior3/5

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

Annotations already declare this tool as readOnlyHint=true, destructiveHint=false, and idempotentHint=true, which is consistent with computing an average. The description adds no further behavioral context (e.g., handling of empty arrays), but does not contradict the annotations.

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 is extremely concise—only four words—with no fluff. Every word is necessary and the message is immediately clear.

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

Completeness4/5

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

For a simple mathematical tool with one parameter and no output schema, the description is sufficient. The annotations cover behavioral traits. The only missing aspect is guidance on edge cases (e.g., empty array), but the tool's simplicity reduces the need for more.

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

Parameters3/5

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

The input schema has 0% description coverage for its single parameter 'numbers'. The description does not explain the parameter beyond stating it operates on numbers. While the parameter is self-explanatory, the description could add useful semantics like handling of non-numeric inputs, but it does not.

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 'Average (mean) of numbers' clearly states the verb (average/mean) and resource (numbers). It distinguishes this tool from siblings like median, mode, sum, etc., which are present on the same server.

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?

No guidance is provided on when to use this tool versus alternatives like median or sum. There is no discussion of edge cases or prerequisites, leaving the agent without decision support.

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