@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/openai-profile.js
CHANGED
|
@@ -15,17 +15,88 @@
|
|
|
15
15
|
* The full MCP server (55 tools) remains available for Claude, Cursor,
|
|
16
16
|
* Windsurf, Cline, Codex, and all other MCP clients.
|
|
17
17
|
*
|
|
18
|
-
* OpenAI-safe mode: 53 tools
|
|
18
|
+
* OpenAI-safe mode: 53 reviewed tools, 0 prompts, 0 government IDs in I/O.
|
|
19
|
+
* The full MCP surface remains available outside FRIHET_OPENAI_MODE.
|
|
19
20
|
*
|
|
20
21
|
* @see https://developers.openai.com/apps-sdk/app-submission-guidelines
|
|
21
22
|
*/
|
|
22
23
|
const PROFILE = {
|
|
24
|
+
// -- OpenAI-reviewed core surface ----------------------------------------
|
|
25
|
+
//
|
|
26
|
+
// Keep the ChatGPT app submission narrow and stable. The full MCP server
|
|
27
|
+
// has many more tools, including payroll, HR, e-invoicing, VIES, stay/PMS,
|
|
28
|
+
// POS, and other regulated workflows. Those are useful for direct MCP
|
|
29
|
+
// clients, but they broaden data collection and review risk for ChatGPT.
|
|
30
|
+
includeTools: new Set([
|
|
31
|
+
// Read-only tools
|
|
32
|
+
"get_business_context",
|
|
33
|
+
"get_monthly_summary",
|
|
34
|
+
"list_invoices",
|
|
35
|
+
"get_invoice",
|
|
36
|
+
"search_invoices",
|
|
37
|
+
"get_invoice_pdf",
|
|
38
|
+
"list_expenses",
|
|
39
|
+
"get_expense",
|
|
40
|
+
"list_clients",
|
|
41
|
+
"get_client",
|
|
42
|
+
"list_client_contacts",
|
|
43
|
+
"list_client_activities",
|
|
44
|
+
"list_client_notes",
|
|
45
|
+
"list_products",
|
|
46
|
+
"get_product",
|
|
47
|
+
"list_quotes",
|
|
48
|
+
"get_quote",
|
|
49
|
+
"list_vendors",
|
|
50
|
+
"get_vendor",
|
|
51
|
+
"list_webhooks",
|
|
52
|
+
"get_webhook",
|
|
53
|
+
// Create tools
|
|
54
|
+
"create_invoice",
|
|
55
|
+
"duplicate_invoice",
|
|
56
|
+
"create_credit_note",
|
|
57
|
+
"apply_late_fee",
|
|
58
|
+
"create_expense",
|
|
59
|
+
"create_client",
|
|
60
|
+
"create_client_contact",
|
|
61
|
+
"log_client_activity",
|
|
62
|
+
"create_client_note",
|
|
63
|
+
"create_product",
|
|
64
|
+
"create_quote",
|
|
65
|
+
"create_vendor",
|
|
66
|
+
// Update tools
|
|
67
|
+
"update_invoice",
|
|
68
|
+
"mark_invoice_paid",
|
|
69
|
+
"update_expense",
|
|
70
|
+
"update_client",
|
|
71
|
+
"update_product",
|
|
72
|
+
"update_quote",
|
|
73
|
+
"update_vendor",
|
|
74
|
+
// Delete tools
|
|
75
|
+
"delete_invoice",
|
|
76
|
+
"delete_expense",
|
|
77
|
+
"delete_client",
|
|
78
|
+
"delete_client_contact",
|
|
79
|
+
"delete_client_note",
|
|
80
|
+
"delete_product",
|
|
81
|
+
"delete_quote",
|
|
82
|
+
"delete_vendor",
|
|
83
|
+
"delete_webhook",
|
|
84
|
+
// Open-world tools with explicit justifications
|
|
85
|
+
"send_invoice",
|
|
86
|
+
"send_quote",
|
|
87
|
+
"create_webhook",
|
|
88
|
+
"update_webhook",
|
|
89
|
+
]),
|
|
23
90
|
// ── Tools excluded entirely ─────────────────────────────────────────
|
|
24
91
|
// Return restricted data categories that cannot be adequately redacted.
|
|
25
92
|
excludeTools: new Set([
|
|
26
93
|
"get_quarterly_taxes", // Modelo 303/130 tax filing data — sensitive fiscal PII
|
|
27
94
|
"get_invoice_einvoice", // EN16931 XML mandatorily contains seller+buyer NIF/CIF
|
|
28
95
|
]),
|
|
96
|
+
// MCP prompts can reference tools/fields that are intentionally hidden from
|
|
97
|
+
// OpenAI mode (for example tax IDs and fiscal filing tools). ChatGPT Apps do
|
|
98
|
+
// not need them for the public app surface, so remove them from this profile.
|
|
99
|
+
excludePrompts: true,
|
|
29
100
|
// ── Annotation corrections ──────────────────────────────────────────
|
|
30
101
|
// openWorldHint MUST be true for tools that cause external side effects.
|
|
31
102
|
annotationOverrides: {
|
|
@@ -107,6 +178,13 @@ const PROFILE = {
|
|
|
107
178
|
"secret", // Webhook signing credential
|
|
108
179
|
"iban", "bankAccount", // Banking identifiers (if exposed via passthrough)
|
|
109
180
|
"bank_account", "accountNumber",
|
|
181
|
+
"idDocument", "documentNumber", // Guest/customer government document fields
|
|
182
|
+
"passport", "passportNumber",
|
|
183
|
+
"dni", "nationalId", "national_id",
|
|
184
|
+
"ssn", "socialSecurityNumber", "social_security_number",
|
|
185
|
+
"apiKey", "api_key",
|
|
186
|
+
"accessToken", "access_token", "refreshToken", "refresh_token",
|
|
187
|
+
"password", "mfa", "otp",
|
|
110
188
|
],
|
|
111
189
|
};
|
|
112
190
|
/* ------------------------------------------------------------------ */
|
|
@@ -189,6 +267,9 @@ export function applyOpenAIProfile(server) {
|
|
|
189
267
|
const originalRegisterTool = server.registerTool.bind(server);
|
|
190
268
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
191
269
|
server.registerTool = (name, config, handler) => {
|
|
270
|
+
// 0. Keep the public ChatGPT app to the reviewed core tool surface
|
|
271
|
+
if (!PROFILE.includeTools.has(name))
|
|
272
|
+
return;
|
|
192
273
|
// 1. Skip excluded tools entirely
|
|
193
274
|
if (PROFILE.excludeTools.has(name))
|
|
194
275
|
return;
|
|
@@ -202,6 +283,22 @@ export function applyOpenAIProfile(server) {
|
|
|
202
283
|
if (descOverride) {
|
|
203
284
|
config.description = descOverride;
|
|
204
285
|
}
|
|
286
|
+
// 3b. Ensure EVERY reviewed tool states an explicit openWorldHint rationale.
|
|
287
|
+
// OpenAI review requires openWorldHint to be explicitly true/false (never null)
|
|
288
|
+
// with a clear justification per tool. The 4 open-world tools already embed a
|
|
289
|
+
// bespoke "[openWorldHint: true — …]" rationale via descriptionOverrides; this
|
|
290
|
+
// appends the closed-world rationale to the remaining reviewed tools so the
|
|
291
|
+
// justification is present for all of them at tools/list. Only mutates the
|
|
292
|
+
// OpenAI-mode description string — annotation booleans (already correct) and the
|
|
293
|
+
// base tool files (used by every other MCP client) are left untouched.
|
|
294
|
+
if (typeof config.description === "string" &&
|
|
295
|
+
!config.description.includes("openWorldHint")) {
|
|
296
|
+
const ow = config.annotations?.openWorldHint;
|
|
297
|
+
config.description +=
|
|
298
|
+
ow === true
|
|
299
|
+
? " [openWorldHint: true — contacts an entity outside Frihet (an email recipient or an external webhook URL).]"
|
|
300
|
+
: " [openWorldHint: false — operates only against the Frihet API (api.frihet.io); no third-party/external calls.]";
|
|
301
|
+
}
|
|
205
302
|
// 4. Strip sensitive input fields
|
|
206
303
|
const inputStrip = PROFILE.stripInputFields[name];
|
|
207
304
|
if (inputStrip && config.inputSchema) {
|
|
@@ -265,9 +362,16 @@ export function applyOpenAIProfile(server) {
|
|
|
265
362
|
}
|
|
266
363
|
return originalRegisterResource(name, ...rest);
|
|
267
364
|
};
|
|
365
|
+
/* ── Intercept registerPrompt ───────────────────────────────────── */
|
|
366
|
+
if (PROFILE.excludePrompts && typeof server.registerPrompt === "function") {
|
|
367
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
368
|
+
server.registerPrompt = (_name, ..._rest) => undefined;
|
|
369
|
+
}
|
|
268
370
|
}
|
|
269
371
|
/** Number of tools excluded in OpenAI mode (for logging). */
|
|
270
372
|
export const OPENAI_EXCLUDED_COUNT = PROFILE.excludeTools.size;
|
|
373
|
+
/** Number of tools explicitly allowed in OpenAI mode. */
|
|
374
|
+
export const OPENAI_ALLOWED_TOOL_COUNT = PROFILE.includeTools.size;
|
|
271
375
|
/** Number of resources excluded in OpenAI mode (for logging). */
|
|
272
376
|
export const OPENAI_EXCLUDED_RESOURCE_COUNT = EXCLUDE_RESOURCES.size;
|
|
273
377
|
//# sourceMappingURL=openai-profile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-profile.js","sourceRoot":"","sources":["../src/openai-profile.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"openai-profile.js","sourceRoot":"","sources":["../src/openai-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAyBH,MAAM,OAAO,GAAkB;IAC7B,2EAA2E;IAC3E,EAAE;IACF,yEAAyE;IACzE,2EAA2E;IAC3E,sEAAsE;IACtE,yEAAyE;IACzE,YAAY,EAAE,IAAI,GAAG,CAAC;QACpB,kBAAkB;QAClB,sBAAsB;QACtB,qBAAqB;QACrB,eAAe;QACf,aAAa;QACb,iBAAiB;QACjB,iBAAiB;QACjB,eAAe;QACf,aAAa;QACb,cAAc;QACd,YAAY;QACZ,sBAAsB;QACtB,wBAAwB;QACxB,mBAAmB;QACnB,eAAe;QACf,aAAa;QACb,aAAa;QACb,WAAW;QACX,cAAc;QACd,YAAY;QACZ,eAAe;QACf,aAAa;QAEb,eAAe;QACf,gBAAgB;QAChB,mBAAmB;QACnB,oBAAoB;QACpB,gBAAgB;QAChB,gBAAgB;QAChB,eAAe;QACf,uBAAuB;QACvB,qBAAqB;QACrB,oBAAoB;QACpB,gBAAgB;QAChB,cAAc;QACd,eAAe;QAEf,eAAe;QACf,gBAAgB;QAChB,mBAAmB;QACnB,gBAAgB;QAChB,eAAe;QACf,gBAAgB;QAChB,cAAc;QACd,eAAe;QAEf,eAAe;QACf,gBAAgB;QAChB,gBAAgB;QAChB,eAAe;QACf,uBAAuB;QACvB,oBAAoB;QACpB,gBAAgB;QAChB,cAAc;QACd,eAAe;QACf,gBAAgB;QAEhB,gDAAgD;QAChD,cAAc;QACd,YAAY;QACZ,gBAAgB;QAChB,gBAAgB;KACjB,CAAC;IAEF,uEAAuE;IACvE,wEAAwE;IACxE,YAAY,EAAE,IAAI,GAAG,CAAC;QACpB,qBAAqB,EAAG,wDAAwD;QAChF,sBAAsB,EAAE,wDAAwD;KACjF,CAAC;IAEF,4EAA4E;IAC5E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OAAO,CAAC,cAAc,IAAI,OAAO,MAAM,CAAC,cAAc,KAAK,UAAU,EAAE,CAAC;QAC1E,8DAA8D;QAC9D,MAAM,CAAC,cAAc,GAAG,CAAC,KAAa,EAAE,GAAG,KAAY,EAAE,EAAE,CAAC,SAAS,CAAC;IACxE,CAAC;AACH,CAAC;AAED,6DAA6D;AAC7D,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC;AAE/D,yDAAyD;AACzD,MAAM,CAAC,MAAM,yBAAyB,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC;AAEnE,iEAAiE;AACjE,MAAM,CAAC,MAAM,8BAA8B,GAAG,iBAAiB,CAAC,IAAI,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Period close tools for the Frihet MCP server — D4-B megasprint (3 tools).
|
|
3
|
+
*
|
|
4
|
+
* Tools:
|
|
5
|
+
* 1. period_close_status — get the current accounting period state (open/closing/closed)
|
|
6
|
+
* 2. period_close — close a monthly or quarterly period (TRUST AREA)
|
|
7
|
+
* 3. period_reopen — reopen a closed period with required reason (TRUST AREA)
|
|
8
|
+
*
|
|
9
|
+
* REST surface: /v1/periods/current, /v1/periods/{id}, /v1/periods/close, /v1/periods/{id}/reopen
|
|
10
|
+
*
|
|
11
|
+
* Closing a period freezes invoices/expenses/journal entries. Reopening requires a
|
|
12
|
+
* compliance reason logged for audit. These are TRUST AREA operations.
|
|
13
|
+
*
|
|
14
|
+
* NOTE: ERP backend endpoints land in parallel D4-A wave. 404s propagate as isError
|
|
15
|
+
* until backend ships. TODO: confirm callable boundary vs REST shell for closePeriod.
|
|
16
|
+
*/
|
|
17
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
18
|
+
import type { IFrihetClient } from "../client-interface.js";
|
|
19
|
+
export declare function registerAccountingCloseTools(server: McpServer, client: IFrihetClient): void;
|
|
20
|
+
//# sourceMappingURL=accountingClose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountingClose.d.ts","sourceRoot":"","sources":["../../src/tools/accountingClose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAU5D,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAuH3F"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Period close tools for the Frihet MCP server — D4-B megasprint (3 tools).
|
|
3
|
+
*
|
|
4
|
+
* Tools:
|
|
5
|
+
* 1. period_close_status — get the current accounting period state (open/closing/closed)
|
|
6
|
+
* 2. period_close — close a monthly or quarterly period (TRUST AREA)
|
|
7
|
+
* 3. period_reopen — reopen a closed period with required reason (TRUST AREA)
|
|
8
|
+
*
|
|
9
|
+
* REST surface: /v1/periods/current, /v1/periods/{id}, /v1/periods/close, /v1/periods/{id}/reopen
|
|
10
|
+
*
|
|
11
|
+
* Closing a period freezes invoices/expenses/journal entries. Reopening requires a
|
|
12
|
+
* compliance reason logged for audit. These are TRUST AREA operations.
|
|
13
|
+
*
|
|
14
|
+
* NOTE: ERP backend endpoints land in parallel D4-A wave. 404s propagate as isError
|
|
15
|
+
* until backend ships. TODO: confirm callable boundary vs REST shell for closePeriod.
|
|
16
|
+
*/
|
|
17
|
+
import { z } from "zod/v4";
|
|
18
|
+
import { withToolLogging, formatRecord, getContent, mutateContent, READ_ONLY_ANNOTATIONS, periodStatusOutput, } from "./shared.js";
|
|
19
|
+
export function registerAccountingCloseTools(server, client) {
|
|
20
|
+
// -- period_close_status --
|
|
21
|
+
server.registerTool("period_close_status", {
|
|
22
|
+
title: "Period Close Status",
|
|
23
|
+
description: "Get the current accounting period state (open / closing / closed / reopened). " +
|
|
24
|
+
"Without periodId returns the current open or most recently closed period. " +
|
|
25
|
+
"/ Devuelve el estado del periodo contable actual (abierto/cerrando/cerrado/reabierto).",
|
|
26
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
27
|
+
inputSchema: {
|
|
28
|
+
periodId: z.string().optional().describe("Specific period ID (default: current) / ID periodo especifico"),
|
|
29
|
+
},
|
|
30
|
+
outputSchema: periodStatusOutput,
|
|
31
|
+
}, async ({ periodId }) => withToolLogging("period_close_status", async () => {
|
|
32
|
+
const result = await client.getCurrentPeriod({ periodId });
|
|
33
|
+
return {
|
|
34
|
+
content: [getContent(formatRecord("Period status", result))],
|
|
35
|
+
structuredContent: result,
|
|
36
|
+
};
|
|
37
|
+
}));
|
|
38
|
+
// -- period_close --
|
|
39
|
+
server.registerTool("period_close", {
|
|
40
|
+
title: "Close Accounting Period",
|
|
41
|
+
description: "TRUST AREA — FISCAL CLOSE. Close a monthly or quarterly accounting period. " +
|
|
42
|
+
"Freezes invoices, expenses, journal entries and bank reconciliations for the period. " +
|
|
43
|
+
"Requires confirm=true. Idempotent: re-closing an already closed period is a no-op. " +
|
|
44
|
+
"Closed periods can be reopened with period_reopen + audit reason. " +
|
|
45
|
+
"/ AREA DE CONFIANZA — CIERRE FISCAL. Cierra un periodo contable mensual o trimestral. " +
|
|
46
|
+
"Congela facturas, gastos, asientos. Requiere confirm=true.",
|
|
47
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
48
|
+
inputSchema: {
|
|
49
|
+
type: z
|
|
50
|
+
.enum(["monthly", "quarterly"])
|
|
51
|
+
.describe("Period type: monthly or quarterly / Tipo: mensual o trimestral"),
|
|
52
|
+
confirm: z
|
|
53
|
+
.boolean()
|
|
54
|
+
.describe("Must be true to perform the close / Debe ser true para ejecutar el cierre"),
|
|
55
|
+
},
|
|
56
|
+
outputSchema: periodStatusOutput,
|
|
57
|
+
}, async ({ type, confirm }) => withToolLogging("period_close", async () => {
|
|
58
|
+
if (!confirm) {
|
|
59
|
+
return {
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: "text",
|
|
63
|
+
text: "Error: confirm=true is required to close an accounting period. " +
|
|
64
|
+
"This freezes all invoices, expenses, journal entries and bank reconciliations for the period. " +
|
|
65
|
+
"Set confirm=true when you are certain. / " +
|
|
66
|
+
"Se requiere confirm=true para cerrar un periodo contable.",
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
isError: true,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const result = await client.closePeriod({ type });
|
|
73
|
+
return {
|
|
74
|
+
content: [mutateContent(formatRecord("Period closed", result))],
|
|
75
|
+
structuredContent: result,
|
|
76
|
+
};
|
|
77
|
+
}));
|
|
78
|
+
// -- period_reopen --
|
|
79
|
+
server.registerTool("period_reopen", {
|
|
80
|
+
title: "Reopen Accounting Period",
|
|
81
|
+
description: "TRUST AREA — FISCAL REOPEN. Reopen a closed accounting period. " +
|
|
82
|
+
"Requires a compliance reason (audit log) and confirm=true. " +
|
|
83
|
+
"Reopening allows backdated edits to invoices/expenses — use with extreme caution. " +
|
|
84
|
+
"/ AREA DE CONFIANZA — REAPERTURA FISCAL. Reabre un periodo cerrado. Requiere motivo (auditoria) y confirm=true.",
|
|
85
|
+
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false },
|
|
86
|
+
inputSchema: {
|
|
87
|
+
periodId: z.string().describe("Closed period ID to reopen / ID del periodo cerrado"),
|
|
88
|
+
reason: z
|
|
89
|
+
.string()
|
|
90
|
+
.min(1)
|
|
91
|
+
.describe("Required audit reason (logged) / Motivo obligatorio (auditoria)"),
|
|
92
|
+
confirm: z
|
|
93
|
+
.boolean()
|
|
94
|
+
.describe("Must be true to reopen / Debe ser true para reabrir"),
|
|
95
|
+
},
|
|
96
|
+
outputSchema: periodStatusOutput,
|
|
97
|
+
}, async ({ periodId, reason, confirm }) => withToolLogging("period_reopen", async () => {
|
|
98
|
+
if (!confirm) {
|
|
99
|
+
return {
|
|
100
|
+
content: [
|
|
101
|
+
{
|
|
102
|
+
type: "text",
|
|
103
|
+
text: "Error: confirm=true is required to reopen a closed accounting period. " +
|
|
104
|
+
"This allows backdated edits and may affect fiscal reporting. " +
|
|
105
|
+
"Set confirm=true when you are certain. / " +
|
|
106
|
+
"Se requiere confirm=true para reabrir un periodo cerrado.",
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
isError: true,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
const result = await client.reopenPeriod({ periodId, reason });
|
|
113
|
+
return {
|
|
114
|
+
content: [mutateContent(formatRecord("Period reopened", result))],
|
|
115
|
+
structuredContent: result,
|
|
116
|
+
};
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=accountingClose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accountingClose.js","sourceRoot":"","sources":["../../src/tools/accountingClose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EACL,eAAe,EACf,YAAY,EACZ,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,MAAM,UAAU,4BAA4B,CAAC,MAAiB,EAAE,MAAqB;IACnF,4BAA4B;IAE5B,MAAM,CAAC,YAAY,CACjB,qBAAqB,EACrB;QACE,KAAK,EAAE,qBAAqB;QAC5B,WAAW,EACT,gFAAgF;YAChF,4EAA4E;YAC5E,wFAAwF;QAC1F,WAAW,EAAE,qBAAqB;QAClC,WAAW,EAAE;YACX,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+DAA+D,CAAC;SAC1G;QACD,YAAY,EAAE,kBAAkB;KACjC,EACD,KAAK,EAAE,EAAE,QAAQ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,EAAE,MAAM,EAAE,CAAC,CAAC;QAC/D,OAAO;YACL,OAAO,EAAE,CAAC,aAAa,CAAC,YAAY,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC,CAAC;YACjE,iBAAiB,EAAE,MAA4C;SAChE,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit GL tools for the Frihet MCP server — Day 1 Megasprint (3 tools).
|
|
3
|
+
*
|
|
4
|
+
* Tools:
|
|
5
|
+
* 1. frihet_gl_entry_approve — approve a GL journal entry (TRUST AREA)
|
|
6
|
+
* 2. frihet_gl_entry_reject — reject a GL journal entry with reason (TRUST AREA)
|
|
7
|
+
* 3. frihet_gl_entry_audit_log — retrieve the audit trail for a GL entry
|
|
8
|
+
*
|
|
9
|
+
* REST surface: /v1/gl/* proxies Firebase callables:
|
|
10
|
+
* approveGLEntry, rejectGLEntry, getGLEntryAuditLog (eu-west1)
|
|
11
|
+
*
|
|
12
|
+
* Backend status (post-Day 1 Megasprint, May 2026):
|
|
13
|
+
* Frihet-ERP PR #395 — Audit GL approval workflow MERGED.
|
|
14
|
+
* Tools will surface 404 errors until backend REST shell ships.
|
|
15
|
+
*/
|
|
16
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
17
|
+
import type { IFrihetClient } from "../client-interface.js";
|
|
18
|
+
export declare function registerAuditGLTools(server: McpServer, client: IFrihetClient): void;
|
|
19
|
+
//# sourceMappingURL=audit_gl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit_gl.d.ts","sourceRoot":"","sources":["../../src/tools/audit_gl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAU5D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CA2FnF"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit GL tools for the Frihet MCP server — Day 1 Megasprint (3 tools).
|
|
3
|
+
*
|
|
4
|
+
* Tools:
|
|
5
|
+
* 1. frihet_gl_entry_approve — approve a GL journal entry (TRUST AREA)
|
|
6
|
+
* 2. frihet_gl_entry_reject — reject a GL journal entry with reason (TRUST AREA)
|
|
7
|
+
* 3. frihet_gl_entry_audit_log — retrieve the audit trail for a GL entry
|
|
8
|
+
*
|
|
9
|
+
* REST surface: /v1/gl/* proxies Firebase callables:
|
|
10
|
+
* approveGLEntry, rejectGLEntry, getGLEntryAuditLog (eu-west1)
|
|
11
|
+
*
|
|
12
|
+
* Backend status (post-Day 1 Megasprint, May 2026):
|
|
13
|
+
* Frihet-ERP PR #395 — Audit GL approval workflow MERGED.
|
|
14
|
+
* Tools will surface 404 errors until backend REST shell ships.
|
|
15
|
+
*/
|
|
16
|
+
import { z } from "zod/v4";
|
|
17
|
+
import { withToolLogging, formatRecord, getContent, mutateContent, READ_ONLY_ANNOTATIONS, UPDATE_ANNOTATIONS, } from "./shared.js";
|
|
18
|
+
export function registerAuditGLTools(server, client) {
|
|
19
|
+
// -- frihet_gl_entry_approve -----------------------------------------------
|
|
20
|
+
server.registerTool("frihet_gl_entry_approve", {
|
|
21
|
+
title: "Approve GL Entry",
|
|
22
|
+
description: "Approve a General Ledger journal entry pending review. " +
|
|
23
|
+
"Sets entry status to 'approved' and records the approver + timestamp in the audit trail. " +
|
|
24
|
+
"Requires gestor/admin role. This is a TRUST AREA action — double-check entry ID before calling. " +
|
|
25
|
+
"Example: entryId='gl_2026_q1_042'. " +
|
|
26
|
+
"/ Aprueba un asiento contable pendiente de revision. " +
|
|
27
|
+
"Requiere rol gestor/admin. Accion de area de confianza.",
|
|
28
|
+
annotations: UPDATE_ANNOTATIONS,
|
|
29
|
+
inputSchema: {
|
|
30
|
+
entryId: z.string().describe("GL entry ID to approve / ID del asiento contable a aprobar"),
|
|
31
|
+
notes: z.string().optional().describe("Optional approval notes / Notas de aprobacion opcionales"),
|
|
32
|
+
},
|
|
33
|
+
}, async ({ entryId, notes }) => withToolLogging("frihet_gl_entry_approve", async () => {
|
|
34
|
+
const result = await client.approveGLEntry(entryId, notes);
|
|
35
|
+
return {
|
|
36
|
+
content: [
|
|
37
|
+
mutateContent(formatRecord(`GL Entry ${entryId} approved`, result)),
|
|
38
|
+
],
|
|
39
|
+
structuredContent: result,
|
|
40
|
+
};
|
|
41
|
+
}));
|
|
42
|
+
// -- frihet_gl_entry_reject ------------------------------------------------
|
|
43
|
+
server.registerTool("frihet_gl_entry_reject", {
|
|
44
|
+
title: "Reject GL Entry",
|
|
45
|
+
description: "Reject a General Ledger journal entry pending review with a required reason. " +
|
|
46
|
+
"Sets entry status to 'rejected' and records the rejector + reason in the audit trail. " +
|
|
47
|
+
"Requires gestor/admin role. This is a TRUST AREA action. " +
|
|
48
|
+
"Example: entryId='gl_2026_q1_042', reason='Importe incorrecto, revisar factura F-2026-042'. " +
|
|
49
|
+
"/ Rechaza un asiento contable pendiente con una razon obligatoria. " +
|
|
50
|
+
"Requiere rol gestor/admin.",
|
|
51
|
+
annotations: UPDATE_ANNOTATIONS,
|
|
52
|
+
inputSchema: {
|
|
53
|
+
entryId: z.string().describe("GL entry ID to reject / ID del asiento contable a rechazar"),
|
|
54
|
+
reason: z.string().describe("Mandatory rejection reason (visible to submitter) / Razon del rechazo (obligatoria, visible al emisor)"),
|
|
55
|
+
},
|
|
56
|
+
}, async ({ entryId, reason }) => withToolLogging("frihet_gl_entry_reject", async () => {
|
|
57
|
+
const result = await client.rejectGLEntry(entryId, reason);
|
|
58
|
+
return {
|
|
59
|
+
content: [
|
|
60
|
+
mutateContent(formatRecord(`GL Entry ${entryId} rejected`, result)),
|
|
61
|
+
],
|
|
62
|
+
structuredContent: result,
|
|
63
|
+
};
|
|
64
|
+
}));
|
|
65
|
+
// -- frihet_gl_entry_audit_log ---------------------------------------------
|
|
66
|
+
server.registerTool("frihet_gl_entry_audit_log", {
|
|
67
|
+
title: "Get GL Entry Audit Log",
|
|
68
|
+
description: "Retrieve the full audit trail for a General Ledger entry — all state transitions " +
|
|
69
|
+
"(created, submitted, approved, rejected), who acted, and when. " +
|
|
70
|
+
"Use this to investigate approval history or compliance audits. " +
|
|
71
|
+
"Example: entryId='gl_2026_q1_042'. " +
|
|
72
|
+
"/ Obtiene el historial de auditoría completo de un asiento contable. " +
|
|
73
|
+
"Muestra todas las transiciones de estado, quien actuo y cuando.",
|
|
74
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
75
|
+
inputSchema: {
|
|
76
|
+
entryId: z.string().describe("GL entry ID / ID del asiento contable"),
|
|
77
|
+
},
|
|
78
|
+
}, async ({ entryId }) => withToolLogging("frihet_gl_entry_audit_log", async () => {
|
|
79
|
+
const result = await client.getGLEntryAuditLog(entryId);
|
|
80
|
+
return {
|
|
81
|
+
content: [getContent(formatRecord(`Audit Log for GL Entry ${entryId}`, result))],
|
|
82
|
+
structuredContent: result,
|
|
83
|
+
};
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=audit_gl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit_gl.js","sourceRoot":"","sources":["../../src/tools/audit_gl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EACL,eAAe,EACf,YAAY,EACZ,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,MAAM,UAAU,oBAAoB,CAAC,MAAiB,EAAE,MAAqB;IAC3E,6EAA6E;IAE7E,MAAM,CAAC,YAAY,CACjB,yBAAyB,EACzB;QACE,KAAK,EAAE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,MAAM,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC3D,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,CACX,YAAY,CAAC,YAAY,OAAO,WAAW,EAAE,MAAM,CAAC,CACrD;aACF;YACD,iBAAiB,EAAE,MAA4C;SAChE,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;IAEF,6EAA6E;IAE7E,MAAM,CAAC,YAAY,CACjB,2BAA2B,EAC3B;QACE,KAAK,EAAE,wBAAwB;QAC/B,WAAW,EACT,mFAAmF;YACnF,iEAAiE;YACjE,iEAAiE;YACjE,qCAAqC;YACrC,uEAAuE;YACvE,iEAAiE;QACnE,WAAW,EAAE,qBAAqB;QAClC,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;SACtE;KACF,EACD,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,eAAe,CAAC,2BAA2B,EAAE,KAAK,IAAI,EAAE;QAC7E,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACxD,OAAO;YACL,OAAO,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,0BAA0B,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;YAChF,iBAAiB,EAAE,MAA4C;SAChE,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bank rules tools for the Frihet MCP server — Day 1 Megasprint (2 tools).
|
|
3
|
+
*
|
|
4
|
+
* Tools:
|
|
5
|
+
* 1. frihet_bank_rules_list — list bank auto-categorization rules for the workspace
|
|
6
|
+
* 2. frihet_bank_rule_create — create a new bank categorization rule
|
|
7
|
+
*
|
|
8
|
+
* Skipped (external webhook handlers, not MCP-callable):
|
|
9
|
+
* - plaidWebhook — Plaid inbound webhook
|
|
10
|
+
* - tinkWebhook — Tink/Revolut inbound webhook
|
|
11
|
+
*
|
|
12
|
+
* REST surface: /v1/banking/rules — admin-side rule management.
|
|
13
|
+
* Backend callables: #394 Banking Q3 flag (Frihet-ERP PR #394).
|
|
14
|
+
* Tools surface 404 until backend callable wrapper ships.
|
|
15
|
+
*
|
|
16
|
+
* NOTE: Bank rules are Q3-flagged in Frihet-ERP. These tools are wired here
|
|
17
|
+
* so AI agents can read + create rules once the backend ships, without an MCP
|
|
18
|
+
* bump. Backend may still be Firestore-direct writes; tools will 404 gracefully.
|
|
19
|
+
*/
|
|
20
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
21
|
+
import type { IFrihetClient } from "../client-interface.js";
|
|
22
|
+
export declare function registerBankRulesTools(server: McpServer, client: IFrihetClient): void;
|
|
23
|
+
//# sourceMappingURL=bank_rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bank_rules.d.ts","sourceRoot":"","sources":["../../src/tools/bank_rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AA+B5D,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CA2ErF"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bank rules tools for the Frihet MCP server — Day 1 Megasprint (2 tools).
|
|
3
|
+
*
|
|
4
|
+
* Tools:
|
|
5
|
+
* 1. frihet_bank_rules_list — list bank auto-categorization rules for the workspace
|
|
6
|
+
* 2. frihet_bank_rule_create — create a new bank categorization rule
|
|
7
|
+
*
|
|
8
|
+
* Skipped (external webhook handlers, not MCP-callable):
|
|
9
|
+
* - plaidWebhook — Plaid inbound webhook
|
|
10
|
+
* - tinkWebhook — Tink/Revolut inbound webhook
|
|
11
|
+
*
|
|
12
|
+
* REST surface: /v1/banking/rules — admin-side rule management.
|
|
13
|
+
* Backend callables: #394 Banking Q3 flag (Frihet-ERP PR #394).
|
|
14
|
+
* Tools surface 404 until backend callable wrapper ships.
|
|
15
|
+
*
|
|
16
|
+
* NOTE: Bank rules are Q3-flagged in Frihet-ERP. These tools are wired here
|
|
17
|
+
* so AI agents can read + create rules once the backend ships, without an MCP
|
|
18
|
+
* bump. Backend may still be Firestore-direct writes; tools will 404 gracefully.
|
|
19
|
+
*/
|
|
20
|
+
import { z } from "zod/v4";
|
|
21
|
+
import { withToolLogging, formatPaginatedResponse, formatRecord, listContent, mutateContent, READ_ONLY_ANNOTATIONS, CREATE_ANNOTATIONS, paginatedOutput, } from "./shared.js";
|
|
22
|
+
const bankRuleItemOutput = z.object({
|
|
23
|
+
id: z.string(),
|
|
24
|
+
name: z.string(),
|
|
25
|
+
conditions: z.array(z.object({
|
|
26
|
+
field: z.string(),
|
|
27
|
+
operator: z.string(),
|
|
28
|
+
value: z.string(),
|
|
29
|
+
})).optional(),
|
|
30
|
+
actions: z.array(z.object({
|
|
31
|
+
type: z.string(),
|
|
32
|
+
value: z.string(),
|
|
33
|
+
})).optional(),
|
|
34
|
+
isActive: z.boolean().optional(),
|
|
35
|
+
createdAt: z.string().optional(),
|
|
36
|
+
}).passthrough();
|
|
37
|
+
const CONDITION_FIELD = z.enum(["description", "amount", "counterparty", "iban", "reference"]);
|
|
38
|
+
const CONDITION_OPERATOR = z.enum(["contains", "startsWith", "endsWith", "equals", "greaterThan", "lessThan"]);
|
|
39
|
+
export function registerBankRulesTools(server, client) {
|
|
40
|
+
// -- frihet_bank_rules_list -----------------------------------------------
|
|
41
|
+
server.registerTool("frihet_bank_rules_list", {
|
|
42
|
+
title: "List Bank Categorization Rules",
|
|
43
|
+
description: "List all bank auto-categorization rules for the workspace. " +
|
|
44
|
+
"Rules automatically categorize transactions matching conditions (description, amount, counterparty). " +
|
|
45
|
+
"Returns rule name, conditions, actions (category/tag/client assign), and active status. " +
|
|
46
|
+
"/ Lista las reglas de categorizacion automatica de transacciones bancarias del workspace. " +
|
|
47
|
+
"Devuelve nombre, condiciones, acciones (categoria/etiqueta/cliente) y estado activo.",
|
|
48
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
49
|
+
inputSchema: {
|
|
50
|
+
isActive: z.boolean().optional().describe("Filter by active/inactive rules / Filtrar por reglas activas/inactivas"),
|
|
51
|
+
limit: z.number().int().min(1).max(100).optional().describe("Max results / Resultados maximos"),
|
|
52
|
+
offset: z.number().int().min(0).optional().describe("Offset / Desplazamiento"),
|
|
53
|
+
},
|
|
54
|
+
outputSchema: paginatedOutput(bankRuleItemOutput),
|
|
55
|
+
}, async ({ isActive, limit, offset }) => withToolLogging("frihet_bank_rules_list", async () => {
|
|
56
|
+
const result = await client.listBankRules({ isActive, limit, offset });
|
|
57
|
+
return {
|
|
58
|
+
content: [listContent(formatPaginatedResponse("bank_rules", result))],
|
|
59
|
+
structuredContent: result,
|
|
60
|
+
};
|
|
61
|
+
}));
|
|
62
|
+
// -- frihet_bank_rule_create ----------------------------------------------
|
|
63
|
+
server.registerTool("frihet_bank_rule_create", {
|
|
64
|
+
title: "Create Bank Categorization Rule",
|
|
65
|
+
description: "Create a new bank auto-categorization rule. " +
|
|
66
|
+
"Rules apply automatically to matching incoming transactions. " +
|
|
67
|
+
"A rule has conditions (AND logic) and actions (assign category, tag, or client). " +
|
|
68
|
+
"Example: name='Mercadona groceries', condition description contains 'MERCADONA', " +
|
|
69
|
+
"action category='groceries'. " +
|
|
70
|
+
"/ Crea una nueva regla de categorizacion automatica de transacciones bancarias. " +
|
|
71
|
+
"Las reglas aplican condiciones (logica AND) y acciones (categoria, etiqueta, cliente).",
|
|
72
|
+
annotations: CREATE_ANNOTATIONS,
|
|
73
|
+
inputSchema: {
|
|
74
|
+
name: z.string().describe("Rule name for identification / Nombre de la regla"),
|
|
75
|
+
conditions: z.array(z.object({
|
|
76
|
+
field: CONDITION_FIELD.describe("Transaction field to match / Campo de transaccion a comparar"),
|
|
77
|
+
operator: CONDITION_OPERATOR.describe("Comparison operator / Operador de comparacion"),
|
|
78
|
+
value: z.string().describe("Value to match against / Valor a comparar"),
|
|
79
|
+
})).min(1).describe("Rule conditions (AND logic — all must match) / Condiciones (logica AND — todas deben cumplirse)"),
|
|
80
|
+
actions: z.array(z.object({
|
|
81
|
+
type: z.enum(["setCategory", "addTag", "assignClient"]).describe("Action type / Tipo de accion"),
|
|
82
|
+
value: z.string().describe("Action value (category name, tag name, or client ID) / Valor de la accion"),
|
|
83
|
+
})).min(1).describe("Actions to apply when rule matches / Acciones a aplicar cuando la regla se cumple"),
|
|
84
|
+
isActive: z.boolean().optional().describe("Whether the rule is active (default true) / Si la regla esta activa (por defecto true)"),
|
|
85
|
+
},
|
|
86
|
+
}, async ({ name, conditions, actions, isActive }) => withToolLogging("frihet_bank_rule_create", async () => {
|
|
87
|
+
const result = await client.createBankRule({ name, conditions, actions, isActive });
|
|
88
|
+
return {
|
|
89
|
+
content: [
|
|
90
|
+
mutateContent(formatRecord(`Bank rule created: ${name}`, result)),
|
|
91
|
+
],
|
|
92
|
+
structuredContent: result,
|
|
93
|
+
};
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=bank_rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bank_rules.js","sourceRoot":"","sources":["../../src/tools/bank_rules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;I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