Skip to main content
Glama
tech-sushant

Calculator MCP Server

by tech-sushant

sqrt

Calculate the square root of any positive number using this mathematical tool. Enter a number to get its square root value with proper error handling for invalid inputs.

Instructions

Calculate square root of a number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
numberYesNumber to calculate square root of

Implementation Reference

  • The handler for the 'sqrt' tool. Extracts the 'number' argument, checks if it's negative (returns error if so), computes Math.sqrt(number), and returns a text response with the result.
    case "sqrt": { const { number } = args as { number: number }; if (number < 0) { return { content: [ { type: "text", text: "Error: Cannot calculate square root of negative number", }, ], isError: true, }; } const result = Math.sqrt(number); return { content: [ { type: "text", text: `√${number} = ${result}`, }, ], }; }
  • src/index.ts:110-123 (registration)
    Registration of the 'sqrt' tool in the listTools response, including name, description, and input schema.
    { name: "sqrt", description: "Calculate square root of a number", inputSchema: { type: "object", properties: { number: { type: "number", description: "Number to calculate square root of", }, }, required: ["number"], }, },
  • Input schema definition for the 'sqrt' tool, specifying a required 'number' property of type number.
    inputSchema: { type: "object", properties: { number: { type: "number", description: "Number to calculate square root of", }, }, required: ["number"], },

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/tech-sushant/calculator-mcp'

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