# chile-kit
> The toolkit for building software in Chile: RUT, CLP, IVA, regions and communes, banks, UF/UTM and Santiago dates. Zero-dependency TypeScript package `chile-kit` (ESM, Node >= 22.12, browsers, Edge) plus an MCP server `chile-kit-mcp`.
Install: `npm install chile-kit`. Every module is a subpath export (`chile-kit/rut`, `/clp`, …) and also re-exported from the package root. All functions are pure and synchronous except `/indicators`. Formatters accept `null`/`undefined` and never throw on bad display input.
MCP server for agents: `npx -y chile-kit-mcp` (stdio). Claude Code: `claude mcp add chile-kit -- npx -y chile-kit-mcp`. Tools (each with an output schema): validate_rut, format_rut, rut_check_digit, format_clp, normalize_phone, whatsapp_link, search_communes, get_region, list_banks, iva_from_net, iva_from_gross, get_indicators, format_date_chile. get_indicators returns `{ values, errors? }` and falls back to the official CMF API when the server has `CMF_API_KEY`; search_communes returns `{ communes }`. On native Windows use `cmd /c npx -y chile-kit-mcp`.
## API
- `/rut`: `isValidRut(rut): boolean` (modulo-11 verifier, body 1-9 digits, not all zeros); `normalizeRut(rut): string | null` ("12.345.678-k" → "12345678K", for storage; null when not RUT-shaped, e.g. "hola"); `formatRut(rut): string` ("123456785" → "12.345.678-5"); `rutCheckDigit(body)` → "0"-"9" | "K" | null (dots allowed); `isValidRut(rut, { minBody })` (e.g. 1_000_000 to reject short typos for people); `formatRutInput(value)` progressive formatting for an input's onChange ("1234567" → "123.456-7", caps at 9 digits + verifier).
- `/clp`: `formatCLP(n)` → "$1.234.567" (rounded, no decimals; negative "$-5.000"); `formatNumber(n)` → "1.234,5"; `fmtClp(n)` / `fmtNumber(n)` return "—" for null, undefined, NaN, Infinity. Output is identical on every runtime (no Intl).
- `/iva`: `IVA_RATE = 0.19`; `ivaFromNet(net, rate?)`, `grossFromNet(net, rate?)`, `netFromGross(gross, rate?)`, `ivaFromGross(gross, rate?)`, `splitGross(gross, rate?)` → `{ net, iva, gross }` with net + iva = gross; `lineAmount({ unitPrice, quantity?, discount? })`; `invoiceTotals(lines, rate?)` → `{ lines, net, exempt, iva, total }` with IVA computed once on the net; `roundClp(n)` half away from zero. All amounts are integer pesos, within ±Number.MAX_SAFE_INTEGER (RangeError beyond, and for NaN/Infinity).
- `/phone`: `normalizeChileanPhone(input)` → "+56912345678" or null (mobiles only); `formatChileanPhone(input)` → "+56 9 1234 5678" (unparseable input returned as-is); `isValidChileanMobile(input)`.
- `/wa`: `buildWaLink(phone, text?)` → "https://wa.me/56912345678?text=…" or null when there are no digits.
- `/name`: `titleCaseName(raw)` → "María de los Ángeles Pérez" (Spanish particles lowercase, O'Higgins, María-José, keeps acronyms in mixed-case input).
- `/date`: always America/Santiago, same output on server and client. `formatChileDate(input, "short" | "medium" | "long" | "full")` → "04-12-2026" | "4 dic 2026" | "4 de diciembre de 2026" | "viernes, 4 de diciembre de 2026"; `formatChileTime(input, { seconds? })` → "14:05"; `formatChileDateTime(input, style?)` → "04-12-2026 14:05"; `toChileISODate(input)` → "2026-12-04"; `chileToday()`; `getChileDateParts(input)`; `CHILE_TIME_ZONE`. Input: Date, epoch ms or ISO string; a date-only "2026-12-04" is a Chilean calendar date (midnight in Santiago, no day shift); invalid gives "".
- `/zod` (needs zod 4 as a peer): `rutSchema` and `personRutSchema` (→ normalized RUT), `phoneSchema` (→ E.164), `clpSchema` (whole non-negative pesos), `regionCodeSchema` (→ "13"), `communeCodeSchema` (→ "13120"); Spanish error messages.
- `/regions`: `REGIONS` (16, north to south: `{ id: "RM", code: "13", iso: "CL-RM", name, abbreviation, romanNumber }`), `PROVINCES` (56: `{ code: "131", name, regionCode }`), `COMMUNES` (346: `{ id: "nunoa", code: "13120", name: "Ñuñoa", provinceCode, regionCode }`); `getRegion(codeOrIdOrIsoOrRoman)`, `findRegion(name)`, `getProvince(code)`, `getCommune(cutOrSlug)`, `findCommune(name)` (accent/case-insensitive, knows alternative spellings), `searchCommunes(query, { region?, limit? })`, `getCommunesByRegion(region)`, `getCommunesByProvince(code)`, `getProvincesByRegion(region)`. Codes are official CUT (Decreto 1115, 2018).
- `/banks`: `BANKS` (`{ code: "012", name, shortName: "BancoEstado", brands }`, CMF codes), `getBank(code, { banks? })`, `findBank(nameOrBrand, { banks? })` (pass `[...BANKS, myBank]` to extend) ("Banco" optional; Banco Security, code 049, merged into BICE 028 in 2025 and resolves to it), `ACCOUNT_TYPES` (checking "Cuenta corriente", demand "Cuenta vista", rut "CuentaRUT", savings "Cuenta de ahorro"), `getAccountType(id)`.
- `/indicators`: `getIndicator(code, options?)` with code "uf" | "utm" | "dolar" | "euro" → `Promise<{ code, name, value, date }>` (value in CLP, date YYYY-MM-DD); `getIndicators(codes?, options?)` → record by code. Options: `date` (YYYY-MM-DD), `cache` (`{ get, set }`, default in-memory 1 h, `null` disables), `fetchOptions` (passed to fetch, e.g. `{ next: { revalidate: 3600 } }`), `timeoutMs`, `signal`, `fetch`, `baseUrl`, `source` and `fallback` (`IndicatorSource` or list, tried in order on IndicatorError). Sources: `mindicadorSource()` (default, community-run, no SLA) and `cmfSource({ apiKey })` (official CMF API, free key; recommended as primary or fallback for production). Throws `IndicatorError` with `reason` "network" | "timeout" | "http" | "invalid-response" | "not-found" (`timeoutMs`, default 10 s, covers headers and body). Source: mindicador.cl.
## Docs
- [Home](https://gvelasquez760.github.io/chile-kit/)
- [RUT](https://gvelasquez760.github.io/chile-kit/rut/)
- [CLP](https://gvelasquez760.github.io/chile-kit/clp/)
- [IVA](https://gvelasquez760.github.io/chile-kit/iva/)
- [Phones](https://gvelasquez760.github.io/chile-kit/phone/)
- [WhatsApp links](https://gvelasquez760.github.io/chile-kit/wa/)
- [Names](https://gvelasquez760.github.io/chile-kit/name/)
- [Regions and communes](https://gvelasquez760.github.io/chile-kit/regions/)
- [Banks](https://gvelasquez760.github.io/chile-kit/banks/)
- [Indicators](https://gvelasquez760.github.io/chile-kit/indicators/)
- [Dates](https://gvelasquez760.github.io/chile-kit/date/)
- [MCP server](https://gvelasquez760.github.io/chile-kit/mcp/)
- [Next.js](https://gvelasquez760.github.io/chile-kit/nextjs/)
- [Zod schemas](https://gvelasquez760.github.io/chile-kit/zod/)
- [For AI coding agents: skill, Cursor rules, prompts](https://gvelasquez760.github.io/chile-kit/agents/)
- [Guías en español](https://gvelasquez760.github.io/chile-kit/es/): [Validar RUT](https://gvelasquez760.github.io/chile-kit/es/validar-rut/), [Dígito verificador](https://gvelasquez760.github.io/chile-kit/es/digito-verificador/), [RUT en un input](https://gvelasquez760.github.io/chile-kit/es/formatear-rut-input/), [Calcular IVA](https://gvelasquez760.github.io/chile-kit/es/calcular-iva/), [Pesos chilenos](https://gvelasquez760.github.io/chile-kit/es/formatear-pesos-chilenos/), [Valor UF](https://gvelasquez760.github.io/chile-kit/es/valor-uf/), [Teléfonos](https://gvelasquez760.github.io/chile-kit/es/validar-telefono/), [Regiones y comunas](https://gvelasquez760.github.io/chile-kit/es/regiones-comunas-json/), [Fechas de Chile](https://gvelasquez760.github.io/chile-kit/es/fechas-chile-nextjs/)
- [Source and README](https://github.com/gvelasquez760/chile-kit)
- [Full docs in one file (llms-full.txt)](https://gvelasquez760.github.io/chile-kit/llms-full.txt)
---
# chile-kit
**The toolkit for building software in Chile: RUT, pesos, IVA, regions and communes, banks, UF/UTM and Santiago dates. Typed, zero dependencies, with an MCP server for AI agents.**
[](https://www.npmjs.com/package/chile-kit)
[](https://github.com/gvelasquez760/chile-kit/actions/workflows/ci.yml)
[](https://github.com/gvelasquez760/chile-kit/actions/workflows/ci.yml)
[](https://github.com/gvelasquez760/chile-kit/blob/main/LICENSE)
[](https://bundlejs.com/?q=chile-kit)
[](https://github.com/gvelasquez760/chile-kit/blob/main/package.json)
[](https://scorecard.dev/viewer/?uri=github.com/gvelasquez760/chile-kit)
[Docs and playground](https://gvelasquez760.github.io/chile-kit/) · [MCP server](https://github.com/gvelasquez760/chile-kit/tree/main/mcp) · [llms.txt](https://gvelasquez760.github.io/chile-kit/llms.txt) · [Next.js example](https://github.com/gvelasquez760/chile-kit/tree/main/examples/next)
## Why
- **Done once, carefully.** The helpers every Chilean product rewrites (RUT, pesos, IVA, regions and communes, bank codes, UF, Santiago dates), typed and tested to 100% coverage, with official sources cited for every dataset.
- **Runs everywhere, renders the same.** Zero dependencies and only web-standard APIs: Node, browsers, Deno, Bun, Next.js Server and Client Components and the Edge runtime, with identical output on the server and in the browser.
- **From form to invoice.** Zod schemas validate the fields and output the values you store; IVA and invoice totals follow SII rounding; [a checkout](#build-a-chilean-checkout-in-5-minutes) takes a few lines.
- **Ready for agents.** An [MCP server](https://github.com/gvelasquez760/chile-kit/tree/main/mcp) exposes the same functions as tools, and [llms.txt](https://gvelasquez760.github.io/chile-kit/llms.txt) / [llms-full.txt](https://gvelasquez760.github.io/chile-kit/llms-full.txt) describe the API for models.
## Install
```sh
npm install chile-kit
pnpm add chile-kit
yarn add chile-kit
bun add chile-kit
```
Also on [JSR](https://jsr.io/@gvelasquez760/chile-kit) as `@gvelasquez760/chile-kit`, and mirrored on GitHub Packages as `@gvelasquez760/chile-kit` and `@gvelasquez760/chile-kit-mcp`. Until 1.0.2 the npm packages were `@gvelasquez760/chile-kit` and `@gvelasquez760/chile-kit-mcp`; those names are deprecated and point here, so switch the import paths when you upgrade.
ESM only. Node 22.12 or newer, modern browsers, Next.js (Server and Client Components, Route Handlers, proxy, Edge), Deno and Bun. No Node-only APIs. CommonJS code can `require()` it on Node 22.12+ (no top-level await); in TypeScript use `module: "nodenext"`.
## Build a Chilean checkout in 5 minutes
The fields every Chilean checkout asks for, validated and normalized for storage, with the total in pesos and IVA:
```sh
npm install chile-kit zod
```
```ts
import { formatCLP } from "chile-kit/clp";
import { grossFromNet, ivaFromNet } from "chile-kit/iva";
import { getCommune } from "chile-kit/regions";
import { communeCodeSchema, personRutSchema, phoneSchema, regionCodeSchema } from "chile-kit/zod";
import { z } from "zod";
const Checkout = z.object({
rut: personRutSchema, // "12.345.678-5" → "123456785"
phone: phoneSchema, // "9 1234 5678" → "+56912345678"
region: regionCodeSchema, // "RM" → "13"
commune: communeCodeSchema, // "nunoa" → "13120"
});
// On the server (Route Handler, Server Action, API): never trust the browser.
export function placeOrder(form: unknown, net: number) {
const result = Checkout.safeParse(form);
if (!result.success) return { ok: false, errors: z.flattenError(result.error).fieldErrors };
const order = result.data; // canonical values, ready to store
return {
ok: true,
order,
shipTo: getCommune(order.commune)?.name, // "Ñuñoa"
summary: `Neto ${formatCLP(net)} + IVA ${formatCLP(ivaFromNet(net))} = ${formatCLP(grossFromNet(net))}`,
// "Neto $25.210 + IVA $4.790 = $30.000"
};
}
placeOrder({ rut: "12.345.678-5", phone: "912345678", region: "RM", commune: "nunoa" }, 25_210);
```
Error messages come in Spanish ("RUT inválido", "Celular chileno inválido"). The same schemas drive the form in the browser: [`examples/next/app/checkout-form.tsx`](https://github.com/gvelasquez760/chile-kit/blob/main/examples/next/app/checkout-form.tsx) wires them to react-hook-form with `zodResolver`, formats the RUT as it is typed and fills the commune select from the region. zod is an optional peer dependency: only `chile-kit/zod` needs it.
## For AI agents (MCP)
[`chile-kit-mcp`](https://github.com/gvelasquez760/chile-kit/tree/main/mcp) is a stdio MCP server with 13 tools: `validate_rut`, `format_rut`, `rut_check_digit`, `format_clp`, `normalize_phone`, `whatsapp_link`, `search_communes`, `get_region`, `list_banks`, `iva_from_net`, `iva_from_gross`, `get_indicators` (live) and `format_date_chile`. Every tool declares an output schema and returns structured content.
**Claude Code**
```sh
claude mcp add chile-kit -- npx -y chile-kit-mcp
```
On native Windows, wrap `npx` in `cmd /c`: `claude mcp add chile-kit -- cmd /c npx -y chile-kit-mcp` (and `"command": "cmd", "args": ["/c", "npx", "-y", "chile-kit-mcp"]` in the JSON configs below).
**Claude Desktop** (`claude_desktop_config.json`) and **Cursor** (`.cursor/mcp.json`)
```json
{
"mcpServers": {
"chile-kit": {
"command": "npx",
"args": ["-y", "chile-kit-mcp"]
}
}
}
```
**VS Code** (`.vscode/mcp.json`)
```json
{
"servers": {
"chile-kit": {
"type": "stdio",
"command": "npx",
"args": ["-y", "chile-kit-mcp"]
}
}
}
```
**Coding agents in your repo:** a Claude Code skill ships in [`skills/chile-kit`](https://github.com/gvelasquez760/chile-kit/tree/main/skills/chile-kit) (copy it to `.claude/skills/chile-kit/`), and [the agents page](https://gvelasquez760.github.io/chile-kit/agents/) has Cursor rules, an AGENTS.md snippet and prompts that work.
Agents that read docs instead of calling tools: [llms.txt](https://gvelasquez760.github.io/chile-kit/llms.txt), or the whole reference in one file: [llms-full.txt](https://gvelasquez760.github.io/chile-kit/llms-full.txt).
## En español
Utilidades chilenas para TypeScript y agentes de IA, sin dependencias:
- **Validar RUT** y calcular el dígito verificador: `isValidRut("12.345.678-5")`, `rutCheckDigit("12345678")` → `"5"`, `formatRutInput(valor)` para formatear mientras se escribe.
- **Formatear pesos chilenos**: `formatCLP(1234567)` → `"$1.234.567"`.
- **Calcular IVA** (19%) desde neto o bruto, con redondeo SII: `splitGross(9990)`.
- **Lista de regiones y comunas de Chile** con código CUT oficial, ISO y slug: `getCommunesByRegion("RM")`, `findCommune("ñuñoa")`.
- **Valor UF, UTM y dólar hoy** desde mindicador.cl, con la API oficial de la CMF como respaldo: `await getIndicator("uf", { fallback: cmfSource({ apiKey }) })`.
- **Códigos de bancos** para transferencias (CMF/SBIF): `getBank("012")` → BancoEstado.
- **Fechas en hora de Chile** (America/Santiago) sin errores de hidratación: `formatChileDateTime(fecha)`.
Documentación y playground:
## Quick start
```ts
import { formatRut, isValidRut } from "chile-kit/rut";
import { formatCLP } from "chile-kit/clp";
import { splitGross } from "chile-kit/iva";
import { findCommune } from "chile-kit/regions";
import { formatChileDateTime } from "chile-kit/date";
isValidRut("12.345.678-5"); // true
formatRut("123456785"); // "12.345.678-5"
formatCLP(1234567); // "$1.234.567"
splitGross(9990); // { net: 8395, iva: 1595, gross: 9990 }
findCommune("nunoa")?.code; // "13120"
formatChileDateTime(new Date()); // "04-12-2026 14:05", Santiago time on any server
```
Everything is also exported from the package root (`import { formatRut } from "chile-kit"`); with `sideEffects: false`, bundlers keep only what you use (importing `formatRut` from the root adds about 300 bytes, minified; CI checks it).
## Modules
| Subpath | What it does |
| ---------------------------------------------------------------------- | ----------------------------------------------------- |
| [`/rut`](https://gvelasquez760.github.io/chile-kit/rut/) | Validate (modulo 11), normalize and format RUTs |
| [`/clp`](https://gvelasquez760.github.io/chile-kit/clp/) | Format Chilean pesos and numbers, hydration-safe |
| [`/iva`](https://gvelasquez760.github.io/chile-kit/iva/) | 19% IVA from net or gross, SII-style invoice totals |
| [`/phone`](https://gvelasquez760.github.io/chile-kit/phone/) | Chilean mobiles to E.164 and display form |
| [`/wa`](https://gvelasquez760.github.io/chile-kit/wa/) | WhatsApp `wa.me` links |
| [`/name`](https://gvelasquez760.github.io/chile-kit/name/) | Title-case person names |
| [`/date`](https://gvelasquez760.github.io/chile-kit/date/) | Dates and times in `America/Santiago` |
| [`/regions`](https://gvelasquez760.github.io/chile-kit/regions/) | 16 regions, 56 provinces, 346 communes with CUT codes |
| [`/zod`](https://gvelasquez760.github.io/chile-kit/zod/) | Zod schemas for RUT, phone, CLP, region and commune |
| [`/banks`](https://gvelasquez760.github.io/chile-kit/banks/) | Bank codes (CMF/SBIF) and account types for transfers |
| [`/indicators`](https://gvelasquez760.github.io/chile-kit/indicators/) | UF, UTM, dólar observado and euro from mindicador.cl |
/rut: Validate, normalize and format RUTs
```ts
import { formatRut, formatRutInput, isValidRut, normalizeRut, rutCheckDigit } from "chile-kit/rut";
isValidRut("12.345.678-5"); // true
isValidRut("10.000.013-k"); // true (K verifier, any case)
isValidRut("12.345.678-4"); // false: wrong verifier
isValidRut("00-0"); // false: passes modulo 11, but no real RUT is all zeros
normalizeRut(" 12.345.678-5 "); // "123456785" store this
formatRut("123456785"); // "12.345.678-5" show this
formatRut("7"); // "7" too short to parse: comes back as-is
normalizeRut("hola"); // null not RUT-shaped
rutCheckDigit("12.345.678"); // "5" the verifier for a body
isValidRut("1-9", { minBody: 1_000_000 }); // false: too short for a person
formatRutInput("1234567"); // "123.456-7" as-you-type, for onChange
```
Syntactic check only (factors 2..7, 10 → K, 11 → 0; body of 1 to 9 digits, not all zeros). It does not query SII.
**Minimum length.** One random string in eleven passes modulo 11, so a short typo like `"1-9"` or `"12.345-6"` can be "valid". People's RUTs have bodies of about 1.000.000 and up, so for a person field use `isValidRut(rut, { minBody: 1_000_000 })`; company RUTs are larger (50.000.000 and up). The default (`minBody: 1`) is unchanged.
**As-you-type input.** `formatRutInput` keeps digits and a final K, adds dots and the dash as the value grows (no dash before the second character) and caps it at 9 digits plus the verifier. It treats the last character as the verifier, so check the value with `isValidRut` on blur or submit, not on every keystroke. To keep the caret where the user is typing, count the digits before the caret in the raw value and put the caret after the same number of digits in the formatted one:
```tsx
"use client";
import { formatRutInput, isValidRut } from "chile-kit/rut";
import { useState } from "react";
/** Index in `formatted` right after its `count`-th digit or K. */
function caretAfter(formatted: string, count: number): number {
let seen = 0;
for (let i = 0; i < formatted.length; i += 1) {
if (seen === count) return i;
if (/[0-9K]/.test(formatted[i] ?? "")) seen += 1;
}
return formatted.length;
}
export function RutInput() {
const [rut, setRut] = useState("");
return (
2 && !isValidRut(rut)}
onChange={(event) => {
const input = event.target;
const next = formatRutInput(input.value);
const typed = input.value
.slice(0, input.selectionStart ?? undefined)
.replace(/[^0-9kK]/g, "");
// Write the DOM first so React keeps the caret, even when the value did not change.
input.value = next;
const caret = caretAfter(next, typed.length);
input.setSelectionRange(caret, caret);
setRut(next);
}}
/>
);
}
```
/clp: Format pesos and numbers
```ts
import { fmtClp, fmtNumber, formatCLP, formatNumber } from "chile-kit/clp";
formatCLP(1234567); // "$1.234.567"
formatCLP(1999.6); // "$2.000" CLP has no cents
formatCLP(-5000); // "$-5.000"
formatNumber(1234.5); // "1.234,5" up to 3 decimals
fmtClp(null); // "—" nullish-safe variant for tables
fmtClp(Number.NaN); // "—" never "$NaN"
fmtNumber(undefined); // "—"
```
Deliberately not built on `Intl.NumberFormat`: its output depends on the runtime's ICU data (Safari spaces the `$` differently), which breaks React hydration. These functions emit the bytes Node's es-CL produces, on every runtime; a test pins that parity.
/iva: IVA from net or gross, invoice totals
```ts
import { grossFromNet, invoiceTotals, ivaFromNet, netFromGross, splitGross } from "chile-kit/iva";
ivaFromNet(10000); // 1900
grossFromNet(10000); // 11900
netFromGross(11900); // 10000
splitGross(9990); // { net: 8395, iva: 1595, gross: 9990 }, net + iva === gross always
ivaFromNet(1050); // 200: exact integer math, never 199 from 199.4999…
invoiceTotals([
{ unitPrice: 1050, quantity: 2 },
{ unitPrice: 2590, quantity: 1.5, discount: 85 },
{ unitPrice: 5000, exempt: true },
]);
// { lines: [2100, 3800, 5000], net: 5900, exempt: 5000, iva: 1121, total: 12021 }
```
Rules: amounts are whole pesos; rounding is half up (half away from zero for credit notes); each line is rounded, and IVA is computed once on the net total (per-line IVA can drift a peso per line). Every function takes an optional `rate` (fraction, default `IVA_RATE = 0.19`). `roundClp(n)` rounds any amount to pesos. Amounts must stay within ±`Number.MAX_SAFE_INTEGER` (about 9 thousand trillion pesos) so every peso is exact; beyond that, and for `NaN` or `Infinity`, the functions throw a `RangeError` instead of returning a wrong number.
/phone: Chilean mobile numbers
```ts
import { formatChileanPhone, isValidChileanMobile, normalizeChileanPhone } from "chile-kit/phone";
normalizeChileanPhone("9 1234 5678"); // "+56912345678" (E.164, store this)
normalizeChileanPhone("(+56) 9-1234-5678"); // "+56912345678"
normalizeChileanPhone("221234567"); // null: landline
formatChileanPhone("56912345678"); // "+56 9 1234 5678"
formatChileanPhone("not a phone"); // "not a phone" (safe fallback)
isValidChileanMobile("912345678"); // true
```
/wa: WhatsApp links
```ts
import { buildWaLink } from "chile-kit/wa";
buildWaLink("+56 9 1234 5678"); // "https://wa.me/56912345678"
buildWaLink("912345678", "Hola, ¿sigue disponible?");
// "https://wa.me/56912345678?text=Hola%2C%20%C2%BFsigue%20disponible%3F"
buildWaLink("12345678"); // "https://wa.me/56912345678" (legacy 8-digit mobile)
buildWaLink("+54 11 1234 5678"); // "https://wa.me/541112345678" (non-Chilean passes through)
buildWaLink("sin número"); // null: render no button instead of a broken link
```
/name: Person names
```ts
import { titleCaseName } from "chile-kit/name";
titleCaseName("MARÍA DE LOS ÁNGELES PÉREZ"); // "María de los Ángeles Pérez"
titleCaseName("bernardo o'higgins"); // "Bernardo O'Higgins"
titleCaseName(" maría-josé rojas "); // "María-José Rojas"
titleCaseName("ABC Estética"); // "ABC Estética": mixed-case input keeps acronyms and inner caps
```
/date: Dates in America/Santiago
```ts
import {
chileToday,
formatChileDate,
formatChileDateTime,
formatChileTime,
toChileISODate,
} from "chile-kit/date";
const at = "2026-12-05T02:30:00Z"; // 23:30 on Dec 4 in Santiago
formatChileDate(at); // "04-12-2026"
formatChileDate(at, "medium"); // "4 dic 2026"
formatChileDate(at, "long"); // "4 de diciembre de 2026"
formatChileDate(at, "full"); // "viernes, 4 de diciembre de 2026"
formatChileTime(at); // "23:30"
formatChileDateTime(at, "long"); // "4 de diciembre de 2026, 23:30"
toChileISODate(at); // "2026-12-04"
chileToday(); // today in Chile, wherever the code runs
formatChileDate(null); // ""
```
Always `America/Santiago` (daylight saving included), whatever the server time zone. A date-only string (`"2026-12-04"`) is a Chilean calendar date: midnight in Santiago, so it never shifts to the previous day. `Intl` is used only to convert the instant to Santiago's numeric calendar fields; every string is assembled from fixed es-CL tables, so the server-rendered HTML and the browser produce the same bytes. Inputs: `Date`, epoch milliseconds or ISO string.
/regions: Regions, provinces and communes
```ts
import {
COMMUNES,
REGIONS,
findCommune,
findRegion,
getCommune,
getCommunesByRegion,
getProvincesByRegion,
getRegion,
searchCommunes,
} from "chile-kit/regions";
REGIONS.length; // 16, north to south
getRegion("RM"); // { id: "RM", code: "13", iso: "CL-RM", name: "Metropolitana de Santiago", abbreviation: "RM", romanNumber: "RM" }
getRegion(16)?.name; // "Ñuble" also "16", "NB", "CL-NB", "NUBLE"
findRegion("Región del Biobío")?.id; // "BI"
getProvincesByRegion("NB"); // Diguillín, Itata, Punilla
getCommunesByRegion("NB").length; // 21
getCommune("13120"); // { id: "nunoa", code: "13120", name: "Ñuñoa", provinceCode: "131", regionCode: "13" }
getCommune(1101)?.name; // "Iquique" numeric codes and slugs work too
findCommune("ÑUÑOA")?.code; // "13120" accent, case and punctuation-insensitive
findCommune("La Calera")?.name; // "Calera" common alternative spellings
searchCommunes("conce"); // [Concepción]
searchCommunes("san", { region: "RM", limit: 5 });
```
Region `id` is the ISO 3166-2 suffix (`RM`, `NB`), `code` the official CUT. `romanNumber` is kept as a secondary field: by law (Ley 21.074) regions are identified by name. The dataset is about 6 KB gzipped and stays out of bundles that do not import `/regions`.
/banks: Banks and account types
```ts
import { ACCOUNT_TYPES, BANKS, findBank, getBank } from "chile-kit/banks";
getBank("012")?.shortName; // "BancoEstado"
getBank(1)?.name; // "Banco de Chile"
findBank("Banco Edwards")?.code; // "001": brands map to their bank
findBank("itau")?.code; // "039"
findBank("Falabella")?.code; // "051": "Banco" is optional
getBank("049")?.shortName; // "BICE": Banco Security merged into BICE in 2025
// A bank that opened after this release, or your own label: pass your list.
const banks = [...BANKS, { code: "070", name: "Banco Nuevo", shortName: "Nuevo", brands: [] }];
getBank("070", { banks })?.name; // "Banco Nuevo"
findBank("nuevo", { banks })?.code; // "070"
ACCOUNT_TYPES; // checking "Cuenta corriente", demand "Cuenta vista", rut "CuentaRUT", savings "Cuenta de ahorro"
```
Banks supervised by the CMF, with the three-digit code (ex-SBIF) transfer forms use. Cooperatives and prepaid-card issuers are not banks and are not listed. Banks that merged (Security into BICE, CMF Res. Ex. 10940 of 2025) keep their old code and name as aliases of the surviving bank. The data is frozen; extend it with your own list as above instead of mutating it. See [Data freshness](#data-freshness) for how updates ship.
/indicators: UF, UTM, dólar and euro
```ts
import {
cmfSource,
createMemoryCache,
getIndicator,
getIndicators,
IndicatorError,
} from "chile-kit/indicators";
const uf = await getIndicator("uf");
// { code: "uf", name: "Unidad de fomento (UF)", value: 39643.59, date: "2026-12-04" }
const usd = await getIndicator("dolar", { date: "2026-12-01" });
const { utm, euro } = await getIndicators(["utm", "euro"]);
// Production: the official CMF API as a fallback (free key from api.cmfchile.cl).
const cmf = cmfSource({ apiKey: process.env.CMF_API_KEY ?? "" });
await getIndicator("uf", { fallback: cmf }); // mindicador first, CMF if it fails
await getIndicator("uf", { source: cmf }); // CMF only
try {
await getIndicator("dolar", { date: "2026-12-05" }); // a Saturday: no value
} catch (error) {
if (error instanceof IndicatorError) error.reason; // "not-found" | "network" | "timeout" | "http" | "invalid-response"
}
```
Options: `date` (`YYYY-MM-DD`), `cache` (any `{ get, set }`, sync or async; default in-memory with a one-hour TTL; `null` disables it; `createMemoryCache(ttlMs)` builds your own), `fetchOptions` (passed straight to `fetch`), `timeoutMs` (default 10 s), `signal`, `fetch`, `baseUrl`, `source` and `fallback` (an `IndicatorSource` or a list, tried in order when the previous source throws an `IndicatorError`). Uses the global `fetch`; no dependencies.
**Which source.** [mindicador.cl](https://mindicador.cl) is a free, community-run service with no SLA: great for dashboards and side projects. When a wrong or missing value costs money (invoices, quotes, payments), use the official [CMF API](https://api.cmfchile.cl) through `cmfSource`, as the primary source or as the `fallback`. Its key is free; keep it in an environment variable or your secret manager. chile-kit never stores it and masks it in error messages. A custom source is two functions, `url(code, date)` and `parse(body, code, date)`, so you can point it at your own cache or mirror.
Full reference with live examples: [docs](https://gvelasquez760.github.io/chile-kit/).
## Next.js
Pure ESM with subpath exports and types that resolve under `moduleResolution: "bundler"` and `"node16"`. No Node-only APIs, so every module runs in Server Components, Client Components, Route Handlers, `proxy.ts` (formerly middleware) and the Edge runtime. `sideEffects: false` keeps unused modules (like the communes dataset) out of client bundles.
```tsx
// app/page.tsx (Server Component). Works with cacheComponents: true, the create-next-app default.
import { formatCLP } from "chile-kit/clp";
import { getIndicator } from "chile-kit/indicators";
import { cacheLife } from "next/cache";
async function Uf() {
"use cache";
cacheLife("hours");
try {
const uf = await getIndicator("uf", { timeoutMs: 5000 });
return
# chile-kit-mcp
**MCP server with Chilean stuff for AI agents: validate RUT, format CLP, IVA, regions and communes, banks, live UF/UTM/dólar and Santiago dates.**
[](https://www.npmjs.com/package/chile-kit-mcp)
[](https://github.com/gvelasquez760/chile-kit/actions/workflows/ci.yml)
[](https://github.com/gvelasquez760/chile-kit/actions/workflows/ci.yml)
[](https://github.com/gvelasquez760/chile-kit/blob/main/LICENSE)
[Docs](https://gvelasquez760.github.io/chile-kit/mcp/) · [chile-kit](https://github.com/gvelasquez760/chile-kit) · [llms.txt](https://gvelasquez760.github.io/chile-kit/llms.txt)