mod
Compute the remainder of dividing two numbers.
Instructions
Mod two numbers
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes |
Implementation Reference
- src/tools/mod.ts:12-17 (handler)The handler function that executes the 'mod' tool logic. It extracts parameters a and b, computes a % b, and returns the result text.
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)The schema definition for the 'mod' tool, specifying name 'mod', description, and inputSchema with two number parameters (a and b) using Zod and zod-to-json-schema.
schema: { name: "mod", description: "Mod two numbers", inputSchema: zodToJsonSchema(z.object({ a: z.number(), b: z.number() })), }, - src/server.ts:7-9 (registration)Import and registration of the 'mod' tool in the server's tools array, making it available for dispatch via CallToolRequestSchema handler.
import { add, div, mod, mul, sqrt, sub } from "./tools"; const tools = [add, div, mod, mul, sqrt, sub]; - src/tools/index.ts:3-3 (registration)Re-exports the 'mod' module from src/tools/mod.ts so it can be imported by the server.
export * from "./mod"; - src/tools/types.ts:15-18 (helper)The Tool interface type that defines the shape (schema + handle) which the mod tool conforms to.
export interface Tool { schema: ToolSchema; handle: (params: Record<string, unknown>) => Promise<ToolResult>; }