@frihet/mcp-server 1.9.0-beta.1 → 1.12.0
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 +263 -13
- 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 +5 -4
- package/dist/__tests__/fiscal-tools.test.d.ts.map +1 -1
- package/dist/__tests__/fiscal-tools.test.js +8 -26
- package/dist/__tests__/fiscal-tools.test.js.map +1 -1
- package/dist/__tests__/openai-profile.test.d.ts +10 -0
- package/dist/__tests__/openai-profile.test.d.ts.map +1 -0
- package/dist/__tests__/openai-profile.test.js +132 -0
- package/dist/__tests__/openai-profile.test.js.map +1 -0
- package/dist/__tests__/recurring-tools.test.d.ts +14 -7
- package/dist/__tests__/recurring-tools.test.d.ts.map +1 -1
- package/dist/__tests__/recurring-tools.test.js +195 -9
- package/dist/__tests__/recurring-tools.test.js.map +1 -1
- 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 +9 -7
- package/dist/__tests__/time-tools.test.d.ts.map +1 -1
- package/dist/__tests__/time-tools.test.js +96 -9
- package/dist/__tests__/time-tools.test.js.map +1 -1
- package/dist/client-interface.d.ts +236 -0
- package/dist/client-interface.d.ts.map +1 -1
- package/dist/client.d.ts +245 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +266 -5
- package/dist/client.js.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/openai-profile.d.ts +4 -1
- package/dist/openai-profile.d.ts.map +1 -1
- package/dist/openai-profile.js +105 -1
- package/dist/openai-profile.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/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 +3 -2
- package/dist/tools/fiscal.d.ts.map +1 -1
- package/dist/tools/fiscal.js +4 -22
- package/dist/tools/fiscal.js.map +1 -1
- 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/recurring.d.ts +10 -5
- package/dist/tools/recurring.d.ts.map +1 -1
- package/dist/tools/recurring.js +178 -6
- package/dist/tools/recurring.js.map +1 -1
- 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 +41 -3
- package/dist/tools/register-all.js.map +1 -1
- package/dist/tools/shared.d.ts +313 -1
- package/dist/tools/shared.d.ts.map +1 -1
- package/dist/tools/shared.js +256 -0
- package/dist/tools/shared.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 +9 -8
- package/dist/tools/time.d.ts.map +1 -1
- package/dist/tools/time.js +54 -9
- package/dist/tools/time.js.map +1 -1
- 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
package/dist/tools/fiscal.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Fiscal tools for the Frihet MCP server — Wave 6 (
|
|
2
|
+
* Fiscal tools for the Frihet MCP server — Wave 6 (7 tools).
|
|
3
3
|
*
|
|
4
4
|
* Tools:
|
|
5
5
|
* 1. get_modelo_303_summary — IVA quarterly Spain
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
* 5. get_modelo_347_summary — Operations >€3005 annual third-party recap
|
|
10
10
|
* 6. verifactu_status — VeriFactu submission status for an invoice
|
|
11
11
|
* 7. verifactu_resubmit — Re-submit a failed VeriFactu submission (TRUST AREA)
|
|
12
|
-
*
|
|
12
|
+
*
|
|
13
|
+
* NOTE: ticketbai_status is registered by einvoice.ts (canonical, more complete impl).
|
|
13
14
|
*
|
|
14
15
|
* REST surface: /v1/fiscal/* (documented: pending — backend ships separately)
|
|
15
16
|
*
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
* and will surface 404 errors until the backend ships.
|
|
18
19
|
*/
|
|
19
20
|
import { z } from "zod/v4";
|
|
20
|
-
import { withToolLogging, formatRecord, getContent, mutateContent, READ_ONLY_ANNOTATIONS, fiscalModeloSummaryOutput, verifactuStatusOutput,
|
|
21
|
+
import { withToolLogging, formatRecord, getContent, mutateContent, READ_ONLY_ANNOTATIONS, fiscalModeloSummaryOutput, verifactuStatusOutput, } from "./shared.js";
|
|
21
22
|
export function registerFiscalTools(server, client) {
|
|
22
23
|
// -- get_modelo_303_summary --
|
|
23
24
|
server.registerTool("get_modelo_303_summary", {
|
|
@@ -192,24 +193,5 @@ export function registerFiscalTools(server, client) {
|
|
|
192
193
|
structuredContent: result,
|
|
193
194
|
};
|
|
194
195
|
}));
|
|
195
|
-
// -- ticketbai_status --
|
|
196
|
-
server.registerTool("ticketbai_status", {
|
|
197
|
-
title: "Get TicketBAI Status (Basque Country)",
|
|
198
|
-
description: "Get the TicketBAI e-invoicing status for an invoice (Basque Country fiscal territories: Araba, Bizkaia, Gipuzkoa). " +
|
|
199
|
-
"Returns submission status, hash, territory province, and AEAT-PV/Bizkaia/Gipuzkoa response. " +
|
|
200
|
-
"/ Obtiene el estado TicketBAI de una factura (territorios forales vascos: Araba, Bizkaia, Gipuzkoa). " +
|
|
201
|
-
"Devuelve estado de envio, hash, provincia y respuesta de la hacienda foral.",
|
|
202
|
-
annotations: READ_ONLY_ANNOTATIONS,
|
|
203
|
-
inputSchema: {
|
|
204
|
-
invoiceId: z.string().describe("Invoice ID / ID de la factura"),
|
|
205
|
-
},
|
|
206
|
-
outputSchema: ticketbaiStatusOutput,
|
|
207
|
-
}, async ({ invoiceId }) => withToolLogging("ticketbai_status", async () => {
|
|
208
|
-
const result = await client.getTicketbaiStatus(invoiceId);
|
|
209
|
-
return {
|
|
210
|
-
content: [getContent(formatRecord("TicketBAI Status", result))],
|
|
211
|
-
structuredContent: result,
|
|
212
|
-
};
|
|
213
|
-
}));
|
|
214
196
|
}
|
|
215
197
|
//# sourceMappingURL=fiscal.js.map
|
package/dist/tools/fiscal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fiscal.js","sourceRoot":"","sources":["../../src/tools/fiscal.ts"],"names":[],"mappings":"AAAA
|
|
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,MA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EAAgE;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
|
+
//# sourceMappingURL=gestoria.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gestoria.js","sourceRoot":"","sources":["../../src/tools/gestoria.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EACL,eAAe,EACf,YAAY,EACZ,WAAW,EACX,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,yBAAyB,EACzB,+BAA+B,EAC/B,kCAAkC,EAClC,4BAA4B,EAC5B,+BAA+B,GAChC,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,GAAG,CAAC;KAClB,IAAI,CAAC,CAAC,iBAAiB,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;KACrD,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 +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"}
|
package/dist/tools/hr.js
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
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 { z } from "zod/v4";
|
|
22
|
+
import { withToolLogging, formatPaginatedResponse, formatRecord, listContent, getContent, mutateContent, READ_ONLY_ANNOTATIONS, CREATE_ANNOTATIONS, UPDATE_ANNOTATIONS, paginatedOutput, leaveRequestItemOutput, attendanceEntryItemOutput, overtimeReportOutput, anomalyItemOutput, } from "./shared.js";
|
|
23
|
+
export function registerHrTools(server, client) {
|
|
24
|
+
// -- leave_request_create --
|
|
25
|
+
server.registerTool("leave_request_create", {
|
|
26
|
+
title: "Create Leave Request",
|
|
27
|
+
description: "Create a new leave/PTO request for an employee. " +
|
|
28
|
+
"Types: 'vacation', 'sick', 'personal', 'parental', 'unpaid', 'training'. " +
|
|
29
|
+
"Dates must be ISO 8601 (YYYY-MM-DD). Status starts as 'pending' awaiting manager approval. " +
|
|
30
|
+
"/ Crea una nueva solicitud de vacaciones/permiso. Estado inicial 'pending' pendiente aprobacion.",
|
|
31
|
+
annotations: CREATE_ANNOTATIONS,
|
|
32
|
+
inputSchema: {
|
|
33
|
+
employeeId: z.string().describe("Employee ID / ID del empleado"),
|
|
34
|
+
type: z.string().describe("Leave type slug (vacation, sick, personal, parental, unpaid, training) / Tipo de permiso"),
|
|
35
|
+
startDate: z.string().describe("Start date ISO 8601 (YYYY-MM-DD) / Fecha inicio"),
|
|
36
|
+
endDate: z.string().describe("End date ISO 8601 (YYYY-MM-DD) / Fecha fin"),
|
|
37
|
+
reason: z.string().optional().describe("Optional reason / Motivo opcional"),
|
|
38
|
+
},
|
|
39
|
+
outputSchema: leaveRequestItemOutput,
|
|
40
|
+
}, async (input) => withToolLogging("leave_request_create", async () => {
|
|
41
|
+
const result = await client.createLeaveRequest(input);
|
|
42
|
+
return {
|
|
43
|
+
content: [mutateContent(formatRecord("Leave request created", result))],
|
|
44
|
+
structuredContent: result,
|
|
45
|
+
};
|
|
46
|
+
}));
|
|
47
|
+
// -- leave_approve --
|
|
48
|
+
server.registerTool("leave_approve", {
|
|
49
|
+
title: "Approve Leave Request",
|
|
50
|
+
description: "TRUST AREA — HR DECISION. Approve a pending leave request. Logs decision with timestamp and approver. " +
|
|
51
|
+
"Idempotent: re-approving an already approved leave is a no-op. " +
|
|
52
|
+
"/ AREA DE CONFIANZA — DECISION RRHH. Aprueba una solicitud de permiso pendiente. Registra la decision.",
|
|
53
|
+
annotations: UPDATE_ANNOTATIONS,
|
|
54
|
+
inputSchema: {
|
|
55
|
+
leaveId: z.string().describe("Leave request ID / ID de la solicitud"),
|
|
56
|
+
reason: z.string().optional().describe("Optional approval note / Nota de aprobacion opcional"),
|
|
57
|
+
},
|
|
58
|
+
outputSchema: leaveRequestItemOutput,
|
|
59
|
+
}, async ({ leaveId, reason }) => withToolLogging("leave_approve", async () => {
|
|
60
|
+
const result = await client.approveLeave(leaveId, { reason });
|
|
61
|
+
return {
|
|
62
|
+
content: [mutateContent(formatRecord("Leave approved", result))],
|
|
63
|
+
structuredContent: result,
|
|
64
|
+
};
|
|
65
|
+
}));
|
|
66
|
+
// -- leave_reject --
|
|
67
|
+
server.registerTool("leave_reject", {
|
|
68
|
+
title: "Reject Leave Request",
|
|
69
|
+
description: "TRUST AREA — HR DECISION. Reject a pending leave request with a required reason. " +
|
|
70
|
+
"Reason is mandatory for transparency and labor-law compliance. " +
|
|
71
|
+
"/ AREA DE CONFIANZA — DECISION RRHH. Rechaza una solicitud con motivo obligatorio.",
|
|
72
|
+
annotations: UPDATE_ANNOTATIONS,
|
|
73
|
+
inputSchema: {
|
|
74
|
+
leaveId: z.string().describe("Leave request ID / ID de la solicitud"),
|
|
75
|
+
reason: z.string().min(1).describe("Required rejection reason / Motivo obligatorio de rechazo"),
|
|
76
|
+
},
|
|
77
|
+
outputSchema: leaveRequestItemOutput,
|
|
78
|
+
}, async ({ leaveId, reason }) => withToolLogging("leave_reject", async () => {
|
|
79
|
+
const result = await client.rejectLeave(leaveId, { reason });
|
|
80
|
+
return {
|
|
81
|
+
content: [mutateContent(formatRecord("Leave rejected", result))],
|
|
82
|
+
structuredContent: result,
|
|
83
|
+
};
|
|
84
|
+
}));
|
|
85
|
+
// -- leave_cancel --
|
|
86
|
+
server.registerTool("leave_cancel", {
|
|
87
|
+
title: "Cancel Leave Request",
|
|
88
|
+
description: "Cancel a leave request. Typically used by the requesting employee before approval, " +
|
|
89
|
+
"or by HR after approval (which may trigger schedule rollback). " +
|
|
90
|
+
"/ Cancela una solicitud de permiso (por el empleado o RRHH).",
|
|
91
|
+
annotations: UPDATE_ANNOTATIONS,
|
|
92
|
+
inputSchema: {
|
|
93
|
+
leaveId: z.string().describe("Leave request ID / ID de la solicitud"),
|
|
94
|
+
},
|
|
95
|
+
outputSchema: leaveRequestItemOutput,
|
|
96
|
+
}, async ({ leaveId }) => withToolLogging("leave_cancel", async () => {
|
|
97
|
+
const result = await client.cancelLeave(leaveId);
|
|
98
|
+
return {
|
|
99
|
+
content: [mutateContent(formatRecord("Leave cancelled", result))],
|
|
100
|
+
structuredContent: result,
|
|
101
|
+
};
|
|
102
|
+
}));
|
|
103
|
+
// -- leave_list --
|
|
104
|
+
server.registerTool("leave_list", {
|
|
105
|
+
title: "List Leave Requests",
|
|
106
|
+
description: "List leave/PTO requests with optional filters. " +
|
|
107
|
+
"Filter by employee, status (pending/approved/rejected/cancelled), or period (date range). " +
|
|
108
|
+
"Useful for HR dashboards, calendar views, balance tracking. " +
|
|
109
|
+
"/ Lista solicitudes de permisos con filtros opcionales (empleado, estado, periodo).",
|
|
110
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
111
|
+
inputSchema: {
|
|
112
|
+
employeeId: z.string().optional().describe("Filter by employee ID / Filtrar por empleado"),
|
|
113
|
+
status: z
|
|
114
|
+
.enum(["pending", "approved", "rejected", "cancelled"])
|
|
115
|
+
.optional()
|
|
116
|
+
.describe("Filter by status / Filtrar por estado"),
|
|
117
|
+
from: z.string().optional().describe("Period start ISO 8601 (YYYY-MM-DD) / Inicio periodo"),
|
|
118
|
+
to: z.string().optional().describe("Period end ISO 8601 (YYYY-MM-DD) / Fin periodo"),
|
|
119
|
+
limit: z.number().int().min(1).max(100).optional().describe("Max results (1-100) / Resultados maximos"),
|
|
120
|
+
offset: z.number().int().min(0).optional().describe("Offset / Desplazamiento"),
|
|
121
|
+
after: z.string().optional().describe("Cursor for cursor-based pagination / Cursor"),
|
|
122
|
+
},
|
|
123
|
+
outputSchema: paginatedOutput(leaveRequestItemOutput),
|
|
124
|
+
}, async ({ employeeId, status, from, to, limit, offset, after }) => withToolLogging("leave_list", async () => {
|
|
125
|
+
const result = await client.listLeaves({ employeeId, status, from, to, limit, offset, after });
|
|
126
|
+
return {
|
|
127
|
+
content: [listContent(formatPaginatedResponse("leaves", result))],
|
|
128
|
+
structuredContent: result,
|
|
129
|
+
};
|
|
130
|
+
}));
|
|
131
|
+
// -- attendance_clock_in --
|
|
132
|
+
server.registerTool("attendance_clock_in", {
|
|
133
|
+
title: "Clock In (Attendance)",
|
|
134
|
+
description: "Record an employee clock-in. Optionally captures mood (employee well-being tracking) " +
|
|
135
|
+
"and location (remote/office/site). Returns an attendance entry with status='open'. " +
|
|
136
|
+
"Pair with attendance_clock_out to close the entry. " +
|
|
137
|
+
"/ Registra una entrada de fichaje. Captura opcionalmente estado de animo y ubicacion.",
|
|
138
|
+
annotations: CREATE_ANNOTATIONS,
|
|
139
|
+
inputSchema: {
|
|
140
|
+
employeeId: z.string().describe("Employee ID / ID del empleado"),
|
|
141
|
+
mood: z.string().optional().describe("Optional mood slug (e.g. 'great','ok','tired') / Estado de animo"),
|
|
142
|
+
location: z.string().optional().describe("Optional location ('remote','office','site') / Ubicacion"),
|
|
143
|
+
},
|
|
144
|
+
outputSchema: attendanceEntryItemOutput,
|
|
145
|
+
}, async (input) => withToolLogging("attendance_clock_in", async () => {
|
|
146
|
+
const result = await client.attendanceClockIn(input);
|
|
147
|
+
return {
|
|
148
|
+
content: [mutateContent(formatRecord("Clocked in", result))],
|
|
149
|
+
structuredContent: result,
|
|
150
|
+
};
|
|
151
|
+
}));
|
|
152
|
+
// -- attendance_clock_out --
|
|
153
|
+
server.registerTool("attendance_clock_out", {
|
|
154
|
+
title: "Clock Out (Attendance)",
|
|
155
|
+
description: "Close an open attendance entry. Stamps clockOutAt and computes durationMinutes. " +
|
|
156
|
+
"Idempotent: clocking out an already-closed entry is a no-op. " +
|
|
157
|
+
"/ Cierra una entrada de fichaje abierta. Calcula la duracion en minutos.",
|
|
158
|
+
annotations: UPDATE_ANNOTATIONS,
|
|
159
|
+
inputSchema: {
|
|
160
|
+
entryId: z.string().describe("Open attendance entry ID / ID de la entrada abierta"),
|
|
161
|
+
},
|
|
162
|
+
outputSchema: attendanceEntryItemOutput,
|
|
163
|
+
}, async ({ entryId }) => withToolLogging("attendance_clock_out", async () => {
|
|
164
|
+
const result = await client.attendanceClockOut(entryId);
|
|
165
|
+
return {
|
|
166
|
+
content: [mutateContent(formatRecord("Clocked out", result))],
|
|
167
|
+
structuredContent: result,
|
|
168
|
+
};
|
|
169
|
+
}));
|
|
170
|
+
// -- overtime_report --
|
|
171
|
+
server.registerTool("overtime_report", {
|
|
172
|
+
title: "Overtime Report",
|
|
173
|
+
description: "Generate an overtime report for a period. Aggregates regular vs overtime hours " +
|
|
174
|
+
"per employee + total estimated cost in EUR. Useful for payroll prep and labor-law audits. " +
|
|
175
|
+
"Period format: 'YYYY-MM' (monthly) or 'YYYY-QN' (quarterly) or 'YYYY' (annual). " +
|
|
176
|
+
"/ Informe de horas extra por periodo. Agrega horas regulares vs extra por empleado + coste estimado.",
|
|
177
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
178
|
+
inputSchema: {
|
|
179
|
+
period: z.string().describe("Period (YYYY-MM, YYYY-QN, or YYYY) / Periodo"),
|
|
180
|
+
employeeId: z.string().optional().describe("Optional filter by employee / Filtrar por empleado opcional"),
|
|
181
|
+
},
|
|
182
|
+
outputSchema: overtimeReportOutput,
|
|
183
|
+
}, async ({ period, employeeId }) => withToolLogging("overtime_report", async () => {
|
|
184
|
+
const result = await client.getOvertimeReport({ period, employeeId });
|
|
185
|
+
return {
|
|
186
|
+
content: [getContent(formatRecord("Overtime report", result))],
|
|
187
|
+
structuredContent: result,
|
|
188
|
+
};
|
|
189
|
+
}));
|
|
190
|
+
// -- anomaly_list --
|
|
191
|
+
server.registerTool("anomaly_list", {
|
|
192
|
+
title: "List Anomalies",
|
|
193
|
+
description: "List HR / operational / financial anomalies detected by the system. " +
|
|
194
|
+
"Filter by type (duplicate_clock_in, overtime_spike, missing_clock_out, expense_outlier, etc.), " +
|
|
195
|
+
"severity (low/medium/high/critical), or period. " +
|
|
196
|
+
"Useful for daily HR review and compliance audits. " +
|
|
197
|
+
"/ Lista anomalias detectadas (RRHH/operativas/financieras) con filtros opcionales.",
|
|
198
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
199
|
+
inputSchema: {
|
|
200
|
+
type: z.string().optional().describe("Filter by anomaly type slug / Tipo"),
|
|
201
|
+
severity: z
|
|
202
|
+
.enum(["low", "medium", "high", "critical"])
|
|
203
|
+
.optional()
|
|
204
|
+
.describe("Filter by severity / Severidad"),
|
|
205
|
+
from: z.string().optional().describe("Period start ISO 8601 / Inicio"),
|
|
206
|
+
to: z.string().optional().describe("Period end ISO 8601 / Fin"),
|
|
207
|
+
limit: z.number().int().min(1).max(100).optional().describe("Max results / Maximos"),
|
|
208
|
+
offset: z.number().int().min(0).optional().describe("Offset / Desplazamiento"),
|
|
209
|
+
},
|
|
210
|
+
outputSchema: paginatedOutput(anomalyItemOutput),
|
|
211
|
+
}, async ({ type, severity, from, to, limit, offset }) => withToolLogging("anomaly_list", async () => {
|
|
212
|
+
const result = await client.listAnomalies({ type, severity, from, to, limit, offset });
|
|
213
|
+
return {
|
|
214
|
+
content: [listContent(formatPaginatedResponse("anomalies", result))],
|
|
215
|
+
structuredContent: result,
|
|
216
|
+
};
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=hr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hr.js","sourceRoot":"","sources":["../../src/tools/hr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,YAAY,EACZ,WAAW,EACX,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,sBAAsB,EACtB,yBAAyB,EACzB,oBAAoB,EACpB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AAErB,MAAM,UAAU,eAAe,CAAC,MAAiB,EAAE,MAAqB;IACtE,6BAA6B;IAE7B,MAAM,CAAC,YAAY,CACjB,sBAAsB,EACtB;QACE,KAAK,EAAE,sBAAsB;QAC7B,WAAW,EACT,kDAAkD;YA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