Skip to main content
Glama
codewithmsunke

MCP Math Server

Square Root tool

sqrt

Calculate the square root of a number with results rounded to two decimal places for precise mathematical computations.

Instructions

Calculate the square root of a number (rounded to two decimals)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
xYes

Implementation Reference

  • The handler function that computes the square root of the input 'x' using Math.sqrt, returns an error for negative inputs, rounds the result to two decimal places, and formats the response as MCP content.
    async ({ x }) => {
      if (x < 0) {
        return {
          content: [
            { type: "text", text: `Error: Square root of negative number is not allowed.` }
          ],
          isError: true
        };
      }
      const result = Math.sqrt(x);
      const rounded = Math.round(result * 100) / 100;
      return {
        content: [
          { type: "text", text: `The square root of ${x} is ${rounded}` }
        ]
      };
    }
  • Defines the input schema for the 'sqrt' tool using Zod: expects a single number parameter 'x'. Includes title and description.
    {
      title: "Square Root tool",
      description: "Calculate the square root of a number (rounded to two decimals)",
      inputSchema: { x: z.number() },
    },
  • src/index.ts:32-56 (registration)
    Registers the 'sqrt' tool with the MCP server, providing the tool name, schema/metadata, and handler function.
    server.registerTool(
      "sqrt",
      {
        title: "Square Root tool",
        description: "Calculate the square root of a number (rounded to two decimals)",
        inputSchema: { x: z.number() },
      },
      async ({ x }) => {
        if (x < 0) {
          return {
            content: [
              { type: "text", text: `Error: Square root of negative number is not allowed.` }
            ],
            isError: true
          };
        }
        const result = Math.sqrt(x);
        const rounded = Math.round(result * 100) / 100;
        return {
          content: [
            { type: "text", text: `The square root of ${x} is ${rounded}` }
          ]
        };
      }
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions rounding behavior ('rounded to two decimals'), which is valuable, but lacks details on error handling (e.g., for negative numbers), performance, or output format. This leaves gaps for a mutation-like tool (calculation) with no annotation coverage.

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

Conciseness5/5

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

The description is a single, efficient sentence that front-loads the core purpose ('Calculate the square root of a number') and adds precision details without waste. Every word earns its place, making it highly concise and well-structured.

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

Completeness3/5

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

Given the tool's low complexity (single parameter, mathematical operation) and lack of annotations or output schema, the description is minimally adequate. It covers the basic purpose and rounding behavior but misses error handling and output details, which could be important for an agent invoking this tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 0% description coverage, with one parameter 'x' of type 'number' but no semantic explanation. The description compensates by clarifying that 'x' is 'a number' for which the square root is calculated, adding meaningful context beyond the bare schema. Since there is only one parameter, this is sufficient for a high baseline.

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

Purpose5/5

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

The description clearly states the specific action ('calculate the square root') and resource ('a number'), with additional precision details ('rounded to two decimals'). It effectively distinguishes this tool from sibling mathematical operations like 'square' or 'multiply' by specifying the square root function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for square root calculations, but does not explicitly state when to use this tool versus alternatives like 'square' (which squares a number) or other mathematical operations. No guidance is provided on edge cases (e.g., negative inputs) or prerequisites.

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/codewithmsunke/MCPMathTools'

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