Skip to main content
Glama
islobodan

Crucher MCP

avg

Read-onlyIdempotent

Calculate the average (mean) of a list of numbers. Provide an array of numbers to get their mean value.

Instructions

Average (mean) of numbers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
numbersYes

Implementation Reference

  • The avg handler function. Calculates the mean by summing numbers using safeMath.add and dividing by count using safeMath.divide. Throws on empty array.
    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,
        );
    },
  • The inputSchema definition for the 'avg' tool. Defines the 'numbers' parameter as an array of numbers (required).
    {
        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"],
        },
    },
  • cruncher.js:76-76 (registration)
    The 'avg' tool is listed in the 'standard' tool tier, meaning it's exposed in standard and full modes.
    "sum", "avg", "min", "max", "count", "variance", "std_dev",
  • The safeMath.add and safeMath.divide helpers used by the avg handler to perform safe floating-point arithmetic via integer-scaling.
    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 indicate readOnlyHint and idempotentHint. The description adds no behavioral details beyond what annotations provide, but it does not contradict them. With annotations present, the bar is lower; however, the description adds no extra value.

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

Conciseness4/5

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

The description is a single, clear sentence. It is concise and front-loaded, but could include more useful information without being verbose.

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

Completeness2/5

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

Given the tool's simplicity, the description is minimal. It does not mention edge cases (e.g., empty input), return value type, or behavior for non-integer results. Annotations help but the description still lacks completeness for a fully transparent tool.

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?

Schema description coverage is 0%, and the description does not elaborate on the 'numbers' parameter beyond its type. It fails to mention constraints like minimum length or handling of empty arrays. The description adds minimal value over the schema.

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

Purpose4/5

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

The description clearly states it calculates the average (mean) of numbers. It is specific enough to know the tool's purpose, but does not distinguish it from other statistical tools like median or mode among siblings.

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 on when to use this tool versus siblings such as median, mode, or sum. The description merely states what it does without context on appropriate use cases.

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