Skip to main content
Glama
paraguay-dnit-ruc

paraguay-dnit-ruc

by pipeworx-io
README.md
# @pipeworx/paraguay-dnit-ruc

Paraguay's DNIT (tax authority) RUC list for **companies**: every legal-entity RUC (8 digits, prefix 80)
with its tax id and check digit, registered name, status and previous tax id (the list's "old code").
About 176k company RUCs as of the 2026-11-01 edition.

Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 2098+ live data sources. This is an independent, unofficial integration — not affiliated with, endorsed by, or published by the upstream provider.

`latam-validate` checks RUC *format* only; `pe_ruc` covers Peru. This pack answers whether a Paraguayan
company RUC is in the DNIT list and what state it is in.

## Tools

- `py_ruc(ruc)` — look up one company. Accepts `80000030`, `80000030-7` or `800000307`. Returns `tax_id`,
  `check_digit`, `check_digit_valid`, `name`, `status` (+ English gloss, `is_active`), `previous_tax_id`
  (null when the list has none), `data_as_of` and `source`. A wrong check digit answers
  `found:false, reason:check_digit_mismatch` with the expected digit. An absent company RUC answers
  `not_in_register`, never an empty object.
- `py_ruc_search(name, active_only?, limit?)` — accent-insensitive name search (every word of 3+ letters must
  appear), active registrations first.

## Individuals are not included, and what that answer means

The list also carries about 1.85M individuals (RUCs below 80000000), roughly 91% of its rows. Their names are
personal data and no ruling covers serving them, so they are **not stored, not looked up and not searchable**;
the loader drops those rows before writing. `py_ruc` on a personal RUC answers
`found:false, reason:natural_person_not_covered` from the number alone, without reading the database. That is
"not covered", not "not found": it says nothing about whether the RUC exists. Peru's ruling is not borrowed;
this is the default for personal data.

## Auth

Keyless. The tools work only through the Pipeworx gateway (the list lives in a gateway-side database); a
standalone install returns a loud `StoreUnavailableError`, never an empty result.

## Check digit

DNIT modulus 11: weights 2, 3, 4, ... from the rightmost digit of the RUC (wrapping after 11); remainder
`r = sum mod 11`; digit = `r > 1 ? 11 - r : 0`. Verified 2026-12-02 against the published digit of every
well-formed row of the 2026-11-01 list: 2,027,700 of 2,027,700 match (the 14 that did not are malformed
lines, not algorithm misses).

## Data source & reuse terms

- DNIT, Paraguay, "Listado de RUC con sus equivalencias": ten bulk files `ruc0.zip` to `ruc9.zip`, each stamped
  "Actualizado al D-M-YY" on the download page. `data_as_of` is the oldest of the ten stamps; the per-file
  stamps are kept in `py_meta`. Fetch mechanics live only in `scripts/paraguay-dnit-ruc/`.
- **Reuse terms: none are published.** The download page (read 2026-12-02) carries no licence, terms-of-use or
  redistribution statement. It is Paraguayan public tax-register data served to anyone without credentials,
  so the companies are served, flagged here as *no explicit reuse grant*.
- There is no per-RUC live endpoint: the only public route is these bulk files.

## Budget (written, per the sourcing rule)

- **Rows:** 176,179 companies kept of 2,027,714 read (1,851,533 individuals dropped, 2 malformed company lines
  skipped; the loader fails above 50 malformed company lines).
- **Bytes:** about 52 MB in the local SQLite including the trigram name index; D1 storage of the same order
  (tens of MB). Download per refresh: 10 files, about 43 MB.
- **Refresh cadence:** monthly (DNIT republishes monthly). One refresh writes about 176k rows plus index rows.
- **Expected monthly cost:** effectively zero. It sits in the existing `pipeworx-pe-sunat-ruc` D1 database
  (binding `PE_SUNAT_DB`, shared with `peru-sunat-ruc`; every object here is prefixed `py_`), so there is no
  new database and no new gateway binding. Storage and row writes are far inside D1's included amounts, well
  under the 25 USD a month and 50 USD one-time lines.

## Refresh

`bash scripts/paraguay-dnit-ruc/refresh.sh build` scrapes the DNIT page for the current zip links (they change
with every publication), downloads the ten files, decodes ISO-8859-1, keeps only prefix-80 rows and builds a
local SQLite plus D1 import chunks without writing remotely. `refresh.sh load` then drops and recreates only the
`py_` tables in the shared D1 database and fills the FTS index; `verify --self-test` proves the completeness
gate can go red. Load has not been run (no production data written by the build session).

## Quick Start

Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):

```json
{
  "mcpServers": {
    "paraguay-dnit-ruc": {
      "url": "https://gateway.pipeworx.io/paraguay-dnit-ruc/mcp"
    }
  }
}
```

### What this endpoint actually serves

`tools/list` at `https://gateway.pipeworx.io/paraguay-dnit-ruc/mcp` returns the tools in the table
above **plus five Pipeworx tools**: `ask_pipeworx`, `discover_tools`, `ask_pipeworx_grounded`, `company_register_search` and `company_facts`.
`ask_pipeworx` answers a question this pack does not cover by routing across the
whole catalog, without adding a second MCP server.

Add an option to the same URL:

- `https://gateway.pipeworx.io/paraguay-dnit-ruc/mcp?meta=1` lists this pack's tools plus **up to 48 shared Pipeworx tools** (48 when this README was
generated; a connection without an account lists fewer, and its own `tools/list` is the
exact answer on any given day).
- `https://gateway.pipeworx.io/paraguay-dnit-ruc/mcp?meta=0` lists this pack's tools alone.

Or connect to the full Pipeworx gateway to get every pack's tools listed
directly, instead of just this one's:

```json
{
  "mcpServers": {
    "pipeworx": {
      "url": "https://gateway.pipeworx.io/mcp"
    }
  }
}
```

Both URLs reach the same gateway and the same 2098+ data sources. The
only difference is which pack's tools are listed **directly**; `ask_pipeworx`
reaches all of them from either one (it is not listed on a `?meta=0` connection).

## No MCP client? Call it over HTTP

```bash
curl -X POST https://gateway.pipeworx.io/v1/tools/py_ruc \
  -H 'Content-Type: application/json' \
  -d '{"ruc":"80000030-7"}'
```

No account needed for the first calls. Inspect any tool: `GET https://gateway.pipeworx.io/v1/tools/py_ruc`. Find one: `POST https://gateway.pipeworx.io/v1/tools/search_packs` with `{"query":"..."}`.

## Run it from npm

`@pipeworx/mcp-paraguay-dnit-ruc` is a local stdio bridge to the Pipeworx gateway: your MCP client
starts it with `npx`, and it forwards every call to the same
`https://gateway.pipeworx.io/paraguay-dnit-ruc/mcp` endpoint shown above. It needs network access;
there is no offline mode.

```json
{
  "mcpServers": {
    "paraguay-dnit-ruc": {
      "command": "npx",
      "args": ["-y", "@pipeworx/mcp-paraguay-dnit-ruc"]
    }
  }
}
```

Without a key it calls anonymously, capped at 50 calls a day. A free account
raises that to 200 a day: get a key at https://pipeworx.io/signup and add
`"env": { "PIPEWORX_API_KEY": "<your key>" }` to the server entry.
The key is sent as a Bearer token, the same way a hosted connection sends it,
so calls are metered and billed exactly as they are there.

It lists **only** this pack's tools by default. Set `PIPEWORX_META_TOOLS=1` to
also list `ask_pipeworx` and the other gateway-wide tools.

Behind an HTTPS proxy: Node's built-in `fetch` does not read `HTTPS_PROXY` by
default. Newer Node releases honour it when `NODE_USE_ENV_PROXY=1` is set; check
your Node version's documentation.

## Using with ask_pipeworx

Instead of calling tools directly, you can ask questions in plain English —
this works on the pack endpoint above as well as on the full gateway:

```
ask_pipeworx({ question: "your question about Paraguay Dnit Ruc data" })
```

The gateway picks the right tool and fills the arguments automatically.

## More

- [Docs and guides](https://pipeworx.io/docs)
- [pipeworx.io](https://pipeworx.io)

## License

MIT