Skip to main content
Glama

mean

Calculate the arithmetic mean of a list of numbers to determine their average value. This tool helps simplify statistical analysis by providing accurate results for numerical data sets.

Instructions

Calculates the arithmetic mean of a list of numbers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
numbersYesArray of numbers to find the mean of

Implementation Reference

  • The handler function for the 'mean' MCP tool. It calls Statistics.mean on the input numbers and returns the result as a text content response.
    }, async ({ numbers }) => { const value = Statistics.mean(numbers) return { content: [{ type: "text", text: `${value}` }] } })
  • Input schema for the 'mean' tool using Zod, requiring a non-empty array of numbers.
    numbers: z.array(z.number()).min(1).describe("Array of numbers to find the mean of")
  • src/index.ts:131-131 (registration)
    Registration of the 'mean' tool on the MCP mathServer, specifying name, description, and schema.
    mathServer.tool("mean", "Calculates the arithmetic mean of a list of numbers", {
  • The Statistics.mean static method that implements the arithmetic mean calculation logic used by the tool handler.
    static mean(numbers: number[]) { // Calculate sum and divide by the count of numbers const sum = numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0); const mean = sum / numbers.length; return mean }

Other Tools

Related 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/EthanHenrickson/math-mcp'

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