Skip to main content
Glama
tech-sushant

Calculator MCP Server

by tech-sushant

divide

Calculate division of two numbers by dividing the first number by the second number. Handles mathematical division operations with proper error checking.

Instructions

Divide first number by second number

Input Schema

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

Implementation Reference

  • Handler function for the 'divide' tool. Extracts arguments 'a' and 'b', checks for division by zero, computes a / b, and returns formatted result or error.
    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}`, }, ], }; }
  • Input schema defining parameters for the 'divide' tool: 'a' as dividend and 'b' as divisor, both required numbers.
    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"], },
  • src/index.ts:74-91 (registration)
    Tool registration in the list of available tools returned by ListToolsRequestHandler, 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"], }, },

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