Skip to main content
Glama
tech-sushant

Calculator MCP Server

by tech-sushant

divide

Perform division operations by calculating the quotient of two numbers. Use this tool to divide any number by another, with built-in error handling for cases like division by zero.

Instructions

Divide first number by second number

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYesDividend (number to be divided)
bYesDivisor (number to divide by)

Implementation Reference

  • The handler for the 'divide' tool performs division of the first argument 'a' by the second 'b', handles division by zero error, and formats the response.
    case "divide": { const { a, b } = args as { a: number; b: number }; if (b === 0) { return { content: [ { type: "text", text: "Error: Division by zero is not allowed", }, ], isError: true, }; } const result = a / b; return { content: [ { type: "text", text: `${a} ÷ ${b} = ${result}`, }, ], }; }
  • src/index.ts:74-91 (registration)
    Registration of the 'divide' tool in the list of available tools, including name, description, and input schema.
    { name: "divide", description: "Divide first number by second number", inputSchema: { type: "object", properties: { a: { type: "number", description: "Dividend (number to be divided)", }, b: { type: "number", description: "Divisor (number to divide by)", }, }, required: ["a", "b"], }, },
  • Input schema definition for the 'divide' tool, specifying parameters 'a' (dividend) and 'b' (divisor).
    inputSchema: { type: "object", properties: { a: { type: "number", description: "Dividend (number to be divided)", }, b: { type: "number", description: "Divisor (number to divide by)", }, }, required: ["a", "b"], },
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