Skip to main content
Glama

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
NameRequiredDescriptionDefault
numberYesThe number to round

Implementation Reference

  • 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}`
            }]
        }
    })
  • 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}`
            }]
        }
    })
  • 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
    }
Install Server

Other Tools

Related 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/EthanHenrickson/math-mcp'

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