Skip to main content
Glama
codewithmsunke

MCP Math Server

Division tool

divide

Perform division operations by calculating the quotient of two numbers, handling division by zero errors with proper error management.

Instructions

Divide a by b (a / b)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYes
bYes

Implementation Reference

  • The handler function for the 'divide' tool. It validates that b is not zero, computes the quotient a / b, and returns a textual response with the result or an error.
    async ({ a, b }) => {
      if (b === 0) {
        return {
          content: [
            { type: "text", text: `Error: Division by zero is not allowed.` }
          ],
          isError: true
        };
      }
      const quotient = a / b;
      return {
        content: [
          { type: "text", text: `The quotient of ${a} divided by ${b} is ${quotient}` }
        ]
      };
    }
  • The input schema for the 'divide' tool, defining parameters 'a' and 'b' as numbers using Zod.
    inputSchema: { a: z.number(), b: z.number() },
  • src/index.ts:169-192 (registration)
    The registration of the 'divide' tool using server.registerTool, including name, metadata (title, description, schema), and handler function.
    server.registerTool(
      "divide",
      {
        title: "Division tool",
        description: "Divide a by b (a / b)",
        inputSchema: { a: z.number(), b: z.number() },
      },
      async ({ a, b }) => {
        if (b === 0) {
          return {
            content: [
              { type: "text", text: `Error: Division by zero is not allowed.` }
            ],
            isError: true
          };
        }
        const quotient = a / b;
        return {
          content: [
            { type: "text", text: `The quotient of ${a} divided by ${b} is ${quotient}` }
          ]
        };
      }
    );
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. It mentions the operation 'a / b' but doesn't disclose behavioral traits such as error handling (e.g., division by zero), output format, or performance characteristics. This leaves significant gaps for an AI agent.

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 extremely concise with a single sentence that directly states the tool's function. It is front-loaded with no wasted words, making it efficient and easy to parse.

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

Completeness2/5

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

Given the complexity of a division operation with no annotations and no output schema, the description is incomplete. It lacks details on error cases (e.g., division by zero), return values, or usage context, which are crucial for proper tool invocation.

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

Parameters3/5

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

Schema description coverage is 0%, so the description must compensate. It adds meaning by specifying that 'a' is divided by 'b', which clarifies the order of parameters beyond the schema's type definitions. However, it doesn't explain parameter roles (e.g., dividend and divisor) or constraints like numeric ranges.

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

Purpose4/5

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

The description clearly states the verb 'divide' and the resources 'a' and 'b', making the purpose explicit. It distinguishes from siblings like 'add' or 'multiply' by specifying division. However, it doesn't explicitly mention it's a mathematical operation, though this is implied.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'multiply' or 'subtract'. It states what the tool does but offers no context about appropriate use cases, prerequisites, or exclusions.

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