Skip to main content
Glama

divide

Calculate division results by inputting dividend and divisor values to perform mathematical operations.

Instructions

Divide two numbers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYesDividend
bYesDivisor

Implementation Reference

  • Handler function for the 'divide' tool that performs division of two numbers and handles division by zero error.
    async ({ a, b }) => { if (b === 0) { return { content: [ { type: "text", text: "Error: Division by zero is not allowed" } ], isError: true }; } return { content: [ { type: "text", text: `${a} ÷ ${b} = ${a / b}` } ] }; }
  • Input schema for the 'divide' tool defining 'a' as dividend and 'b' as divisor using Zod.
    inputSchema: { a: z.number().describe("Dividend"), b: z.number().describe("Divisor") }
  • Registration of the 'divide' tool on the MCP server, including title, description, schema, and handler.
    "divide", { title: "Division Tool", description: "Divide two numbers", inputSchema: { a: z.number().describe("Dividend"), b: z.number().describe("Divisor") } }, async ({ a, b }) => { if (b === 0) { return { content: [ { type: "text", text: "Error: Division by zero is not allowed" } ], isError: true }; } return { content: [ { type: "text", text: `${a} ÷ ${b} = ${a / b}` } ] }; } );

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/kylekanouse/Test-MCP---DEMO-MCP-Dev-1'

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