chapin-mcp
# chapin-mcp 🇬🇹
[](https://github.com/folgmateo/chapin-mcp/actions/workflows/ci.yml)
[](LICENSE)
**Servidor MCP + librerÃa TypeScript con utilidades de Guatemala para agentes de IA.**
Conectalo a Cursor, Claude, Grok Bot o cualquier cliente MCP y tu agente podrá validar NITs y DPIs, desglosar el IVA, escribir montos en letras para facturas y armar enlaces de WhatsApp con +502, sin inventarse nada.
> *English version below.*
## ¿Por qué?
Los LLMs se equivocan con cosas muy chapinas: calculan mal el dÃgito verificador del NIT, no saben que el CUI trae el departamento y municipio, o escriben "veintiuno quetzales". `chapin-mcp` le da al agente **herramientas deterministas y probadas** para esas tareas.
## Herramientas MCP
| Herramienta | Qué hace | Ejemplo |
|---|---|---|
| `validar_nit` | Valida un NIT de la SAT (módulo 11, verificador `K`, acepta `CF`) | `576937-K` → válido |
| `validar_cui` | Valida el CUI del DPI (RENAP): verificador, departamento y municipio | `1234 56789 0101` → válido, Guatemala |
| `calcular_iva` | Desglosa o agrega IVA (12% por defecto) | `Q112.00` → base `Q100.00` + IVA `Q12.00` |
| `monto_en_letras` | Monto en letras estilo factura/cheque | `1250.50` → `MIL DOSCIENTOS CINCUENTA QUETZALES CON 50/100` |
| `telefono_whatsapp` | Normaliza teléfonos +502, móvil/fijo, enlace `wa.me` | `5555 1234` → `https://wa.me/50255551234` |
| `departamentos` | Los 22 departamentos: código, cabecera y nº de municipios | `Sololá` → `07` |
## Instalación en Cursor
Agregá esto a `.cursor/mcp.json` (en tu proyecto) o a `~/.cursor/mcp.json` (global):
```json
{
"mcpServers": {
"chapin": {
"command": "npx",
"args": ["-y", "github:folgmateo/chapin-mcp"]
}
}
}
```
Luego pedile al agente cosas como:
- *"Validá estos NITs de clientes y decime cuáles están malos"*
- *"Generá el texto de la factura por Q3,599.99 con el monto en letras"*
- *"Armame los botones de WhatsApp para estos teléfonos de la barberÃa"*
### Claude Desktop / otros clientes MCP
Mismo bloque `mcpServers` en el archivo de configuración del cliente. También podés correrlo directo:
```bash
npx -y github:folgmateo/chapin-mcp # servidor MCP por stdio
```
## Uso como librerÃa
```bash
npm install github:folgmateo/chapin-mcp
```
```ts
import { validarNit, validarCui, desglosarIva, montoEnLetras, enlaceWhatsApp } from "chapin-mcp";
validarNit("576937-K").valido; // true
validarCui("1234567890101").departamento?.nombre; // "Guatemala"
desglosarIva(112); // { base: 100, iva: 12, total: 112, tasa: 0.12 }
montoEnLetras(21); // "VEINTIÚN QUETZALES CON 00/100"
enlaceWhatsApp("5555-1234", "Hola!"); // "https://wa.me/50255551234?text=Hola!"
```
## Desarrollo
```bash
npm install
npm test # compila con tsc y corre los tests (node:test), incluida una prueba MCP de punta a punta
npm start # levanta el servidor por stdio
```
## Notas
- Las validaciones son **matemáticas/de formato**: confirman que un NIT o CUI *puede* existir, no que esté registrado en la SAT o el RENAP.
- Códigos de departamento y conteo de municipios (340 en total) según la división polÃtico-administrativa vigente.
- ¿Encontraste un caso raro? ¡Abrà un issue o PR!
---
## English
**MCP server + TypeScript library with Guatemala-specific utilities for AI agents.** Plug it into Cursor, Claude, Grok Bot or any MCP client so your agent can validate Guatemalan tax IDs (NIT) and national IDs (DPI/CUI), split 12% VAT (IVA), write amounts in Spanish words for invoices and checks, normalize +502 phone numbers into WhatsApp links, and look up the 22 departments.
**Tools:** `validar_nit`, `validar_cui`, `calcular_iva`, `monto_en_letras`, `telefono_whatsapp`, `departamentos`.
**Cursor setup** (`.cursor/mcp.json`):
```json
{ "mcpServers": { "chapin": { "command": "npx", "args": ["-y", "github:folgmateo/chapin-mcp"] } } }
```
**As a library:** `npm install github:folgmateo/chapin-mcp`, then `import { validarNit } from "chapin-mcp"`.
Validation is checksum/format-based only; it does not query SAT or RENAP. Tested on Node 20, 22 and 24.
## Licencia / License
[MIT](LICENSE) © 2026 Mateo Folgar
TDQS
Scored across 6 tools
Each tool targets a clearly distinct operation: two validators (NIT vs CUI), a geography lister, an IVA calculator, a number-to-words converter, and a phone normalizer. Even the two 'validar_*' tools are unambiguous because the identifier types (NIT/CF vs 13-digit CUI) are explicitly named.
Half the set follows a verb_noun pattern (validar_nit, validar_cui, calcular_iva), but the rest are bare nouns or noun phrases (departamentos, monto_en_letras, telefono_whatsapp). The convention is mixed even though all names are lowercase snake_case and readable.
Six tools is well-scoped for a Guatemala-specific formatting/validation utility server; each tool earns its place and there is no filler. No obvious consolidation or splitting is needed.
The core local-domain utilities (NIT, CUI, departamentos, IVA, letras, teléfono) form a coherent surface with no dead ends, since validators return useful detail like department/municipio. Minor gaps exist: no standalone municipio lookup, no NIT/CUI generation or reverse parsing (e.g. birth date from CUI), and no other common invoice helpers (e.g. retención/IVA split rates).