format_number_european
Formats numeric values according to European country locale conventions, transforming decimal and thousands separators for accurate regional display.
Instructions
Formats a number using the locale conventions of a specific European country — correct decimal and thousands separators. Returns { original, formatted, locale, country_code }. Supports PT, ES, FR, DE, IT, NL, BE, PL, SE, DK, FI, AT, IE, GR, HU, RO, UK.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| number | Yes | The numeric value to format. Example: 1234.56 | |
| country_code | Yes | Two-letter country code. Example: 'PT', 'FR', 'DE' | |
| decimals | No | Number of decimal places. Defaults to 2. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| original | Yes | ||
| formatted | Yes | ||
| locale | Yes | ||
| country_code | Yes |
Implementation Reference
- index.js:261-276 (handler)The tool handler function for 'format_number_european' — formats a number using European locale conventions (decimal and thousands separators) via Intl.NumberFormat. Maps country codes to locale strings and returns the formatted result.
// ── 11. Format Number European ── server.registerTool("format_number_european", { description: "Formats a number using the locale conventions of a specific European country — correct decimal and thousands separators. Returns { original, formatted, locale, country_code }. Supports PT, ES, FR, DE, IT, NL, BE, PL, SE, DK, FI, AT, IE, GR, HU, RO, UK.", inputSchema: { number: z.number().describe("The numeric value to format. Example: 1234.56"), country_code: z.string().describe("Two-letter country code. Example: 'PT', 'FR', 'DE'"), decimals: z.number().optional().describe("Number of decimal places. Defaults to 2.") }, outputSchema: { original: z.number(), formatted: z.string(), locale: z.string(), country_code: z.string() }, annotations: { title: "Format Number European Locale", readOnlyHint: true, idempotentHint: true, openWorldHint: false } }, async ({ number, country_code, decimals = 2 }) => { const localeMap = { PT:"pt-PT",ES:"es-ES",FR:"fr-FR",DE:"de-DE",IT:"it-IT",NL:"nl-NL",BE:"fr-BE",PL:"pl-PL",SE:"sv-SE",DK:"da-DK",FI:"fi-FI",AT:"de-AT",IE:"en-IE",GR:"el-GR",HU:"hu-HU",RO:"ro-RO",UK:"en-GB" }; const locale = localeMap[country_code.toUpperCase()] || "en-GB"; const formatted = new Intl.NumberFormat(locale, { minimumFractionDigits: decimals, maximumFractionDigits: decimals }).format(number); return { content: [{ type: "text", text: JSON.stringify({ original: number, formatted, locale, country_code }) }] }; }); - index.js:262-270 (registration)Registration of the 'format_number_european' tool on the MCP server via server.registerTool(), including description and input/output schemas.
server.registerTool("format_number_european", { description: "Formats a number using the locale conventions of a specific European country — correct decimal and thousands separators. Returns { original, formatted, locale, country_code }. Supports PT, ES, FR, DE, IT, NL, BE, PL, SE, DK, FI, AT, IE, GR, HU, RO, UK.", inputSchema: { number: z.number().describe("The numeric value to format. Example: 1234.56"), country_code: z.string().describe("Two-letter country code. Example: 'PT', 'FR', 'DE'"), decimals: z.number().optional().describe("Number of decimal places. Defaults to 2.") }, outputSchema: { original: z.number(), formatted: z.string(), locale: z.string(), country_code: z.string() }, annotations: { title: "Format Number European Locale", readOnlyHint: true, idempotentHint: true, openWorldHint: false } - index.js:264-268 (schema)Input schema for format_number_european: number (required), country_code (required), decimals (optional, defaults to 2). Output schema: original, formatted, locale, country_code.
inputSchema: { number: z.number().describe("The numeric value to format. Example: 1234.56"), country_code: z.string().describe("Two-letter country code. Example: 'PT', 'FR', 'DE'"), decimals: z.number().optional().describe("Number of decimal places. Defaults to 2.") }, - index.js:272-273 (helper)Helper mapping of country codes to locale strings used for Intl.NumberFormat formatting.
const localeMap = { PT:"pt-PT",ES:"es-ES",FR:"fr-FR",DE:"de-DE",IT:"it-IT",NL:"nl-NL",BE:"fr-BE",PL:"pl-PL",SE:"sv-SE",DK:"da-DK",FI:"fi-FI",AT:"de-AT",IE:"en-IE",GR:"el-GR",HU:"hu-HU",RO:"ro-RO",UK:"en-GB" }; const locale = localeMap[country_code.toUpperCase()] || "en-GB";