Skip to main content
Glama
wrtnlabs

Calculator MCP

by wrtnlabs

sqrt

Calculate the square root of a number using the sqrt tool in Calculator MCP, designed to perform precise mathematical operations for LLMs.

Instructions

Square root of a number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYes

Implementation Reference

  • Full implementation of the 'sqrt' tool, including schema definition and the handler function that computes Math.sqrt(a).
    export const sqrt: Tool = {
      schema: {
        name: "sqrt",
        description: "Square root of a number",
        inputSchema: zodToJsonSchema(z.object({ a: z.number() })),
      },
      handle: async (params) => {
        const a = params.a as number;
        const result = Math.sqrt(a);
        return { content: [{ type: "text", text: `The square root of ${a} is ${result}` }] };
      },
    };
  • Input schema for the sqrt tool using Zod for validation (expects object with 'a' number).
    schema: {
      name: "sqrt",
      description: "Square root of a number",
      inputSchema: zodToJsonSchema(z.object({ a: z.number() })),
    },
  • src/server.ts:7-9 (registration)
    The 'sqrt' tool is imported and registered in the main tools array used by the MCP server.
    import { add, div, mod, mul, sqrt, sub } from "./tools";
    
    const tools = [add, div, mod, mul, sqrt, sub];
  • src/tools/index.ts:5-5 (registration)
    Re-export of the sqrt tool from the tools index module.
    export * from "./sqrt";
Install Server

Other Tools

Related Tools

  • @kelseyee/mcp_calculator
  • @balajidommeti/MCP
  • @wrtnlabs/calculator-mcp
  • @kelseyee/mcp_calculator
  • @shaleen-wonder-ent/simple-mcp-server
  • @wrtnlabs/calculator-mcp

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

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