Skip to main content
Glama

divide

Calculate the division of two numbers with a dividend and divisor. Input two numerical values to get the quotient using this calculation tool from the Demo MCP Server.

Instructions

Divide two numbers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYesDividend
bYesDivisor

Implementation Reference

  • Handler function that performs division of two numbers, handling division by zero error by returning an error response.
    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 using Zod for the divide tool, defining 'a' as dividend and 'b' as divisor, both numbers.
    inputSchema: { a: z.number().describe("Dividend"), b: z.number().describe("Divisor") }
  • Registration of the 'divide' tool on the MCP server, including title, description, input schema, and handler function.
    server.registerTool( "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