@frihet/mcp-server 1.6.1 → 1.9.0-beta.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.
Files changed (77) hide show
  1. package/README.md +19 -6
  2. package/dist/__tests__/banking-tools.test.d.ts +18 -0
  3. package/dist/__tests__/banking-tools.test.d.ts.map +1 -0
  4. package/dist/__tests__/banking-tools.test.js +252 -0
  5. package/dist/__tests__/banking-tools.test.js.map +1 -0
  6. package/dist/__tests__/einvoice-integration.test.d.ts +24 -0
  7. package/dist/__tests__/einvoice-integration.test.d.ts.map +1 -0
  8. package/dist/__tests__/einvoice-integration.test.js +142 -0
  9. package/dist/__tests__/einvoice-integration.test.js.map +1 -0
  10. package/dist/__tests__/einvoice-tools.test.d.ts +16 -0
  11. package/dist/__tests__/einvoice-tools.test.d.ts.map +1 -0
  12. package/dist/__tests__/einvoice-tools.test.js +435 -0
  13. package/dist/__tests__/einvoice-tools.test.js.map +1 -0
  14. package/dist/__tests__/fiscal-tools.test.d.ts +20 -0
  15. package/dist/__tests__/fiscal-tools.test.d.ts.map +1 -0
  16. package/dist/__tests__/fiscal-tools.test.js +233 -0
  17. package/dist/__tests__/fiscal-tools.test.js.map +1 -0
  18. package/dist/__tests__/pos-tools.test.d.ts +16 -0
  19. package/dist/__tests__/pos-tools.test.d.ts.map +1 -0
  20. package/dist/__tests__/pos-tools.test.js +244 -0
  21. package/dist/__tests__/pos-tools.test.js.map +1 -0
  22. package/dist/__tests__/recurring-tools.test.d.ts +16 -0
  23. package/dist/__tests__/recurring-tools.test.d.ts.map +1 -0
  24. package/dist/__tests__/recurring-tools.test.js +166 -0
  25. package/dist/__tests__/recurring-tools.test.js.map +1 -0
  26. package/dist/__tests__/stay-tools.test.d.ts +17 -0
  27. package/dist/__tests__/stay-tools.test.d.ts.map +1 -0
  28. package/dist/__tests__/stay-tools.test.js +259 -0
  29. package/dist/__tests__/stay-tools.test.js.map +1 -0
  30. package/dist/__tests__/time-tools.test.d.ts +17 -0
  31. package/dist/__tests__/time-tools.test.d.ts.map +1 -0
  32. package/dist/__tests__/time-tools.test.js +199 -0
  33. package/dist/__tests__/time-tools.test.js.map +1 -0
  34. package/dist/client-interface.d.ts +131 -0
  35. package/dist/client-interface.d.ts.map +1 -1
  36. package/dist/client.d.ts +131 -0
  37. package/dist/client.d.ts.map +1 -1
  38. package/dist/client.js +159 -0
  39. package/dist/client.js.map +1 -1
  40. package/dist/index.js +0 -0
  41. package/dist/tools/banking.d.ts +19 -0
  42. package/dist/tools/banking.d.ts.map +1 -0
  43. package/dist/tools/banking.js +155 -0
  44. package/dist/tools/banking.js.map +1 -0
  45. package/dist/tools/einvoice.d.ts +92 -0
  46. package/dist/tools/einvoice.d.ts.map +1 -0
  47. package/dist/tools/einvoice.js +400 -0
  48. package/dist/tools/einvoice.js.map +1 -0
  49. package/dist/tools/fiscal.d.ts +22 -0
  50. package/dist/tools/fiscal.d.ts.map +1 -0
  51. package/dist/tools/fiscal.js +215 -0
  52. package/dist/tools/fiscal.js.map +1 -0
  53. package/dist/tools/pos.d.ts +15 -0
  54. package/dist/tools/pos.d.ts.map +1 -0
  55. package/dist/tools/pos.js +156 -0
  56. package/dist/tools/pos.js.map +1 -0
  57. package/dist/tools/recurring.d.ts +16 -0
  58. package/dist/tools/recurring.d.ts.map +1 -0
  59. package/dist/tools/recurring.js +67 -0
  60. package/dist/tools/recurring.js.map +1 -0
  61. package/dist/tools/register-all.d.ts +2 -2
  62. package/dist/tools/register-all.d.ts.map +1 -1
  63. package/dist/tools/register-all.js +16 -2
  64. package/dist/tools/register-all.js.map +1 -1
  65. package/dist/tools/shared.d.ts +169 -0
  66. package/dist/tools/shared.d.ts.map +1 -1
  67. package/dist/tools/shared.js +140 -0
  68. package/dist/tools/shared.js.map +1 -1
  69. package/dist/tools/stay.d.ts +6 -78
  70. package/dist/tools/stay.d.ts.map +1 -1
  71. package/dist/tools/stay.js +121 -343
  72. package/dist/tools/stay.js.map +1 -1
  73. package/dist/tools/time.d.ts +18 -0
  74. package/dist/tools/time.d.ts.map +1 -0
  75. package/dist/tools/time.js +134 -0
  76. package/dist/tools/time.js.map +1 -0
  77. package/package.json +3 -2
@@ -0,0 +1,400 @@
1
+ /**
2
+ * E-Invoicing tools for the Frihet MCP server.
3
+ *
4
+ * Wired to real CF endpoints at api.frihet.io/v1/einvoice/*.
5
+ * 404-fallback: if the CF endpoint is not yet deployed, returns a stub with
6
+ * { _stub: true, _note: "CF endpoint pending deploy", _plannedEndpoint: "..." }
7
+ * so the MCP server remains usable while the transport Wave ships.
8
+ *
9
+ * All 4 tools use the shared withToolLogging wrapper (Langfuse tracing applied
10
+ * globally via patchServerWithTracing in register-all.ts).
11
+ *
12
+ * Trace names prefix: mcp.einvoice.*
13
+ * CF endpoints: https://api.frihet.io/v1/einvoice/{send,status,validate,export-datev}
14
+ */
15
+ import { z } from "zod/v4";
16
+ import { withToolLogging, mutateContent, getContent, READ_ONLY_ANNOTATIONS, CREATE_ANNOTATIONS, } from "./shared.js";
17
+ /* ------------------------------------------------------------------ */
18
+ /* Shared format union */
19
+ /* ------------------------------------------------------------------ */
20
+ /**
21
+ * All supported e-invoice formats.
22
+ *
23
+ * | Format | Standard | Markets | Notes |
24
+ * |-------------------------|-----------|--------------------------|---------------------------------------------------|
25
+ * | xrechnung-cii | EN16931 | Germany (DE mandatory) | CII syntax, official DE B2G format |
26
+ * | xrechnung-ubl | EN16931 | Germany (DE mandatory) | UBL 2.1 syntax, alternative DE B2G |
27
+ * | facturx-en16931 | EN16931 | France, EU | PDF/A-3 embedded XML, Factur-X EN16931 profile |
28
+ * | facturx-extended | EN16931+ | France, EU | Factur-X Extended — extra logistics/trade fields |
29
+ * | facturx-basic | EN16931 | France, EU | Factur-X Basic — reduced field set |
30
+ * | facturx-minimum | EN16931 | France, EU | Factur-X Minimum — summary invoices only |
31
+ * | fatturapa | SDI | Italy (IT mandatory) | XML FatturaPA — sent via SDI interchange hub |
32
+ * | ubl | UBL 2.1 | EU/global | Generic UBL — use when no country-specific needed |
33
+ * | cii | UN/CEFACT | EU/global | Generic CII — Cross Industry Invoice XML |
34
+ * | peppol-bis-3 | PEPPOL | EU/Nordic/AU/SG | PEPPOL BIS Billing 3.0 — B2B/B2G network |
35
+ * | facturae | Facturae | Spain (ES B2G mandatory) | Facturae 3.2.x — AEAT/FACe submission |
36
+ */
37
+ export const eInvoiceFormatSchema = z.enum([
38
+ "xrechnung-cii",
39
+ "xrechnung-ubl",
40
+ "facturx-en16931",
41
+ "facturx-extended",
42
+ "facturx-basic",
43
+ "facturx-minimum",
44
+ "fatturapa",
45
+ "ubl",
46
+ "cii",
47
+ "peppol-bis-3",
48
+ "facturae",
49
+ ]);
50
+ /* ------------------------------------------------------------------ */
51
+ /* Output schemas */
52
+ /* ------------------------------------------------------------------ */
53
+ export const sendEInvoiceOutput = z.object({
54
+ workflowRunId: z.string().describe("Hatchet workflow run ID for polling status"),
55
+ status: z.literal("queued").describe("Always 'queued' for async dispatch"),
56
+ estimatedCompletionSec: z.number().describe("Estimated seconds until the workflow completes"),
57
+ }).passthrough();
58
+ export const eInvoiceStatusOutput = z.object({
59
+ status: z.enum(["queued", "running", "succeeded", "failed", "cancelled"]),
60
+ step: z.string().describe("Current or last workflow step name"),
61
+ error: z.string().optional().describe("Error message if status is 'failed'"),
62
+ ackId: z.string().optional().describe("Network acknowledgement ID (PEPPOL SBDH / SDI protocol ID / etc.)"),
63
+ pdfA3Url: z.string().optional().describe("Signed URL to download the PDF/A-3 envelope (Factur-X only)"),
64
+ xmlUrl: z.string().optional().describe("Signed URL to download the raw XML file"),
65
+ }).passthrough();
66
+ export const validateEInvoiceOutput = z.object({
67
+ valid: z.boolean().describe("Whether the XML passes all validation rules"),
68
+ errors: z.array(z.object({
69
+ severity: z.string().describe("'error' | 'warning' | 'info'"),
70
+ location: z.string().describe("XPath or element path where the issue was found"),
71
+ message: z.string().describe("Human-readable validation message"),
72
+ rule: z.string().describe("Rule ID (e.g. 'BR-01', 'PEPPOL-EN16931-R001')"),
73
+ })).describe("List of validation findings (empty if valid)"),
74
+ validator: z.enum(["kosit", "mustang", "xsd", "schematron"]).describe("Validation engine used"),
75
+ durationMs: z.number().describe("Validation duration in milliseconds"),
76
+ }).passthrough();
77
+ export const exportDatevOutput = z.object({
78
+ fileUrl: z.string().describe("Signed URL to download the DATEV EXTF file"),
79
+ filename: z.string().describe("Suggested filename (e.g. EXTF_Buchungsstapel_2026-01.csv)"),
80
+ rowCount: z.number().describe("Number of accounting rows in the export"),
81
+ fiscalPeriod: z.string().describe("Fiscal period covered (e.g. '2026-01' or '2026-Q1')"),
82
+ encoding: z.literal("cp1252").describe("File encoding — always CP1252 per DATEV EXTF spec"),
83
+ }).passthrough();
84
+ /* ------------------------------------------------------------------ */
85
+ /* Tool registration */
86
+ /* ------------------------------------------------------------------ */
87
+ export function registerEInvoiceTools(server, _client) {
88
+ // -- send_einvoice --
89
+ server.registerTool("send_einvoice", {
90
+ title: "Send E-Invoice",
91
+ description: "Dispatch an e-invoice to the recipient via the selected transport channel. " +
92
+ "Returns immediately with a workflowRunId — use get_einvoice_status to poll until completion. " +
93
+ "\n\n" +
94
+ "Supported formats (11 total):\n" +
95
+ " • xrechnung-cii — XRechnung CII syntax (Germany B2G mandatory)\n" +
96
+ " • xrechnung-ubl — XRechnung UBL 2.1 syntax (Germany B2G alternative)\n" +
97
+ " • facturx-en16931 — Factur-X EN16931 PDF/A-3 (France, EU)\n" +
98
+ " • facturx-extended — Factur-X Extended with trade/logistics fields (France, EU)\n" +
99
+ " • facturx-basic — Factur-X Basic reduced field set (France, EU)\n" +
100
+ " • facturx-minimum — Factur-X Minimum for summary invoices (France, EU)\n" +
101
+ " • fatturapa — FatturaPA XML via SDI hub (Italy mandatory)\n" +
102
+ " • ubl — Generic UBL 2.1 XML (EU/global)\n" +
103
+ " • cii — Generic CII Cross Industry Invoice (EU/global)\n" +
104
+ " • peppol-bis-3 — PEPPOL BIS Billing 3.0 network (EU/Nordic/AU/SG)\n" +
105
+ " • facturae — Facturae 3.2.x (Spain B2G via FACe/AEAT mandatory)\n" +
106
+ "\n" +
107
+ "Dispatch modes:\n" +
108
+ " • email — attach XML/PDF and send via Resend to client email on file\n" +
109
+ " • chorus_pro — submit to French Chorus Pro portal (facturx-* only)\n" +
110
+ " • sdi — submit to Italian SDI hub (fatturapa only)\n" +
111
+ " • peppol — transmit via PEPPOL access point (peppol-bis-3 only)\n" +
112
+ " • download — generate and return a signed download URL only\n" +
113
+ "\n" +
114
+ "NOTE: Stub response — real CF endpoint https://api.frihet.io/v1/einvoice/send wired in transport Wave. " +
115
+ "/ Envia una factura electronica al destinatario mediante el canal de transporte seleccionado. " +
116
+ "Devuelve de forma asincrona — consultar get_einvoice_status para seguimiento.",
117
+ annotations: CREATE_ANNOTATIONS,
118
+ inputSchema: {
119
+ invoiceId: z.string().describe("Frihet invoice ID to dispatch / ID de la factura a enviar"),
120
+ format: eInvoiceFormatSchema.describe("E-invoice format. Choose based on recipient country and channel: " +
121
+ "DE→xrechnung-cii/ubl, FR→facturx-*, IT→fatturapa, ES B2G→facturae, EU PEPPOL→peppol-bis-3, " +
122
+ "generic→ubl or cii / Formato de factura electronica."),
123
+ dispatchMode: z.enum(["email", "chorus_pro", "sdi", "peppol", "download"]).describe("Transport channel: email=send via Resend, chorus_pro=French portal, sdi=Italian SDI hub, " +
124
+ "peppol=PEPPOL network, download=generate URL only / Canal de transporte."),
125
+ },
126
+ outputSchema: sendEInvoiceOutput,
127
+ }, async ({ invoiceId, format, dispatchMode }) => withToolLogging("send_einvoice", async () => {
128
+ const plannedEndpoint = "/v1/einvoice/send";
129
+ try {
130
+ const result = await _client.sendEInvoice({ invoiceId, format, dispatchMode });
131
+ return {
132
+ content: [
133
+ mutateContent(`E-invoice queued:\n` +
134
+ ` Invoice: ${invoiceId}\n` +
135
+ ` Format: ${format}\n` +
136
+ ` Dispatch: ${dispatchMode}\n` +
137
+ ` WorkflowRunId: ${result.workflowRunId}\n` +
138
+ ` Status: ${result.status}\n` +
139
+ ` Estimated: ~${result.estimatedCompletionSec}s\n\n` +
140
+ `Use get_einvoice_status with the workflowRunId to poll for completion.`),
141
+ ],
142
+ structuredContent: result,
143
+ };
144
+ }
145
+ catch (err) {
146
+ if (isNotFoundError(err)) {
147
+ const stubResult = {
148
+ workflowRunId: `wfr_stub_${Date.now()}`,
149
+ status: "queued",
150
+ estimatedCompletionSec: 15,
151
+ _stub: true,
152
+ _note: "CF endpoint pending deploy",
153
+ _plannedEndpoint: plannedEndpoint,
154
+ };
155
+ return {
156
+ content: [
157
+ mutateContent(`E-invoice queued (stub — CF pending deploy):\n` +
158
+ ` Invoice: ${invoiceId}\n` +
159
+ ` Format: ${format}\n` +
160
+ ` Dispatch: ${dispatchMode}\n` +
161
+ ` WorkflowRunId: ${stubResult.workflowRunId}\n` +
162
+ ` Status: queued\n` +
163
+ ` Estimated: ~${stubResult.estimatedCompletionSec}s\n\n` +
164
+ `Use get_einvoice_status with the workflowRunId to poll for completion.`),
165
+ ],
166
+ structuredContent: stubResult,
167
+ };
168
+ }
169
+ throw err;
170
+ }
171
+ }));
172
+ // -- get_einvoice_status --
173
+ server.registerTool("get_einvoice_status", {
174
+ title: "Get E-Invoice Status",
175
+ description: "Poll the status of an e-invoice dispatch workflow. " +
176
+ "Returns current step, ack ID (network confirmation), and download URLs once complete. " +
177
+ "Poll every 5–10 seconds until status is 'succeeded', 'failed', or 'cancelled'. " +
178
+ "\n\n" +
179
+ "NOTE: Stub response — real CF endpoint https://api.frihet.io/v1/einvoice/status wired in transport Wave. " +
180
+ "/ Consulta el estado de un flujo de envio de factura electronica.",
181
+ annotations: READ_ONLY_ANNOTATIONS,
182
+ inputSchema: {
183
+ workflowRunId: z.string().describe("Hatchet workflow run ID returned by send_einvoice / ID del run de workflow"),
184
+ },
185
+ outputSchema: eInvoiceStatusOutput,
186
+ }, async ({ workflowRunId }) => withToolLogging("get_einvoice_status", async () => {
187
+ const plannedEndpoint = `/v1/einvoice/status/${workflowRunId}`;
188
+ try {
189
+ const result = await _client.getEInvoiceStatus(workflowRunId);
190
+ return {
191
+ content: [
192
+ getContent(`E-invoice status:\n` +
193
+ ` WorkflowRunId: ${workflowRunId}\n` +
194
+ ` Status: ${result.status}\n` +
195
+ ` Step: ${result.step}\n` +
196
+ (result.ackId ? ` AckId: ${result.ackId}\n` : "") +
197
+ (result.xmlUrl ? ` XML URL: ${result.xmlUrl}\n` : "") +
198
+ (result.pdfA3Url ? ` PDF/A-3 URL: ${result.pdfA3Url}\n` : "")),
199
+ ],
200
+ structuredContent: result,
201
+ };
202
+ }
203
+ catch (err) {
204
+ if (isNotFoundError(err)) {
205
+ const stubResult = {
206
+ status: "succeeded",
207
+ step: "dispatch_complete",
208
+ ackId: `ack_stub_${workflowRunId.slice(-8)}`,
209
+ pdfA3Url: undefined,
210
+ xmlUrl: `https://storage.frihet.io/stub/${workflowRunId}.xml`,
211
+ _stub: true,
212
+ _note: "CF endpoint pending deploy",
213
+ _plannedEndpoint: plannedEndpoint,
214
+ };
215
+ return {
216
+ content: [
217
+ getContent(`E-invoice status (stub — CF pending deploy):\n` +
218
+ ` WorkflowRunId: ${workflowRunId}\n` +
219
+ ` Status: ${stubResult.status}\n` +
220
+ ` Step: ${stubResult.step}\n` +
221
+ ` AckId: ${stubResult.ackId}\n` +
222
+ ` XML URL: ${stubResult.xmlUrl}`),
223
+ ],
224
+ structuredContent: stubResult,
225
+ };
226
+ }
227
+ throw err;
228
+ }
229
+ }));
230
+ // -- validate_einvoice_xml --
231
+ server.registerTool("validate_einvoice_xml", {
232
+ title: "Validate E-Invoice XML",
233
+ description: "Validate an e-invoice XML document against the specified format's schema and schematron rules. " +
234
+ "Returns a list of errors with severity, XPath location, message, and rule ID. " +
235
+ "Runs KOSIT validator (XRechnung), Mustang (EN16931), XSD, or Schematron depending on format. " +
236
+ "\n\n" +
237
+ "Use before dispatch to catch errors early without incurring network transmission costs. " +
238
+ "A valid=true response means the document passes all schema + business rule checks. " +
239
+ "\n\n" +
240
+ "NOTE: Stub response — real CF endpoint https://api.frihet.io/v1/einvoice/validate wired in transport Wave. " +
241
+ "/ Valida un documento XML de factura electronica contra el esquema y reglas schematron del formato especificado.",
242
+ annotations: READ_ONLY_ANNOTATIONS,
243
+ inputSchema: {
244
+ xml: z.string().describe("Raw XML string of the e-invoice document to validate / Contenido XML de la factura electronica"),
245
+ format: eInvoiceFormatSchema.describe("Format to validate against. Determines which validator and ruleset to apply. " +
246
+ "/ Formato a validar. Determina el validador y conjunto de reglas a aplicar."),
247
+ },
248
+ outputSchema: validateEInvoiceOutput,
249
+ }, async ({ xml, format }) => withToolLogging("validate_einvoice_xml", async () => {
250
+ const plannedEndpoint = "/v1/einvoice/validate";
251
+ const validatorMap = {
252
+ "xrechnung-cii": "kosit",
253
+ "xrechnung-ubl": "kosit",
254
+ "facturx-en16931": "mustang",
255
+ "facturx-extended": "mustang",
256
+ "facturx-basic": "mustang",
257
+ "facturx-minimum": "mustang",
258
+ "fatturapa": "xsd",
259
+ "ubl": "schematron",
260
+ "cii": "schematron",
261
+ "peppol-bis-3": "schematron",
262
+ "facturae": "xsd",
263
+ };
264
+ try {
265
+ const result = await _client.validateEInvoiceXml({ xml, format });
266
+ return {
267
+ content: [
268
+ getContent(`E-invoice validation result:\n` +
269
+ ` Format: ${format}\n` +
270
+ ` Valid: ${result.valid}\n` +
271
+ ` Errors: ${result.errors.length}\n` +
272
+ ` Validator: ${result.validator}\n` +
273
+ ` Duration: ${result.durationMs}ms`),
274
+ ],
275
+ structuredContent: result,
276
+ };
277
+ }
278
+ catch (err) {
279
+ if (isNotFoundError(err)) {
280
+ const stubResult = {
281
+ valid: true,
282
+ errors: [],
283
+ validator: validatorMap[format],
284
+ durationMs: 42,
285
+ _stub: true,
286
+ _note: "CF endpoint pending deploy",
287
+ _plannedEndpoint: plannedEndpoint,
288
+ };
289
+ return {
290
+ content: [
291
+ getContent(`E-invoice validation result (stub — CF pending deploy):\n` +
292
+ ` Format: ${format}\n` +
293
+ ` Valid: ${stubResult.valid}\n` +
294
+ ` Errors: ${stubResult.errors.length}\n` +
295
+ ` Validator: ${stubResult.validator}\n` +
296
+ ` Duration: ${stubResult.durationMs}ms`),
297
+ ],
298
+ structuredContent: stubResult,
299
+ };
300
+ }
301
+ throw err;
302
+ }
303
+ }));
304
+ // -- export_datev --
305
+ server.registerTool("export_datev", {
306
+ title: "Export DATEV",
307
+ description: "Export accounting data in DATEV EXTF format for import into DATEV Kanzlei-Rechnungswesen or compatible systems. " +
308
+ "Returns a signed download URL valid for 24 hours. " +
309
+ "\n\n" +
310
+ "Supported EXTF formats:\n" +
311
+ " • extf-buchungsstapel — Journal entries (Buchungsstapel) — most common, use for P&L/tax\n" +
312
+ " • extf-debitoren — Accounts receivable master data (Debitoren-/Kreditorenstamm AR)\n" +
313
+ " • extf-kreditoren — Accounts payable master data (Debitoren-/Kreditorenstamm AP)\n" +
314
+ "\n" +
315
+ "Output encoding is always CP1252 per DATEV EXTF specification. " +
316
+ "Date range: both periodStart and periodEnd must be ISO 8601 dates (YYYY-MM-DD). " +
317
+ "\n\n" +
318
+ "NOTE: Stub response — real CF endpoint https://api.frihet.io/v1/datev/export wired in transport Wave. " +
319
+ "/ Exporta datos contables en formato DATEV EXTF para importacion en DATEV o sistemas compatibles.",
320
+ annotations: READ_ONLY_ANNOTATIONS,
321
+ inputSchema: {
322
+ periodStart: z.string().describe("Start of the export period (ISO 8601 YYYY-MM-DD). Inclusive. " +
323
+ "/ Inicio del periodo de exportacion (YYYY-MM-DD). Inclusivo."),
324
+ periodEnd: z.string().describe("End of the export period (ISO 8601 YYYY-MM-DD). Inclusive. " +
325
+ "/ Fin del periodo de exportacion (YYYY-MM-DD). Inclusivo."),
326
+ format: z.enum(["extf-buchungsstapel", "extf-debitoren", "extf-kreditoren"]).describe("DATEV EXTF export format: extf-buchungsstapel (journal entries), " +
327
+ "extf-debitoren (AR master), extf-kreditoren (AP master) / Formato EXTF de DATEV."),
328
+ },
329
+ outputSchema: exportDatevOutput,
330
+ }, async ({ periodStart, periodEnd, format }) => withToolLogging("export_datev", async () => {
331
+ const plannedEndpoint = "/v1/einvoice/export-datev";
332
+ const formatFileMap = {
333
+ "extf-buchungsstapel": "EXTF_Buchungsstapel",
334
+ "extf-debitoren": "EXTF_Debitoren",
335
+ "extf-kreditoren": "EXTF_Kreditoren",
336
+ };
337
+ const periodLabel = periodStart.slice(0, 7); // YYYY-MM
338
+ try {
339
+ const result = await _client.exportDatev({ periodStart, periodEnd, format });
340
+ return {
341
+ content: [
342
+ getContent(`DATEV export ready:\n` +
343
+ ` Format: ${format}\n` +
344
+ ` Period: ${periodStart} → ${periodEnd}\n` +
345
+ ` Filename: ${result.filename}\n` +
346
+ ` Rows: ${result.rowCount}\n` +
347
+ ` Encoding: ${result.encoding}\n` +
348
+ ` Download URL: ${result.fileUrl}`),
349
+ ],
350
+ structuredContent: result,
351
+ };
352
+ }
353
+ catch (err) {
354
+ if (isNotFoundError(err)) {
355
+ const filename = `${formatFileMap[format]}_${periodLabel}.csv`;
356
+ const stubResult = {
357
+ fileUrl: `https://storage.frihet.io/stub/datev/${filename}`,
358
+ filename,
359
+ rowCount: 0,
360
+ fiscalPeriod: periodLabel,
361
+ encoding: "cp1252",
362
+ _stub: true,
363
+ _note: "CF endpoint pending deploy",
364
+ _plannedEndpoint: plannedEndpoint,
365
+ };
366
+ return {
367
+ content: [
368
+ getContent(`DATEV export ready (stub — CF pending deploy):\n` +
369
+ ` Format: ${format}\n` +
370
+ ` Period: ${periodStart} → ${periodEnd}\n` +
371
+ ` Filename: ${stubResult.filename}\n` +
372
+ ` Rows: ${stubResult.rowCount}\n` +
373
+ ` Encoding: ${stubResult.encoding}\n` +
374
+ ` Download URL: ${stubResult.fileUrl}`),
375
+ ],
376
+ structuredContent: stubResult,
377
+ };
378
+ }
379
+ throw err;
380
+ }
381
+ }));
382
+ }
383
+ /* ------------------------------------------------------------------ */
384
+ /* Helpers */
385
+ /* ------------------------------------------------------------------ */
386
+ /**
387
+ * Returns true if the error is a 404 Not Found, indicating the CF endpoint
388
+ * is not yet deployed. Detects both FrihetApiError shape and generic HTTP errors.
389
+ */
390
+ function isNotFoundError(err) {
391
+ if (err && typeof err === "object") {
392
+ const e = err;
393
+ if (e["statusCode"] === 404)
394
+ return true;
395
+ if (e["status"] === 404)
396
+ return true;
397
+ }
398
+ return false;
399
+ }
400
+ //# sourceMappingURL=einvoice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"einvoice.js","sourceRoot":"","sources":["../../src/tools/einvoice.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EACL,eAAe,EACf,aAAa,EACb,UAAU,EACV,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,wEAAwE;AACxE,0EAA0E;AAC1E,wEAAwE;AAExE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC;IACzC,eAAe;IACf,eAAe;IACf,iBAAiB;IACjB,kBAAkB;IAClB,eAAe;IACf,iBAAiB;IACjB,WAAW;IACX,KAAK;IACL,KAAK;IACL,cAAc;IACd,UAAU;CACX,CAAC,CAAC;AAIH,wEAAwE;AACxE,0EAA0E;AAC1E,wEAAwE;AAExE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4CAA4C,CAAC;IAChF,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,oCAAoC,CAAC;IAC1E,sBAAsB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gDAAgD,CAAC;CAC9F,CAAC,CAAC,WAAW,EAAE,CAAC;AAEjB,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CA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C/D,MAAM,UAAU,GAAG;oBACjB,OAAO,EAAE,wCAAwC,QAAQ,EAAE;oBAC3D,QAAQ;oBACR,QAAQ,EAAE,CAAC;oBACX,YAAY,EAAE,WAAW;oBACzB,QAAQ,EAAE,QAAiB;oBAC3B,KAAK,EAAE,IAAI;oBACX,KAAK,EAAE,4BAA4B;oBACnC,gBAAgB,EAAE,eAAe;iBAClC,CAAC;gBACF,OAAO;oBACL,OAAO,EAAE;wBACP,UAAU,CACR,kDAAkD;4BAClD,aAAa,MAAM,IAAI;4BACvB,aAAa,WAAW,MAAM,SAAS,IAAI;4BAC3C,eAAe,UAAU,CAAC,QAAQ,IAAI;4BACtC,WAAW,UAAU,CAAC,QAAQ,IAAI;4BAClC,eAAe,UAAU,CAAC,QAAQ,IAAI;4BACtC,mBAAmB,UAAU,CAAC,OAAO,EAAE,CACxC;qBACF;oBACD,iBAAiB,EAAE,UAAgD;iBACpE,CAAC;YACJ,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC,CAAC,CACL,CAAC;AACJ,CAAC;AAED,wEAAwE;AACxE,0EAA0E;AAC1E,wEAAwE;AAExE;;;GAGG;AACH,SAAS,eAAe,CAAC,GAAY;IACnC,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACnC,MAAM,CAAC,GAAG,GAA8B,CAAC;QACzC,IAAI,CAAC,CAAC,YAAY,CAAC,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;QACzC,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,GAAG;YAAE,OAAO,IAAI,CAAC;IACvC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Fiscal tools for the Frihet MCP server — Wave 6 (8 tools).
3
+ *
4
+ * Tools:
5
+ * 1. get_modelo_303_summary — IVA quarterly Spain
6
+ * 2. get_modelo_130_summary — IRPF estimated payment Spain
7
+ * 3. get_modelo_390_summary — IVA annual recap Spain
8
+ * 4. get_modelo_180_summary — IRPF rentals annual Spain
9
+ * 5. get_modelo_347_summary — Operations >€3005 annual third-party recap
10
+ * 6. verifactu_status — VeriFactu submission status for an invoice
11
+ * 7. verifactu_resubmit — Re-submit a failed VeriFactu submission (TRUST AREA)
12
+ * 8. ticketbai_status — Basque Country e-invoicing status
13
+ *
14
+ * REST surface: /v1/fiscal/* (documented: pending — backend ships separately)
15
+ *
16
+ * NOTE: ERP backend endpoints /v1/fiscal/* are planned. Tools are wired
17
+ * and will surface 404 errors until the backend ships.
18
+ */
19
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
20
+ import type { IFrihetClient } from "../client-interface.js";
21
+ export declare function registerFiscalTools(server: McpServer, client: IFrihetClient): void;
22
+ //# sourceMappingURL=fiscal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fiscal.d.ts","sourceRoot":"","sources":["../../src/tools/fiscal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAY5D,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAwPlF"}