@dojocoding/hacienda-mcp 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +85 -0
- package/README.md +62 -8
- package/dist/chunk-Q2UJO3PQ.js +944 -0
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +20 -10
- package/dist/chunk-B2GJ3MA4.js +0 -62558
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @dojocoding/hacienda-mcp
|
|
2
|
+
|
|
3
|
+
## 0.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- Updated dependencies [7c800ab]
|
|
9
|
+
- Updated dependencies [682bce8]
|
|
10
|
+
- @dojocoding/hacienda-shared@0.4.1
|
|
11
|
+
- @dojocoding/hacienda-sdk@0.4.1
|
|
12
|
+
|
|
13
|
+
## 0.4.0
|
|
14
|
+
|
|
15
|
+
- Declare Node.js 22+ and public package metadata; verify installed TypeScript consumers and ship corrected upgrade documentation.
|
|
16
|
+
- Report the package manifest version in CLI/MCP metadata instead of a hardcoded version.
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- eaf7cff: Validate XML offline against the vendored Hacienda v4.4 schemas before submission.
|
|
21
|
+
Fix discount totals, reconcile summaries with detail, serialize sequence resets
|
|
22
|
+
and increments, and enforce concurrent API rate limits. Return nonzero CLI exit
|
|
23
|
+
codes for rejected submissions. MCP invoice creation requires the actual system
|
|
24
|
+
provider ID and validates generated documents; its JSON schema resource now
|
|
25
|
+
reflects the tool input schema.
|
|
26
|
+
- 4e89886: Harden cancellation, submission deadlines, response/XML limits, certificate
|
|
27
|
+
readiness, secret-safe diagnostics and retry semantics. Fix standalone MCP ESM
|
|
28
|
+
startup and validate inputs before sequence allocation. Update security-sensitive
|
|
29
|
+
dependencies and add hostile-input, cryptographic, local HTTP lifecycle,
|
|
30
|
+
multiprocess sequence and installed-package regression suites.
|
|
31
|
+
|
|
32
|
+
Submission timeout now covers POST and polling; POST/PATCH are not automatically
|
|
33
|
+
retried. HTTP requests default to a 30-second deadline and reject redirects.
|
|
34
|
+
See docs/security-hardening.md for input caps and remaining trust boundaries.
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- Updated dependencies [eaf7cff]
|
|
39
|
+
- Updated dependencies [4e89886]
|
|
40
|
+
- @dojocoding/hacienda-sdk@0.4.0
|
|
41
|
+
- @dojocoding/hacienda-shared@0.4.0
|
|
42
|
+
|
|
43
|
+
## 0.3.0
|
|
44
|
+
|
|
45
|
+
### Minor Changes (BREAKING — pre-1.0)
|
|
46
|
+
|
|
47
|
+
- `create_invoice` and `draft_invoice` tools and the `factura-schema` resource now speak the v4.4 contract (`proveedorSistemas`, `codigoActividadEmisor`, required emisor `ubicacion`, single `medioPago` code emitted inside `ResumenFactura`, `codigoTarifaIVA`, `codigoDescuento`, ID types 05/06). `unidadMedida` is validated against the official catalog and location fields enforce the v4.4 bounds.
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- Updated dependencies
|
|
52
|
+
- @dojocoding/hacienda-sdk@0.3.0
|
|
53
|
+
- @dojocoding/hacienda-shared@0.3.0
|
|
54
|
+
|
|
55
|
+
## 0.2.0
|
|
56
|
+
|
|
57
|
+
### Minor Changes
|
|
58
|
+
|
|
59
|
+
- Rename npm scope from `@hacienda-cr` to `@dojocoding` for DojoCoding ecosystem branding. All packages now published under the `@dojocoding` org. No API changes.
|
|
60
|
+
|
|
61
|
+
### Patch Changes
|
|
62
|
+
|
|
63
|
+
- Updated dependencies
|
|
64
|
+
- @dojocoding/hacienda-shared@0.2.0
|
|
65
|
+
- @dojocoding/hacienda-sdk@0.2.0
|
|
66
|
+
|
|
67
|
+
## 0.1.0
|
|
68
|
+
|
|
69
|
+
### Minor Changes
|
|
70
|
+
|
|
71
|
+
- Initial public release of hacienda-cr — TypeScript SDK, CLI, and MCP Server for Costa Rica electronic invoicing (Hacienda API v4.4).
|
|
72
|
+
|
|
73
|
+
**@dojocoding/hacienda-shared** — Shared types, Zod schemas, and constants for all 7 document types, tax codes, and identification types.
|
|
74
|
+
|
|
75
|
+
**@dojocoding/hacienda-sdk** — Core SDK with OAuth2 authentication, 50-digit clave generation/parsing, XML builder, XAdES-EPES digital signing, API client with submission/polling, and document builders for all 7 electronic document types.
|
|
76
|
+
|
|
77
|
+
**@dojocoding/hacienda-cli** — `hacienda` CLI binary for login, invoice drafting, validation, signing, submission, status checking, and document listing.
|
|
78
|
+
|
|
79
|
+
**@dojocoding/hacienda-mcp** — MCP Server exposing invoice creation, status checking, document retrieval, taxpayer lookup, and reference data as AI-accessible tools and resources.
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- Updated dependencies
|
|
84
|
+
- @dojocoding/hacienda-shared@0.1.0
|
|
85
|
+
- @dojocoding/hacienda-sdk@0.1.0
|
package/README.md
CHANGED
|
@@ -65,23 +65,65 @@ const transport = new StdioServerTransport();
|
|
|
65
65
|
await server.connect(transport);
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
+
## Authentication and document lifecycle
|
|
69
|
+
|
|
70
|
+
`lookup_taxpayer`, `draft_invoice`, and `create_invoice` do not need IDP
|
|
71
|
+
authentication. `draft_invoice` produces a template with provider and issuer
|
|
72
|
+
location placeholders. Complete these and review the activity, CABYS, taxes,
|
|
73
|
+
and customer before passing it to `create_invoice`.
|
|
74
|
+
|
|
75
|
+
`create_invoice` returns **unsigned XML**, its clave, and calculated totals. It
|
|
76
|
+
does not sign or submit to Hacienda. It increments the default local sequence
|
|
77
|
+
store for document type `01`, branch `001`, POS `00001`; the counter does not
|
|
78
|
+
separate issuers or environments. Save the returned XML and clave before
|
|
79
|
+
handing them to your backend for validation, signing, submission, and status
|
|
80
|
+
tracking. Repeating `create_invoice` allocates a new number and clave.
|
|
81
|
+
|
|
82
|
+
`check_status`, `list_documents`, and `get_document` need a saved profile and
|
|
83
|
+
`HACIENDA_PASSWORD` in the **MCP server process**. First create the profile with
|
|
84
|
+
the CLI (using the corresponding password in its environment):
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
hacienda auth login --cedula-type 02 --cedula 3101234567 \
|
|
88
|
+
--environment sandbox --profile sandbox
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Replace the identification with your issuer's. Select `profile: "sandbox"`
|
|
92
|
+
when calling these tools; all three default to `"default"`. A desktop client's
|
|
93
|
+
server may not inherit your terminal's environment. Use your client's secret
|
|
94
|
+
or environment configuration to supply `HACIENDA_PASSWORD` to the server. The
|
|
95
|
+
password is not stored by `auth login`; saving a profile alone is insufficient.
|
|
96
|
+
Restart the server after updating profiles or credentials because authenticated
|
|
97
|
+
clients are cached by profile name.
|
|
98
|
+
|
|
99
|
+
For a complete SDK handoff, see the [sandbox walkthrough](https://github.com/DojoCodingLabs/hacienda-cr/blob/main/docs/sandbox-guide.md#usar-la-cli-o-mcp-en-el-mismo-flujo).
|
|
100
|
+
For multiple companies or application instances, see the
|
|
101
|
+
[production integration guide](https://github.com/DojoCodingLabs/hacienda-cr/blob/main/docs/production-integration.md).
|
|
102
|
+
|
|
68
103
|
## Tools
|
|
69
104
|
|
|
70
105
|
### `create_invoice`
|
|
71
106
|
|
|
72
|
-
Create a Factura Electronica (electronic invoice).
|
|
107
|
+
Create a Factura Electronica (electronic invoice). Automatically computes taxes,
|
|
108
|
+
totals, generates the clave numerica, validates input and XSD, and returns
|
|
109
|
+
unsigned XML. Local validation does not imply Hacienda acceptance.
|
|
73
110
|
|
|
74
111
|
**Parameters:**
|
|
75
112
|
|
|
76
|
-
- `
|
|
113
|
+
- `proveedorSistemas` -- Required identification of the invoicing system provider (9–12 digits)
|
|
114
|
+
- `emisor` -- Issuer information: name, ID, email, and required `ubicacion` with `provincia`, `canton`, `distrito`, `otrasSenas`; optional `nombreComercial`
|
|
77
115
|
- `receptor` -- Receiver information (name, optional ID, optional email)
|
|
78
|
-
- `codigoActividadEmisor` -- Issuer economic activity code (6 digits)
|
|
79
|
-
- `proveedorSistemas` -- Invoicing-system provider ID (optional, defaults to the emisor ID)
|
|
116
|
+
- `codigoActividadEmisor` -- Issuer economic activity code (6 digits), distinct from each item's 13-digit CABYS code
|
|
80
117
|
- `condicionVenta` -- Sale condition code (default: `"01"` = cash)
|
|
81
|
-
- `medioPago` --
|
|
82
|
-
- `lineItems` -- Array of
|
|
118
|
+
- `medioPago` -- Single payment-method string (default: `"01"` = cash); emitted with its amount inside `ResumenFactura`
|
|
119
|
+
- `lineItems` -- Array of 1–1000 items with `codigoCabys`, `cantidad`, `unidadMedida`, `detalle`, `precioUnitario`, optional `impuesto` (up to 10), `descuento` (up to 5), and `esServicio` (defaults to `false`; set `true` for services)
|
|
83
120
|
- `plazoCredito` -- Credit term in days (optional)
|
|
84
121
|
|
|
122
|
+
`plazoCredito` is a string and is required for credit sales (`condicionVenta: "02"`).
|
|
123
|
+
Tax inputs contain `codigo`, `tarifa`, and optional `codigoTarifaIVA`; discount
|
|
124
|
+
inputs contain `montoDescuento`, `naturalezaDescuento`, and `codigoDescuento` (defaults to `"01"`). The tool calculates
|
|
125
|
+
the resulting amounts.
|
|
126
|
+
|
|
85
127
|
### `check_status`
|
|
86
128
|
|
|
87
129
|
Check the processing status of a document by its 50-digit clave numerica.
|
|
@@ -89,6 +131,7 @@ Check the processing status of a document by its 50-digit clave numerica.
|
|
|
89
131
|
**Parameters:**
|
|
90
132
|
|
|
91
133
|
- `clave` -- The 50-digit clave numerica
|
|
134
|
+
- `profile` -- Saved profile name (default: `"default"`); requires server password environment
|
|
92
135
|
|
|
93
136
|
### `list_documents`
|
|
94
137
|
|
|
@@ -102,6 +145,7 @@ List recent electronic documents with optional filters.
|
|
|
102
145
|
- `receptorIdentificacion` -- Filter by receiver ID (optional)
|
|
103
146
|
- `fechaDesde` -- Start date filter, ISO 8601 (optional)
|
|
104
147
|
- `fechaHasta` -- End date filter, ISO 8601 (optional)
|
|
148
|
+
- `profile` -- Saved profile name (default: `"default"`); requires server password environment
|
|
105
149
|
|
|
106
150
|
### `get_document`
|
|
107
151
|
|
|
@@ -110,6 +154,7 @@ Get full details of an electronic document by its 50-digit clave numerica.
|
|
|
110
154
|
**Parameters:**
|
|
111
155
|
|
|
112
156
|
- `clave` -- The 50-digit clave numerica
|
|
157
|
+
- `profile` -- Saved profile name (default: `"default"`); requires server password environment
|
|
113
158
|
|
|
114
159
|
### `lookup_taxpayer`
|
|
115
160
|
|
|
@@ -121,7 +166,10 @@ Look up a Costa Rica taxpayer by identification number (cedula). Returns name, I
|
|
|
121
166
|
|
|
122
167
|
### `draft_invoice`
|
|
123
168
|
|
|
124
|
-
Generate a draft invoice template
|
|
169
|
+
Generate a draft invoice template. Fill in `proveedorSistemas` and issuer
|
|
170
|
+
location placeholders, review the default CABYS/activity and tax inputs, then
|
|
171
|
+
pass the completed JSON to `create_invoice`. It is not the full invoice JSON
|
|
172
|
+
accepted by CLI `submit`.
|
|
125
173
|
|
|
126
174
|
**Parameters:**
|
|
127
175
|
|
|
@@ -149,4 +197,10 @@ Generate a draft invoice template with sensible defaults. Returns JSON that can
|
|
|
149
197
|
|
|
150
198
|
## Full Documentation
|
|
151
199
|
|
|
152
|
-
See the [
|
|
200
|
+
See the [MCP reference](https://github.com/DojoCodingLabs/hacienda-cr/blob/main/docs/reference.md#mcp-server--integración-con-ia),
|
|
201
|
+
[sandbox walkthrough](https://github.com/DojoCodingLabs/hacienda-cr/blob/main/docs/sandbox-guide.md), and
|
|
202
|
+
[production integration guide](https://github.com/DojoCodingLabs/hacienda-cr/blob/main/docs/production-integration.md).
|
|
203
|
+
|
|
204
|
+
## Migrating to 0.4.0
|
|
205
|
+
|
|
206
|
+
Read the [migration guide](https://github.com/DojoCodingLabs/hacienda-cr/blob/main/packages/sdk/MIGRATION-v4.4.md) before upgrading.
|