mod
Calculate the modulo of two numbers using the Calculator MCP server. Input two values to determine the remainder after division for precise mathematical results.
Instructions
Mod two numbers
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes |
Implementation Reference
- src/tools/mod.ts:12-17 (handler)Handler function that computes the modulo (remainder) of two numbers a and b, returning a formatted text response.handle: async (params) => { const a = params.a as number; const b = params.b as number; const result = a % b; return { content: [{ type: "text", text: `The modulo of ${a} and ${b} is ${result}` }] }; },
- src/tools/mod.ts:7-11 (schema)Schema definition for the 'mod' tool, including name, description, and Zod-based input schema for parameters a and b.schema: { name: "mod", description: "Mod two numbers", inputSchema: zodToJsonSchema(z.object({ a: z.number(), b: z.number() })), },
- src/server.ts:7-9 (registration)The 'mod' tool is imported from './tools' (which re-exports src/tools/mod.ts) and registered in the tools array used by the MCP server for listTools and callTool requests.import { add, div, mod, mul, sqrt, sub } from "./tools"; const tools = [add, div, mod, mul, sqrt, sub];