round
Round a number to the nearest integer using a simple API tool for precise numerical calculations. Ideal for quick and accurate integer conversion.
Instructions
Rounds a number to the nearest integer
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| number | Yes | The number to round |
Implementation Reference
- src/index.ts:252-260 (handler)The handler function that executes the 'round' tool logic by calling Arithmetic.round on the input number and returning the result as MCP text content.}, async ({ number }) => { const value = Arithmetic.round(number) return { content: [{ type: "text", text: `${value}` }] } })
- src/index.ts:251-251 (schema)The Zod input schema defining a single 'number' parameter for the 'round' tool.number: z.number().describe("The number to round"),
- src/index.ts:246-260 (registration)The registration of the 'round' tool on the MCP server, including JSDoc, name, description, schema, and handler./** * Round operation * Rounds a number to the nearest integer */ mathServer.tool("round", "Rounds a number to the nearest integer", { number: z.number().describe("The number to round"), }, async ({ number }) => { const value = Arithmetic.round(number) return { content: [{ type: "text", text: `${value}` }] } })
- src/Classes/Arithmetic.ts:77-85 (helper)The helper static method 'Arithmetic.round' that performs the core rounding logic using Math.round./** * Calculate the round of a number * @param number - Number to find the round of * @returns round of the number */ static round(number: number) { const round = Math.round(number) return round }