@frihet/mcp-server 1.7.0-beta.1 → 1.12.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.
- package/README.md +262 -12
- package/dist/__tests__/banking-tools.test.d.ts +18 -0
- package/dist/__tests__/banking-tools.test.d.ts.map +1 -0
- package/dist/__tests__/banking-tools.test.js +252 -0
- package/dist/__tests__/banking-tools.test.js.map +1 -0
- package/dist/__tests__/d4b-hr-payroll-onboarding-tools.test.d.ts +13 -0
- package/dist/__tests__/d4b-hr-payroll-onboarding-tools.test.d.ts.map +1 -0
- package/dist/__tests__/d4b-hr-payroll-onboarding-tools.test.js +420 -0
- package/dist/__tests__/d4b-hr-payroll-onboarding-tools.test.js.map +1 -0
- package/dist/__tests__/einvoice-day4-tools.test.d.ts +16 -0
- package/dist/__tests__/einvoice-day4-tools.test.d.ts.map +1 -0
- package/dist/__tests__/einvoice-day4-tools.test.js +377 -0
- package/dist/__tests__/einvoice-day4-tools.test.js.map +1 -0
- package/dist/__tests__/einvoice-tools.test.d.ts +1 -1
- package/dist/__tests__/einvoice-tools.test.js +25 -12
- package/dist/__tests__/einvoice-tools.test.js.map +1 -1
- package/dist/__tests__/fiscal-tools.test.d.ts +21 -0
- package/dist/__tests__/fiscal-tools.test.d.ts.map +1 -0
- package/dist/__tests__/fiscal-tools.test.js +215 -0
- package/dist/__tests__/fiscal-tools.test.js.map +1 -0
- package/dist/__tests__/pos-tools.test.d.ts +16 -0
- package/dist/__tests__/pos-tools.test.d.ts.map +1 -0
- package/dist/__tests__/pos-tools.test.js +244 -0
- package/dist/__tests__/pos-tools.test.js.map +1 -0
- package/dist/__tests__/recurring-tools.test.d.ts +23 -0
- package/dist/__tests__/recurring-tools.test.d.ts.map +1 -0
- package/dist/__tests__/recurring-tools.test.js +352 -0
- package/dist/__tests__/recurring-tools.test.js.map +1 -0
- package/dist/__tests__/stay-tools.test.d.ts +17 -0
- package/dist/__tests__/stay-tools.test.d.ts.map +1 -0
- package/dist/__tests__/stay-tools.test.js +259 -0
- package/dist/__tests__/stay-tools.test.js.map +1 -0
- package/dist/__tests__/team-tools.test.d.ts +18 -0
- package/dist/__tests__/team-tools.test.d.ts.map +1 -0
- package/dist/__tests__/team-tools.test.js +228 -0
- package/dist/__tests__/team-tools.test.js.map +1 -0
- package/dist/__tests__/time-tools.test.d.ts +19 -0
- package/dist/__tests__/time-tools.test.d.ts.map +1 -0
- package/dist/__tests__/time-tools.test.js +286 -0
- package/dist/__tests__/time-tools.test.js.map +1 -0
- package/dist/client-interface.d.ts +325 -0
- package/dist/client-interface.d.ts.map +1 -1
- package/dist/client.d.ts +325 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +404 -0
- package/dist/client.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/tools/accountingClose.d.ts +20 -0
- package/dist/tools/accountingClose.d.ts.map +1 -0
- package/dist/tools/accountingClose.js +119 -0
- package/dist/tools/accountingClose.js.map +1 -0
- package/dist/tools/audit_gl.d.ts +19 -0
- package/dist/tools/audit_gl.d.ts.map +1 -0
- package/dist/tools/audit_gl.js +86 -0
- package/dist/tools/audit_gl.js.map +1 -0
- package/dist/tools/bank_rules.d.ts +23 -0
- package/dist/tools/bank_rules.d.ts.map +1 -0
- package/dist/tools/bank_rules.js +96 -0
- package/dist/tools/bank_rules.js.map +1 -0
- package/dist/tools/banking.d.ts +19 -0
- package/dist/tools/banking.d.ts.map +1 -0
- package/dist/tools/banking.js +155 -0
- package/dist/tools/banking.js.map +1 -0
- package/dist/tools/einvoice.d.ts +70 -3
- package/dist/tools/einvoice.d.ts.map +1 -1
- package/dist/tools/einvoice.js +421 -3
- package/dist/tools/einvoice.js.map +1 -1
- package/dist/tools/fiscal.d.ts +23 -0
- package/dist/tools/fiscal.d.ts.map +1 -0
- package/dist/tools/fiscal.js +197 -0
- package/dist/tools/fiscal.js.map +1 -0
- package/dist/tools/gestoria.d.ts +28 -0
- package/dist/tools/gestoria.d.ts.map +1 -0
- package/dist/tools/gestoria.js +248 -0
- package/dist/tools/gestoria.js.map +1 -0
- package/dist/tools/hr.d.ts +24 -0
- package/dist/tools/hr.d.ts.map +1 -0
- package/dist/tools/hr.js +219 -0
- package/dist/tools/hr.js.map +1 -0
- package/dist/tools/igic.d.ts +19 -0
- package/dist/tools/igic.d.ts.map +1 -0
- package/dist/tools/igic.js +102 -0
- package/dist/tools/igic.js.map +1 -0
- package/dist/tools/impuesto_sociedades.d.ts +18 -0
- package/dist/tools/impuesto_sociedades.d.ts.map +1 -0
- package/dist/tools/impuesto_sociedades.js +64 -0
- package/dist/tools/impuesto_sociedades.js.map +1 -0
- package/dist/tools/onboard_vies.d.ts +22 -0
- package/dist/tools/onboard_vies.d.ts.map +1 -0
- package/dist/tools/onboard_vies.js +74 -0
- package/dist/tools/onboard_vies.js.map +1 -0
- package/dist/tools/onboarding.d.ts +19 -0
- package/dist/tools/onboarding.d.ts.map +1 -0
- package/dist/tools/onboarding.js +63 -0
- package/dist/tools/onboarding.js.map +1 -0
- package/dist/tools/payroll.d.ts +20 -0
- package/dist/tools/payroll.d.ts.map +1 -0
- package/dist/tools/payroll.js +73 -0
- package/dist/tools/payroll.js.map +1 -0
- package/dist/tools/permissions.d.ts +19 -0
- package/dist/tools/permissions.d.ts.map +1 -0
- package/dist/tools/permissions.js +52 -0
- package/dist/tools/permissions.js.map +1 -0
- package/dist/tools/portal_domain.d.ts +19 -0
- package/dist/tools/portal_domain.d.ts.map +1 -0
- package/dist/tools/portal_domain.js +85 -0
- package/dist/tools/portal_domain.js.map +1 -0
- package/dist/tools/pos.d.ts +15 -0
- package/dist/tools/pos.d.ts.map +1 -0
- package/dist/tools/pos.js +156 -0
- package/dist/tools/pos.js.map +1 -0
- package/dist/tools/recurring.d.ts +21 -0
- package/dist/tools/recurring.d.ts.map +1 -0
- package/dist/tools/recurring.js +239 -0
- package/dist/tools/recurring.js.map +1 -0
- package/dist/tools/register-all.d.ts +2 -2
- package/dist/tools/register-all.d.ts.map +1 -1
- package/dist/tools/register-all.js +53 -3
- package/dist/tools/register-all.js.map +1 -1
- package/dist/tools/shared.d.ts +481 -0
- package/dist/tools/shared.d.ts.map +1 -1
- package/dist/tools/shared.js +396 -0
- package/dist/tools/shared.js.map +1 -1
- package/dist/tools/stay.d.ts +6 -78
- package/dist/tools/stay.d.ts.map +1 -1
- package/dist/tools/stay.js +121 -343
- package/dist/tools/stay.js.map +1 -1
- package/dist/tools/team.d.ts +17 -0
- package/dist/tools/team.d.ts.map +1 -0
- package/dist/tools/team.js +141 -0
- package/dist/tools/team.js.map +1 -0
- package/dist/tools/time.d.ts +19 -0
- package/dist/tools/time.d.ts.map +1 -0
- package/dist/tools/time.js +179 -0
- package/dist/tools/time.js.map +1 -0
- package/dist/tools/webhooks.d.ts.map +1 -1
- package/dist/tools/webhooks.js +27 -1
- package/dist/tools/webhooks.js.map +1 -1
- package/package.json +12 -5
- package/scripts/audit-mcp-refs.mjs +331 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fiscal tools for the Frihet MCP server — Wave 6 (7 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
|
+
*
|
|
13
|
+
* NOTE: ticketbai_status is registered by einvoice.ts (canonical, more complete impl).
|
|
14
|
+
*
|
|
15
|
+
* REST surface: /v1/fiscal/* (documented: pending — backend ships separately)
|
|
16
|
+
*
|
|
17
|
+
* NOTE: ERP backend endpoints /v1/fiscal/* are planned. Tools are wired
|
|
18
|
+
* and will surface 404 errors until the backend ships.
|
|
19
|
+
*/
|
|
20
|
+
import { z } from "zod/v4";
|
|
21
|
+
import { withToolLogging, formatRecord, getContent, mutateContent, READ_ONLY_ANNOTATIONS, fiscalModeloSummaryOutput, verifactuStatusOutput, } from "./shared.js";
|
|
22
|
+
export function registerFiscalTools(server, client) {
|
|
23
|
+
// -- get_modelo_303_summary --
|
|
24
|
+
server.registerTool("get_modelo_303_summary", {
|
|
25
|
+
title: "Get Modelo 303 Summary (IVA Quarterly)",
|
|
26
|
+
description: "Get IVA (VAT) quarterly summary for Modelo 303 filing in Spain. " +
|
|
27
|
+
"Returns aggregated totals by tax rate, deductible IVA, net amount due, and filing deadline. " +
|
|
28
|
+
"Example: period='2026-Q1' / " +
|
|
29
|
+
"Obtiene el resumen trimestral del IVA para el Modelo 303 en Espana. " +
|
|
30
|
+
"Devuelve totales por tipo impositivo, IVA deducible, cuota a ingresar y plazo.",
|
|
31
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
32
|
+
inputSchema: {
|
|
33
|
+
period: z
|
|
34
|
+
.string()
|
|
35
|
+
.optional()
|
|
36
|
+
.describe("Period in format YYYY-QN (e.g. '2026-Q1') or YYYY for annual / Periodo en formato YYYY-QN o YYYY"),
|
|
37
|
+
},
|
|
38
|
+
outputSchema: fiscalModeloSummaryOutput,
|
|
39
|
+
}, async ({ period }) => withToolLogging("get_modelo_303_summary", async () => {
|
|
40
|
+
const result = await client.getFiscalModeloSummary("303", period);
|
|
41
|
+
return {
|
|
42
|
+
content: [getContent(formatRecord("Modelo 303 Summary", result))],
|
|
43
|
+
structuredContent: result,
|
|
44
|
+
};
|
|
45
|
+
}));
|
|
46
|
+
// -- get_modelo_130_summary --
|
|
47
|
+
server.registerTool("get_modelo_130_summary", {
|
|
48
|
+
title: "Get Modelo 130 Summary (IRPF Estimated Payment)",
|
|
49
|
+
description: "Get IRPF estimated payment summary for Modelo 130 filing (freelancers/self-employed in Spain). " +
|
|
50
|
+
"Returns quarterly net income, deductible expenses, previous payments, and amount due. " +
|
|
51
|
+
"Example: period='2026-Q1' / " +
|
|
52
|
+
"Obtiene el resumen del pago fraccionado IRPF para el Modelo 130 (autonomos). " +
|
|
53
|
+
"Devuelve rendimiento neto, gastos deducibles, pagos previos y cuota a ingresar.",
|
|
54
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
55
|
+
inputSchema: {
|
|
56
|
+
period: z
|
|
57
|
+
.string()
|
|
58
|
+
.optional()
|
|
59
|
+
.describe("Period in format YYYY-QN (e.g. '2026-Q1') / Periodo en formato YYYY-QN"),
|
|
60
|
+
},
|
|
61
|
+
outputSchema: fiscalModeloSummaryOutput,
|
|
62
|
+
}, async ({ period }) => withToolLogging("get_modelo_130_summary", async () => {
|
|
63
|
+
const result = await client.getFiscalModeloSummary("130", period);
|
|
64
|
+
return {
|
|
65
|
+
content: [getContent(formatRecord("Modelo 130 Summary", result))],
|
|
66
|
+
structuredContent: result,
|
|
67
|
+
};
|
|
68
|
+
}));
|
|
69
|
+
// -- get_modelo_390_summary --
|
|
70
|
+
server.registerTool("get_modelo_390_summary", {
|
|
71
|
+
title: "Get Modelo 390 Summary (IVA Annual Recap)",
|
|
72
|
+
description: "Get IVA annual summary for Modelo 390 filing in Spain. " +
|
|
73
|
+
"Returns full-year totals by rate, total deductible IVA, and annual balance. " +
|
|
74
|
+
"Example: period='2025' / " +
|
|
75
|
+
"Obtiene el resumen anual del IVA para el Modelo 390. " +
|
|
76
|
+
"Devuelve totales anuales por tipo, IVA deducible total y resultado anual.",
|
|
77
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
78
|
+
inputSchema: {
|
|
79
|
+
period: z
|
|
80
|
+
.string()
|
|
81
|
+
.optional()
|
|
82
|
+
.describe("Year in format YYYY (e.g. '2025') / Ejercicio en formato YYYY"),
|
|
83
|
+
},
|
|
84
|
+
outputSchema: fiscalModeloSummaryOutput,
|
|
85
|
+
}, async ({ period }) => withToolLogging("get_modelo_390_summary", async () => {
|
|
86
|
+
const result = await client.getFiscalModeloSummary("390", period);
|
|
87
|
+
return {
|
|
88
|
+
content: [getContent(formatRecord("Modelo 390 Summary", result))],
|
|
89
|
+
structuredContent: result,
|
|
90
|
+
};
|
|
91
|
+
}));
|
|
92
|
+
// -- get_modelo_180_summary --
|
|
93
|
+
server.registerTool("get_modelo_180_summary", {
|
|
94
|
+
title: "Get Modelo 180 Summary (IRPF Rentals Annual)",
|
|
95
|
+
description: "Get IRPF annual informative summary for rental income withholdings (Modelo 180, Spain). " +
|
|
96
|
+
"Returns total retentions per tenant, property, and annual aggregate. " +
|
|
97
|
+
"Example: period='2025' / " +
|
|
98
|
+
"Obtiene el resumen anual de retenciones sobre alquileres para el Modelo 180. " +
|
|
99
|
+
"Devuelve retenciones totales por inquilino, inmueble y agregado anual.",
|
|
100
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
101
|
+
inputSchema: {
|
|
102
|
+
period: z
|
|
103
|
+
.string()
|
|
104
|
+
.optional()
|
|
105
|
+
.describe("Year in format YYYY (e.g. '2025') / Ejercicio en formato YYYY"),
|
|
106
|
+
},
|
|
107
|
+
outputSchema: fiscalModeloSummaryOutput,
|
|
108
|
+
}, async ({ period }) => withToolLogging("get_modelo_180_summary", async () => {
|
|
109
|
+
const result = await client.getFiscalModeloSummary("180", period);
|
|
110
|
+
return {
|
|
111
|
+
content: [getContent(formatRecord("Modelo 180 Summary", result))],
|
|
112
|
+
structuredContent: result,
|
|
113
|
+
};
|
|
114
|
+
}));
|
|
115
|
+
// -- get_modelo_347_summary --
|
|
116
|
+
server.registerTool("get_modelo_347_summary", {
|
|
117
|
+
title: "Get Modelo 347 Summary (Operations >€3,005 Annual Recap)",
|
|
118
|
+
description: "Get annual informative summary of operations exceeding €3,005 per counterparty (Modelo 347, Spain). " +
|
|
119
|
+
"Returns per-party totals for clients and vendors above the threshold. " +
|
|
120
|
+
"Example: period='2025' / " +
|
|
121
|
+
"Obtiene el resumen anual de operaciones con terceros superiores a 3.005€ (Modelo 347). " +
|
|
122
|
+
"Devuelve totales por cliente/proveedor que superen el umbral.",
|
|
123
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
124
|
+
inputSchema: {
|
|
125
|
+
period: z
|
|
126
|
+
.string()
|
|
127
|
+
.optional()
|
|
128
|
+
.describe("Year in format YYYY (e.g. '2025') / Ejercicio en formato YYYY"),
|
|
129
|
+
},
|
|
130
|
+
outputSchema: fiscalModeloSummaryOutput,
|
|
131
|
+
}, async ({ period }) => withToolLogging("get_modelo_347_summary", async () => {
|
|
132
|
+
const result = await client.getFiscalModeloSummary("347", period);
|
|
133
|
+
return {
|
|
134
|
+
content: [getContent(formatRecord("Modelo 347 Summary", result))],
|
|
135
|
+
structuredContent: result,
|
|
136
|
+
};
|
|
137
|
+
}));
|
|
138
|
+
// -- verifactu_status --
|
|
139
|
+
server.registerTool("verifactu_status", {
|
|
140
|
+
title: "Get VeriFactu Submission Status",
|
|
141
|
+
description: "Get the VeriFactu (AEAT Spanish e-invoice chain) submission status for a specific invoice. " +
|
|
142
|
+
"Returns last submission timestamp, hash, AEAT response code, and QR verification URL. " +
|
|
143
|
+
"/ Obtiene el estado de envio VeriFactu (AEAT) para una factura especifica. " +
|
|
144
|
+
"Devuelve timestamp del ultimo envio, hash, respuesta AEAT y URL del codigo QR.",
|
|
145
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
146
|
+
inputSchema: {
|
|
147
|
+
invoiceId: z.string().describe("Invoice ID / ID de la factura"),
|
|
148
|
+
},
|
|
149
|
+
outputSchema: verifactuStatusOutput,
|
|
150
|
+
}, async ({ invoiceId }) => withToolLogging("verifactu_status", async () => {
|
|
151
|
+
const result = await client.getVerifactuStatus(invoiceId);
|
|
152
|
+
return {
|
|
153
|
+
content: [getContent(formatRecord("VeriFactu Status", result))],
|
|
154
|
+
structuredContent: result,
|
|
155
|
+
};
|
|
156
|
+
}));
|
|
157
|
+
// -- verifactu_resubmit --
|
|
158
|
+
server.registerTool("verifactu_resubmit", {
|
|
159
|
+
title: "Re-submit VeriFactu Submission",
|
|
160
|
+
description: "TRUST AREA — COMPLIANCE. Re-submit a failed or rejected VeriFactu submission to AEAT. " +
|
|
161
|
+
"Idempotent: uses the same hash chain; AEAT deduplicates by hash. " +
|
|
162
|
+
"Creates an audit trail entry for every resubmission attempt. " +
|
|
163
|
+
"Requires confirm=true. Only use on invoices with status='failed'. " +
|
|
164
|
+
"/ AREA DE CONFIANZA — COMPLIANCE. Reenvio de una factura VeriFactu fallida a AEAT. " +
|
|
165
|
+
"Idempotente: misma cadena hash. Registra entrada de auditoria en cada intento. " +
|
|
166
|
+
"Requiere confirm=true. Solo para facturas con status='failed'.",
|
|
167
|
+
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
|
|
168
|
+
inputSchema: {
|
|
169
|
+
invoiceId: z.string().describe("Invoice ID to resubmit / ID de la factura a reenviar"),
|
|
170
|
+
confirm: z
|
|
171
|
+
.boolean()
|
|
172
|
+
.describe("Must be true to confirm VeriFactu resubmission / Debe ser true para confirmar el reenvio"),
|
|
173
|
+
},
|
|
174
|
+
outputSchema: verifactuStatusOutput,
|
|
175
|
+
}, async ({ invoiceId, confirm }) => withToolLogging("verifactu_resubmit", async () => {
|
|
176
|
+
if (!confirm) {
|
|
177
|
+
return {
|
|
178
|
+
content: [
|
|
179
|
+
{
|
|
180
|
+
type: "text",
|
|
181
|
+
text: "Error: confirm=true is required for VeriFactu resubmission. " +
|
|
182
|
+
"This is a COMPLIANCE action that submits fiscal data to AEAT. " +
|
|
183
|
+
"Verify the invoice data is correct before setting confirm=true. / " +
|
|
184
|
+
"Se requiere confirm=true para el reenvio VeriFactu. Accion de COMPLIANCE que envia datos fiscales a AEAT.",
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
isError: true,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
const result = await client.resubmitVerifactu(invoiceId);
|
|
191
|
+
return {
|
|
192
|
+
content: [mutateContent(formatRecord("VeriFactu Resubmitted", result))],
|
|
193
|
+
structuredContent: result,
|
|
194
|
+
};
|
|
195
|
+
}));
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=fiscal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fiscal.js","sourceRoot":"","sources":["../../src/tools/fiscal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EACL,eAAe,EACf,YAAY,EACZ,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAErB,MAAM,UAAU,mBAAmB,CAAC,MAAiB,EAAE,MAAqB;IAC1E,+BAA+B;IAE/B,MAAM,CAAC,YAAY,CACjB,wBAAwB,EACxB;QACE,KAAK,EAAE,wCAAwC;QAC/C,WAAW,EACT,kEAAkE;YAClE,8FAA8F;YAC9F,8BAA8B;YAC9B,sEAAsE;YACtE,gFAAgF;QAClF,WAAW,EAAE,qBAAqB;QAClC,WAAW,EAAE;YACX,MAAM,EAAE,CAAC;iBACN,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CAAC,kGAAkG,CAAC;SAChH;QACD,YAAY,EAAE,yBAAyB;KACxC,EACD,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,eAAe,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;QACzE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,sBAAsB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAClE,OAAO;YACL,OAAO,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC,CAAC;YACjE,iBAAiB,EAAE,MAA4C;SAChE,CAAC;IACJ,CAAC,CAAC,CACH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AE,eAAe,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE;QACxG,WAAW,EAAE;YACX,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sDAAsD,CAAC;YACtF,OAAO,EAAE,CAAC;iBACP,OAAO,EAAE;iBACT,QAAQ,CAAC,0FAA0F,CAAC;SACxG;QACD,YAAY,EAAE,qBAAqB;KACpC,EACD,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,eAAe,CAAC,oBAAoB,EAAE,KAAK,IAAI,EAAE;QACjF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;gBACL,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,8DAA8D;4BAClE,gEAAgE;4BAChE,oEAAoE;4BACpE,2GAA2G;qBAC9G;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;QACzD,OAAO;YACL,OAAO,EAAE,CAAC,aAAa,CAAC,YAAY,CAAC,uBAAuB,EAAE,MAAM,CAAC,CAAC,CAAC;YACvE,iBAAiB,EAAE,MAA4C;SAChE,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AAEJ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gestoria (accountant) tools for the Frihet MCP server — Wave Fase 1 (5 tools).
|
|
3
|
+
*
|
|
4
|
+
* Tools:
|
|
5
|
+
* 1. gestoria_message_send — send a message in a contextual thread
|
|
6
|
+
* 2. gestoria_messages_list — list messages in a thread (paged backwards)
|
|
7
|
+
* 3. gestoria_template_create — create a document request template
|
|
8
|
+
* 4. gestoria_template_bulk_send — bulk send template to N client workspaces
|
|
9
|
+
* 5. gestoria_aging_consolidated — cross-client AR aging report
|
|
10
|
+
*
|
|
11
|
+
* REST surface: /v1/gestoria/*
|
|
12
|
+
*
|
|
13
|
+
* Backend status (post-Wave Fase 1, May 2026):
|
|
14
|
+
* - Frihet-ERP PR #383 — `gestoriaBulkSendRequests` callable (eu-west1) MERGED.
|
|
15
|
+
* - Frihet-ERP PR #384 — consolidated AR aging tab (branch live, await merge).
|
|
16
|
+
* - Frihet-ERP PR #385 — contextual messaging (branch live, await merge).
|
|
17
|
+
*
|
|
18
|
+
* The MCP layer talks REST (`api.frihet.io/v1/gestoria/*`). The REST shell
|
|
19
|
+
* proxies to Firebase callables + Firestore reads. Until the REST shell ships,
|
|
20
|
+
* tools will surface 404 errors with clear messages — clients can retry post-deploy.
|
|
21
|
+
*
|
|
22
|
+
* App Check: mcp.frihet.io worker is App Check enforced. Region: callables
|
|
23
|
+
* auto-resolve eu-west1 via existing client routing.
|
|
24
|
+
*/
|
|
25
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
26
|
+
import type { IFrihetClient } from "../client-interface.js";
|
|
27
|
+
export declare function registerGestoriaTools(server: McpServer, client: IFrihetClient): void;
|
|
28
|
+
//# sourceMappingURL=gestoria.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gestoria.d.ts","sourceRoot":"","sources":["../../src/tools/gestoria.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAuC5D,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAyPpF"}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gestoria (accountant) tools for the Frihet MCP server — Wave Fase 1 (5 tools).
|
|
3
|
+
*
|
|
4
|
+
* Tools:
|
|
5
|
+
* 1. gestoria_message_send — send a message in a contextual thread
|
|
6
|
+
* 2. gestoria_messages_list — list messages in a thread (paged backwards)
|
|
7
|
+
* 3. gestoria_template_create — create a document request template
|
|
8
|
+
* 4. gestoria_template_bulk_send — bulk send template to N client workspaces
|
|
9
|
+
* 5. gestoria_aging_consolidated — cross-client AR aging report
|
|
10
|
+
*
|
|
11
|
+
* REST surface: /v1/gestoria/*
|
|
12
|
+
*
|
|
13
|
+
* Backend status (post-Wave Fase 1, May 2026):
|
|
14
|
+
* - Frihet-ERP PR #383 — `gestoriaBulkSendRequests` callable (eu-west1) MERGED.
|
|
15
|
+
* - Frihet-ERP PR #384 — consolidated AR aging tab (branch live, await merge).
|
|
16
|
+
* - Frihet-ERP PR #385 — contextual messaging (branch live, await merge).
|
|
17
|
+
*
|
|
18
|
+
* The MCP layer talks REST (`api.frihet.io/v1/gestoria/*`). The REST shell
|
|
19
|
+
* proxies to Firebase callables + Firestore reads. Until the REST shell ships,
|
|
20
|
+
* tools will surface 404 errors with clear messages — clients can retry post-deploy.
|
|
21
|
+
*
|
|
22
|
+
* App Check: mcp.frihet.io worker is App Check enforced. Region: callables
|
|
23
|
+
* auto-resolve eu-west1 via existing client routing.
|
|
24
|
+
*/
|
|
25
|
+
import { z } from "zod/v4";
|
|
26
|
+
import { withToolLogging, formatRecord, listContent, getContent, mutateContent, READ_ONLY_ANNOTATIONS, CREATE_ANNOTATIONS, gestoriaMessageItemOutput, gestoriaMessageSendResultOutput, gestoriaTemplateCreateResultOutput, gestoriaBulkSendResultOutput, gestoriaAgingConsolidatedOutput, } from "./shared.js";
|
|
27
|
+
const PARENT_TYPE = z
|
|
28
|
+
.enum(["documentRequest", "filingItem", "obligation"])
|
|
29
|
+
.describe("Thread parent kind / Tipo de hilo: documentRequest (solicitud de documento), filingItem (presentacion fiscal), obligation (obligacion fiscal)");
|
|
30
|
+
const TEMPLATE_VARIABLE = z.object({
|
|
31
|
+
key: z.string().describe("Variable placeholder key, e.g. 'quarter' / Clave variable, p.ej. 'trimestre'"),
|
|
32
|
+
label: z.string().optional().describe("Human label shown in template editor / Etiqueta legible"),
|
|
33
|
+
defaultValue: z.string().optional().describe("Fallback value if no override supplied / Valor por defecto"),
|
|
34
|
+
});
|
|
35
|
+
const PERIOD_OVERRIDES = z
|
|
36
|
+
.object({
|
|
37
|
+
quarter: z.union([z.string(), z.number()]).optional(),
|
|
38
|
+
year: z.union([z.string(), z.number()]).optional(),
|
|
39
|
+
month: z.union([z.string(), z.number()]).optional(),
|
|
40
|
+
})
|
|
41
|
+
.optional()
|
|
42
|
+
.describe("Override template period variables in the bulk send / Sobrescribir variables de periodo (trimestre, ano, mes)");
|
|
43
|
+
export function registerGestoriaTools(server, client) {
|
|
44
|
+
// -- gestoria_message_send ------------------------------------------------
|
|
45
|
+
server.registerTool("gestoria_message_send", {
|
|
46
|
+
title: "Send Gestoria Message",
|
|
47
|
+
description: "Send a message in a contextual thread between a gestor (accountant) and a client. " +
|
|
48
|
+
"Threads attach to a document request, a filing item, or a fiscal obligation — " +
|
|
49
|
+
"context is preserved so both sides see what the message is about. " +
|
|
50
|
+
"Useful for chasing a missing document, replying to a client's question, or " +
|
|
51
|
+
"annotating a presentation. " +
|
|
52
|
+
"Example: workspaceId='ws_abc', parentType='documentRequest', parentId='dr_q3_iva', body='Falta el extracto bancario de septiembre'. " +
|
|
53
|
+
"/ Envia un mensaje en un hilo contextual entre gestor y cliente. " +
|
|
54
|
+
"Los hilos se anclan a una solicitud de documento, presentacion o obligacion fiscal — " +
|
|
55
|
+
"ambas partes ven a que se refiere. Util para pedir documentos, responder dudas o anotar presentaciones.",
|
|
56
|
+
annotations: CREATE_ANNOTATIONS,
|
|
57
|
+
inputSchema: {
|
|
58
|
+
workspaceId: z
|
|
59
|
+
.string()
|
|
60
|
+
.min(1)
|
|
61
|
+
.describe("Client workspace ID the thread belongs to / ID del espacio de trabajo del cliente"),
|
|
62
|
+
parentType: PARENT_TYPE,
|
|
63
|
+
parentId: z.string().min(1).describe("ID of the parent entity (document request / filing item / obligation) / ID de la entidad padre"),
|
|
64
|
+
body: z
|
|
65
|
+
.string()
|
|
66
|
+
.min(1)
|
|
67
|
+
.max(4000)
|
|
68
|
+
.describe("Message body (plain text, 1-4000 chars) / Cuerpo del mensaje (texto plano)"),
|
|
69
|
+
},
|
|
70
|
+
outputSchema: gestoriaMessageSendResultOutput,
|
|
71
|
+
}, async ({ workspaceId, parentType, parentId, body }) => withToolLogging("gestoria_message_send", async () => {
|
|
72
|
+
const result = await client.sendGestoriaMessage({ workspaceId, parentType, parentId, body });
|
|
73
|
+
return {
|
|
74
|
+
content: [mutateContent(formatRecord("Message sent", result))],
|
|
75
|
+
structuredContent: result,
|
|
76
|
+
};
|
|
77
|
+
}));
|
|
78
|
+
// -- gestoria_messages_list -----------------------------------------------
|
|
79
|
+
server.registerTool("gestoria_messages_list", {
|
|
80
|
+
title: "List Gestoria Messages",
|
|
81
|
+
description: "List messages in a contextual gestor/cliente thread, newest first. " +
|
|
82
|
+
"Use `before` (message ID or ISO timestamp) to paginate backwards through history. " +
|
|
83
|
+
"Returns up to `limit` messages plus a `hasMore` flag so the agent knows when to stop. " +
|
|
84
|
+
"/ Lista los mensajes de un hilo gestor/cliente, mas recientes primero. " +
|
|
85
|
+
"Usa `before` (ID o fecha) para paginar hacia atras. Devuelve hasta `limit` mensajes con flag `hasMore`.",
|
|
86
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
87
|
+
inputSchema: {
|
|
88
|
+
workspaceId: z.string().min(1).describe("Client workspace ID / ID del espacio de trabajo"),
|
|
89
|
+
parentType: PARENT_TYPE,
|
|
90
|
+
parentId: z.string().min(1).describe("ID of the parent entity / ID de la entidad padre"),
|
|
91
|
+
limit: z
|
|
92
|
+
.number()
|
|
93
|
+
.int()
|
|
94
|
+
.min(1)
|
|
95
|
+
.max(100)
|
|
96
|
+
.optional()
|
|
97
|
+
.describe("Max messages to return (1-100, default 50) / Mensajes maximos"),
|
|
98
|
+
before: z
|
|
99
|
+
.string()
|
|
100
|
+
.optional()
|
|
101
|
+
.describe("Cursor: messages older than this (message ID or ISO date) / Cursor: mensajes anteriores a este"),
|
|
102
|
+
},
|
|
103
|
+
outputSchema: z.object({
|
|
104
|
+
messages: z.array(gestoriaMessageItemOutput),
|
|
105
|
+
hasMore: z.boolean(),
|
|
106
|
+
}),
|
|
107
|
+
}, async ({ workspaceId, parentType, parentId, limit, before }) => withToolLogging("gestoria_messages_list", async () => {
|
|
108
|
+
const result = await client.listGestoriaMessages({
|
|
109
|
+
workspaceId,
|
|
110
|
+
parentType,
|
|
111
|
+
parentId,
|
|
112
|
+
limit,
|
|
113
|
+
before,
|
|
114
|
+
});
|
|
115
|
+
const count = Array.isArray(result.messages) ? result.messages.length : 0;
|
|
116
|
+
return {
|
|
117
|
+
content: [
|
|
118
|
+
listContent(`Loaded ${count} message${count === 1 ? "" : "s"} for ${parentType}:${parentId}` +
|
|
119
|
+
(result.hasMore ? " (more available — paginate with `before`)" : "")),
|
|
120
|
+
],
|
|
121
|
+
structuredContent: result,
|
|
122
|
+
};
|
|
123
|
+
}));
|
|
124
|
+
// -- gestoria_template_create ---------------------------------------------
|
|
125
|
+
server.registerTool("gestoria_template_create", {
|
|
126
|
+
title: "Create Gestoria Template",
|
|
127
|
+
description: "Create a reusable document request template that the gestor can bulk-send to many " +
|
|
128
|
+
"client workspaces. Template body supports plain-text variable interpolation " +
|
|
129
|
+
"(e.g. `{{quarter}}`, `{{year}}`). `dueDateOffsetDays` sets when the request is due " +
|
|
130
|
+
"relative to the bulk-send date. `attachmentRequired=true` enforces clients to upload " +
|
|
131
|
+
"a file before marking complete. " +
|
|
132
|
+
"Example: name='IVA trimestral', title='Documentacion IVA {{quarter}}/{{year}}', " +
|
|
133
|
+
"description='Adjunta extractos bancarios y facturas emitidas del {{quarter}}', " +
|
|
134
|
+
"dueDateOffsetDays=14, attachmentRequired=true. " +
|
|
135
|
+
"/ Crea una plantilla de solicitud de documento reutilizable que el gestor puede enviar en masa a varios espacios cliente.",
|
|
136
|
+
annotations: CREATE_ANNOTATIONS,
|
|
137
|
+
inputSchema: {
|
|
138
|
+
name: z
|
|
139
|
+
.string()
|
|
140
|
+
.min(1)
|
|
141
|
+
.max(120)
|
|
142
|
+
.describe("Internal template name (shown to gestor only) / Nombre interno"),
|
|
143
|
+
title: z
|
|
144
|
+
.string()
|
|
145
|
+
.min(1)
|
|
146
|
+
.max(200)
|
|
147
|
+
.describe("Title rendered to the client (supports {{variables}}) / Titulo visible al cliente"),
|
|
148
|
+
description: z
|
|
149
|
+
.string()
|
|
150
|
+
.min(1)
|
|
151
|
+
.max(4000)
|
|
152
|
+
.describe("Description / instructions for the client (supports {{variables}}) / Descripcion e instrucciones"),
|
|
153
|
+
dueDateOffsetDays: z
|
|
154
|
+
.number()
|
|
155
|
+
.int()
|
|
156
|
+
.min(0)
|
|
157
|
+
.max(365)
|
|
158
|
+
.describe("Days from send until due (0-365) / Dias desde envio hasta vencimiento"),
|
|
159
|
+
attachmentRequired: z
|
|
160
|
+
.boolean()
|
|
161
|
+
.optional()
|
|
162
|
+
.describe("Require an uploaded file before completion (default: false) / Requiere archivo"),
|
|
163
|
+
variables: z
|
|
164
|
+
.array(TEMPLATE_VARIABLE)
|
|
165
|
+
.optional()
|
|
166
|
+
.describe("Variable definitions for interpolation / Definiciones de variables"),
|
|
167
|
+
},
|
|
168
|
+
outputSchema: gestoriaTemplateCreateResultOutput,
|
|
169
|
+
}, async ({ name, title, description, dueDateOffsetDays, attachmentRequired, variables }) => withToolLogging("gestoria_template_create", async () => {
|
|
170
|
+
const result = await client.createGestoriaTemplate({
|
|
171
|
+
name,
|
|
172
|
+
title,
|
|
173
|
+
description,
|
|
174
|
+
dueDateOffsetDays,
|
|
175
|
+
attachmentRequired,
|
|
176
|
+
variables,
|
|
177
|
+
});
|
|
178
|
+
return {
|
|
179
|
+
content: [mutateContent(formatRecord("Template created", result))],
|
|
180
|
+
structuredContent: result,
|
|
181
|
+
};
|
|
182
|
+
}));
|
|
183
|
+
// -- gestoria_template_bulk_send ------------------------------------------
|
|
184
|
+
server.registerTool("gestoria_template_bulk_send", {
|
|
185
|
+
title: "Bulk Send Gestoria Template",
|
|
186
|
+
description: "Send the same document request template to up to 500 client workspaces in one call. " +
|
|
187
|
+
"Each spawned request triggers the per-client notification handler (email + in-app). " +
|
|
188
|
+
"Honours `allowGestoriaCommunications=false` on the client user doc (opt-out). " +
|
|
189
|
+
"Uses `periodOverrides` to plug runtime values (quarter/year/month) into template variables. " +
|
|
190
|
+
"Returns a per-client outcome with success count, failures, and total wall-clock duration. " +
|
|
191
|
+
"Trust Area: RGPD — recipients must already have granted accountant access. " +
|
|
192
|
+
"Example: templateId='tpl_iva_q', clientWorkspaceIds=['ws_a','ws_b','ws_c'], periodOverrides={quarter:3, year:2026}. " +
|
|
193
|
+
"/ Envia la misma plantilla a hasta 500 espacios cliente en una sola operacion. " +
|
|
194
|
+
"Respeta opt-out `allowGestoriaCommunications=false`.",
|
|
195
|
+
annotations: CREATE_ANNOTATIONS,
|
|
196
|
+
inputSchema: {
|
|
197
|
+
templateId: z.string().min(1).describe("Template ID (from `gestoria_template_create`) / ID de la plantilla"),
|
|
198
|
+
clientWorkspaceIds: z
|
|
199
|
+
.array(z.string().min(1))
|
|
200
|
+
.min(1)
|
|
201
|
+
.max(500)
|
|
202
|
+
.describe("Target client workspace IDs (1-500) / IDs de espacios cliente destino"),
|
|
203
|
+
periodOverrides: PERIOD_OVERRIDES,
|
|
204
|
+
},
|
|
205
|
+
outputSchema: gestoriaBulkSendResultOutput,
|
|
206
|
+
}, async ({ templateId, clientWorkspaceIds, periodOverrides }) => withToolLogging("gestoria_template_bulk_send", async () => {
|
|
207
|
+
const result = await client.bulkSendGestoriaTemplate({
|
|
208
|
+
templateId,
|
|
209
|
+
clientWorkspaceIds,
|
|
210
|
+
periodOverrides,
|
|
211
|
+
});
|
|
212
|
+
const success = typeof result.success === "number" ? result.success : 0;
|
|
213
|
+
const failed = Array.isArray(result.failed) ? result.failed.length : 0;
|
|
214
|
+
return {
|
|
215
|
+
content: [
|
|
216
|
+
mutateContent(`Bulk send complete: ${success} succeeded, ${failed} failed of ${clientWorkspaceIds.length} targets.`),
|
|
217
|
+
],
|
|
218
|
+
structuredContent: result,
|
|
219
|
+
};
|
|
220
|
+
}));
|
|
221
|
+
// -- gestoria_aging_consolidated ------------------------------------------
|
|
222
|
+
server.registerTool("gestoria_aging_consolidated", {
|
|
223
|
+
title: "Consolidated AR Aging (Gestoria)",
|
|
224
|
+
description: "Get a cross-client AR aging report for a gestor — totals bucketed by current / 30-60 / " +
|
|
225
|
+
"60-90 / 90+ days overdue, a per-workspace breakdown, and the top overdue invoices. " +
|
|
226
|
+
"Defaults to the authenticated gestor; pass `ownerUid` to query a specific gestor " +
|
|
227
|
+
"(requires elevated scope). " +
|
|
228
|
+
"Useful for dunning prioritisation and end-of-month chase lists. " +
|
|
229
|
+
"/ Obtiene un informe de antiguedad de saldos cruzando todos los clientes del gestor — " +
|
|
230
|
+
"totales por tramo (al dia / 30-60 / 60-90 / 90+ dias), desglose por espacio y top vencidas. " +
|
|
231
|
+
"Util para priorizar reclamaciones y listas de cobro de fin de mes.",
|
|
232
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
233
|
+
inputSchema: {
|
|
234
|
+
ownerUid: z
|
|
235
|
+
.string()
|
|
236
|
+
.optional()
|
|
237
|
+
.describe("Gestor UID to query (defaults to authenticated caller; elevated scope required for other UIDs) / UID del gestor (por defecto el llamante)"),
|
|
238
|
+
},
|
|
239
|
+
outputSchema: gestoriaAgingConsolidatedOutput,
|
|
240
|
+
}, async ({ ownerUid }) => withToolLogging("gestoria_aging_consolidated", async () => {
|
|
241
|
+
const result = await client.getGestoriaAgingConsolidated({ ownerUid });
|
|
242
|
+
return {
|
|
243
|
+
content: [getContent(formatRecord("Aging consolidated", result))],
|
|
244
|
+
structuredContent: result,
|
|
245
|
+
};
|
|
246
|
+
}));
|
|
247
|
+
}
|
|
248
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W,EAAE;YACX,QAAQ,EAAE,CAAC;iBACR,MAAM,EAAE;iBACR,QAAQ,EAAE;iBACV,QAAQ,CACP,2IAA2I,CAC5I;SACJ;QACD,YAAY,EAAE,+BAA+B;KAC9C,EACD,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CACrB,eAAe,CAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QACxD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QACvE,OAAO;YACL,OAAO,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC,CAAC;YACjE,iBAAiB,EAAE,MAA4C;SAChE,CAAC;IACJ,CAAC,CAAC,CACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HR (Human Resources) tools for the Frihet MCP server — D4-B megasprint (9 tools).
|
|
3
|
+
*
|
|
4
|
+
* Tools:
|
|
5
|
+
* 1. leave_request_create — create a leave/PTO request
|
|
6
|
+
* 2. leave_approve — approve a pending leave (logs decision)
|
|
7
|
+
* 3. leave_reject — reject a pending leave with reason
|
|
8
|
+
* 4. leave_cancel — cancel own leave request
|
|
9
|
+
* 5. leave_list — list leaves (filter: employee, status, period)
|
|
10
|
+
* 6. attendance_clock_in — clock in with optional mood + location
|
|
11
|
+
* 7. attendance_clock_out — close an open time entry
|
|
12
|
+
* 8. overtime_report — aggregated overtime by period
|
|
13
|
+
* 9. anomaly_list — list HR/operational anomalies
|
|
14
|
+
*
|
|
15
|
+
* REST surface: /v1/leaves, /v1/time-entries, /v1/anomalies
|
|
16
|
+
*
|
|
17
|
+
* NOTE: ERP backend endpoints land in parallel D4-A wave. Tools wired —
|
|
18
|
+
* 404s propagate as isError until backend ships. TODO: wire to CF
|
|
19
|
+
* logLeaveDecision callable when REST shell lands.
|
|
20
|
+
*/
|
|
21
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
22
|
+
import type { IFrihetClient } from "../client-interface.js";
|
|
23
|
+
export declare function registerHrTools(server: McpServer, client: IFrihetClient): void;
|
|
24
|
+
//# sourceMappingURL=hr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hr.d.ts","sourceRoot":"","sources":["../../src/tools/hr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAkB5D,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAmQ9E"}
|