Skip to main content
Glama
SanLangLOVE

Simple Calculator MCP

by SanLangLOVE

divide

Calculate the quotient of two numbers by dividing the dividend by the divisor to obtain the result.

Instructions

计算两个数字的商

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYes被除数
bYes除数

Implementation Reference

  • The switch case handler for the 'divide' tool. It extracts arguments a and b, checks if b is zero and returns an error if so, otherwise computes and returns the division result.
    case "divide": { const { a, b } = args as { a: number; b: number }; if (b === 0) { return { content: [ { type: "text", text: "错误:除数不能为零", }, ], isError: true, }; } const result = a / b; return { content: [ { type: "text", text: `${a} ÷ ${b} = ${result}`, }, ], }; }
  • The tool definition in the tools list, including name, description, and input schema for parameters a (dividend) and b (divisor).
    { name: "divide", description: "计算两个数字的商", inputSchema: { type: "object", properties: { a: { type: "number", description: "被除数", }, b: { type: "number", description: "除数", }, }, required: ["a", "b"], }, },
  • src/index.ts:111-115 (registration)
    Registers the handler for ListToolsRequestSchema, which returns the list of tools including 'divide'.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools, }; });
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/SanLangLOVE/mcp-calculator'

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