Skip to main content
Glama
tech-sushant

Calculator MCP Server

by tech-sushant

sqrt

Calculate the square root of any number to solve mathematical problems or verify calculations.

Instructions

Calculate square root of a number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
numberYesNumber to calculate square root of

Implementation Reference

  • Handler logic for the 'sqrt' tool: validates input number is non-negative, computes square root using Math.sqrt, and returns formatted result or error.
    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 tools array, including name, description, and input schema definition.
    {
      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 for the 'sqrt' tool defining the expected 'number' parameter.
    inputSchema: {
      type: "object",
      properties: {
        number: {
          type: "number",
          description: "Number to calculate square root of",
        },
      },
      required: ["number"],
    },
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/tech-sushant/calculator-mcp'

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