Skip to main content
Glama
mcp-server-chile
by crisvd

mcp-server-chile — A Least-Privilege MCP Server for Chilean Business Tasks

CI Python Dependencies MCP

🇪🇸 Resumen en español: README.es.md

An MCP server that gives AI agents exact, auditable tools (RUT validation, IVA maths, economic indicators, order lookup, refund requests) instead of letting models guess. Built from scratch on the wire protocol (no SDK, zero dependencies) so every security decision is visible, and designed around least privilege: read-only by default, writes only on request, and even then the agent proposes while a person decides.

Why this project

Agents become dangerous when they get tools. This repo shows how to expose tools responsibly: validated inputs, honest annotations, scoped capabilities, rate limits, masked audit logs and no existence leaks, plus a protocol implementation that is current (spec 2026-07-28) and compatible with the 2025 clients still in the wild.

Related MCP server: chile-invoice-mcp

Tools

Tool

Scope

What it does

validate_rut

read

Modulo-11 check digit; normalises/format RUTs. Invalid RUT = normal result, not an error

calculate_iva

read

Net/IVA/total from a net or gross amount, exact integer arithmetic

check_invoice_totals

read

IVA = 19% of net (±1 peso) and net + exempt + IVA = total

get_economic_indicator

read

UF, dólar, euro, UTM, IPC. Offline = synthetic sample (is_sample: true); --online uses mindicador.cl

convert_uf_to_clp

read

UF → CLP at a date's UF value, Decimal half-up

get_order_status

read

Status of an order only if it belongs to the given customer; missing and foreign look identical

request_refund

write (needs --allow-write)

Creates a refund request pending human approval. confirm=true + idempotency key. Never moves money

Try it (no keys, no cost)

python examples/client_demo.py --allow-write       # spawns the server and talks to it over stdio
python -m unittest discover -s tests -t .          # 55 tests, incl. a real subprocess over stdio
connected: modern (2026-07-28), server=mcp-server-chile
tools: ['calculate_iva', 'check_invoice_totals', ..., 'request_refund', 'validate_rut']

check_invoice_totals(100000, 19000, 120000)
  -> {"consistent": false, "expected_iva": 19000, "expected_total": 119000, "problems": ["net + exempt + IVA = 119000, but total says 120000"]}

get_order_status(20001, someone else's order)
  -> ERROR "order not found for that customer"

request_refund(...)  -> {"status": "pending_human_approval", "replayed": false, ...}
same call again      -> {"status": "pending_human_approval", "replayed": true, ...}

Connect it to an AI host

pip install -e .                                   # makes `python -m mcp_chile` work from anywhere
claude mcp add chile -- python -m mcp_chile        # Claude Code (verify syntax for your version)

Claude Desktop / other hosts: see examples/claude_desktop_config.json and docs/CONFIGURATION.md.

Protocol: dual era

Modern (2026-07-28)

Legacy (2025-06-18 / 2025-11-25)

Opening

None. Every request carries _meta (version + capabilities)

initialize → notifications/initialized

Discovery

server/discover (required by the spec)

initialize result

Methods

server/discover, tools/list, tools/call

+ ping

Results

include resultType: "complete", list results carry ttlMs/cacheScope

classic shape

Version error

-32022 with {supported, requested}

negotiated down in initialize

Stdio rules honoured: newline-delimited JSON, nothing but protocol on stdout (logs → stderr), UTF-8, exit on stdin EOF, LF line endings even on Windows (tested end-to-end). Details and what I verified against the spec: docs/PROTOCOL.md.

Security model (summary: docs/SECURITY.md)

Threat

Control (each has tests)

Excessive agency

Read-only by default; write tool absent (not merely "denied") unless --allow-write; it only creates a request

Hallucinated/unsafe arguments

Strict JSON-Schema validation (additionalProperties: false, patterns, ranges) before any handler runs; errors are tool errors with actionable text so the model self-corrects

Runaway agent loops / abuse

Sliding-window rate limits (all calls, and a tighter one for writes)

Double actions on retry

Idempotency keys; same key + different params is rejected

Confused deputy / data leak

Ownership check on every order; missing and foreign orders return the same error

Prompt injection in arguments

Free text is stored and never interpreted; nothing in the server executes it

SSRF via the model

Online provider builds URLs from a whitelist of codes and a strict date; no model-controlled host or path

Leaky errors

Crashes return a generic message; details go to stderr only

PII in logs

Audit JSONL masks e-mails/RUTs and reduces free text to its length

Mislabelled tools

Annotations are honest (readOnlyHint, destructiveHint, idempotentHint, openWorldHint) and the description of the write tool says it does not refund

Output flooding

Result size cap

Docs

PRD · Architecture · Protocol · Security & threat model · Configuration · Enterprise Q&A · Risk matrix

Limitations (honest list)

  • Only tools. No resources, prompts, sampling, tasks or notifications; no HTTP transport or OAuth (stdio only, so authentication is the host/OS user's, not the server's).

  • The MCP spec moves fast. Verified against 2026-07-28 on the date in docs/PROTOCOL.md; legacy-era details (2025-11-25 tools page) are only partially verified. Re-check before relying on it.

  • Offline indicators are synthetic. --online uses a third-party free API (mindicador.cl) whose terms and format you should verify; it is tested only with a fake transport.

  • Orders are a fixture; a real deployment would use the company's order API with a service credential of minimal scope.

  • Rate limiting is per process, not per user; the stdio server serves exactly one host session.

  • Free-text reason is stored as submitted; a downstream human UI must escape it.

License

MIT

Available Tools

6 tools
calculate_ivaCalculate Chilean IVA (19%)A
Read-onlyIdempotent

Computes net, IVA and total in whole pesos. base='neto' means the amount is the net price; base='total' means the amount already includes IVA. Exact integer arithmetic (round half up).

Inputs: base (required), amount (required). Returns: iva, neto, total

check_invoice_totalsCheck invoice totalsA
Read-onlyIdempotent

Verifies that IVA is 19% of the net amount (±1 peso rounding) and that net + exempt + IVA equals the total. Returns the list of problems; consistent=false is a normal result.

Inputs: iva (required), neto (required), total (required), exento. Returns: problems, consistent, expected_iva, expected_total

convert_uf_to_clpConvert UF to pesosA
Read-onlyIdempotent

Converts an amount in UF to CLP using the UF value of the given date (YYYY-MM-DD). Whole pesos, round half up.

Inputs: date (required), amount_uf (required). Returns: clp, date, fuente, uf_value, +2 more

get_economic_indicatorGet an economic indicatorA
Read-onlyIdempotent

Returns UF, dólar, euro, UTM or IPC for a date (YYYY-MM-DD) or the latest available. OFFLINE MODE: returns synthetic sample values (is_sample=true); do not use for real decisions.

Inputs: code (required), date. Returns: fecha, valor, codigo, fuente, +3 more

get_order_statusGet the status of a customer's orderA
Read-onlyIdempotent

Returns status, ETA and total of an order, only if it belongs to the given customer e-mail. Missing and foreign orders return the same error.

Inputs: order_number (required), customer_email (required). Returns: eta, number, status, total_clp

validate_rutValidate a Chilean RUTA
Read-onlyIdempotent

Checks a Chilean RUT (RUN/RUT) with the modulo-11 check digit. Accepts '12.345.678-5' or '12345678-5'. An invalid RUT is a normal result (valid=false), not an error.

Inputs: rut (required). Returns: valid, reason, formatted, normalized, +1 more

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 6 tools

    Disambiguation4/5

    Each tool has a clearly distinct verb+resource target: IVA math, invoice consistency verification, UF→CLP conversion, indicator lookup, RUT validation, and order lookup. The only mild friction is that convert_uf_to_clp implicitly depends on the same UF data as get_economic_indicator, and get_order_status is an outlier from the finance/tax theme, but the descriptions make the boundaries clear enough.

    Naming Consistency5/5

    All six tools follow a strict verb_noun snake_case pattern (calculate_iva, check_invoice_totals, convert_uf_to_clp, get_economic_indicator, get_order_status, validate_rut). Verbs are specific and predictable, and noun objects are unambiguous.

    Tool Count5/5

    Six tools is well within a comfortable scope and each one performs a concrete, non-redundant operation. There are no filler or wrapper tools; every entry earns its slot.

    Completeness4/5

    The surface covers the core Chilean finance helpers: IVA calculation, invoice verification, UF conversion, economic indicators, and RUT validation. The notable gaps are the reverse CLP→UF conversion and any batch/multi-indicator retrieval, but agents can work around these.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Allows AI assistants to query public procurement opportunities, purchase orders, and government entities from Chile's Mercado Público (ChileCompra) API in real time.
      12
      20 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables users to interact with Chile's SII tax authority through natural language, including checking tax documents, invoices, filings, and administrative requests. It supports browser-based login and optional write operations when explicitly enabled.
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables access to a curated registry of Chilean administrative and regulatory entities, including institutional details, official record deep-links, RUT validation, live economic indicators, and regulatory data, along with executable legal reasoning tools.
      1
      MIT