@frihet/mcp-server 1.0.1 → 1.2.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/dist/index.js +30 -1
- package/dist/index.js.map +1 -1
- package/dist/prompts/register-all.d.ts +10 -0
- package/dist/prompts/register-all.d.ts.map +1 -0
- package/dist/prompts/register-all.js +271 -0
- package/dist/prompts/register-all.js.map +1 -0
- package/dist/resources/register-all.d.ts +12 -0
- package/dist/resources/register-all.d.ts.map +1 -0
- package/dist/resources/register-all.js +345 -0
- package/dist/resources/register-all.js.map +1 -0
- package/dist/tools/clients.d.ts.map +1 -1
- package/dist/tools/clients.js +21 -6
- package/dist/tools/clients.js.map +1 -1
- package/dist/tools/expenses.d.ts.map +1 -1
- package/dist/tools/expenses.js +21 -6
- package/dist/tools/expenses.js.map +1 -1
- package/dist/tools/invoices.d.ts.map +1 -1
- package/dist/tools/invoices.js +25 -10
- package/dist/tools/invoices.js.map +1 -1
- package/dist/tools/products.d.ts.map +1 -1
- package/dist/tools/products.js +21 -6
- package/dist/tools/products.js.map +1 -1
- package/dist/tools/quotes.d.ts.map +1 -1
- package/dist/tools/quotes.js +21 -6
- package/dist/tools/quotes.js.map +1 -1
- package/dist/tools/shared.d.ts +125 -5
- package/dist/tools/shared.d.ts.map +1 -1
- package/dist/tools/shared.js +165 -7
- package/dist/tools/shared.js.map +1 -1
- package/dist/tools/webhooks.d.ts.map +1 -1
- package/dist/tools/webhooks.js +21 -6
- package/dist/tools/webhooks.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static MCP Resources for the Frihet ERP server.
|
|
3
|
+
*
|
|
4
|
+
* Resources are read-only reference data that LLMs can access without making
|
|
5
|
+
* API calls. They encode domain knowledge (tax rates, deadlines, categories)
|
|
6
|
+
* that would otherwise require the user to explain every time.
|
|
7
|
+
*
|
|
8
|
+
* All resources use the `frihet://` URI scheme.
|
|
9
|
+
*/
|
|
10
|
+
/* ------------------------------------------------------------------ */
|
|
11
|
+
/* Static data */
|
|
12
|
+
/* ------------------------------------------------------------------ */
|
|
13
|
+
const API_SCHEMA_SUMMARY = `Frihet ERP REST API — OpenAPI 3.1
|
|
14
|
+
Base URL: https://api.frihet.io/v1
|
|
15
|
+
Docs: https://docs.frihet.io/desarrolladores/api-reference
|
|
16
|
+
|
|
17
|
+
Authentication:
|
|
18
|
+
Header: X-API-Key
|
|
19
|
+
Format: fri_<key>
|
|
20
|
+
|
|
21
|
+
Rate limits:
|
|
22
|
+
100 requests/minute per API key
|
|
23
|
+
Burst: 10 requests/second
|
|
24
|
+
Response header: Retry-After (seconds) on 429
|
|
25
|
+
|
|
26
|
+
Endpoints:
|
|
27
|
+
GET /invoices — List invoices (paginated)
|
|
28
|
+
GET /invoices/:id — Get invoice by ID
|
|
29
|
+
POST /invoices — Create invoice
|
|
30
|
+
PUT /invoices/:id — Update invoice
|
|
31
|
+
DELETE /invoices/:id — Delete invoice
|
|
32
|
+
|
|
33
|
+
GET /expenses — List expenses (paginated)
|
|
34
|
+
GET /expenses/:id — Get expense by ID
|
|
35
|
+
POST /expenses — Create expense
|
|
36
|
+
PUT /expenses/:id — Update expense
|
|
37
|
+
DELETE /expenses/:id — Delete expense
|
|
38
|
+
|
|
39
|
+
GET /clients — List clients (paginated)
|
|
40
|
+
GET /clients/:id — Get client by ID
|
|
41
|
+
POST /clients — Create client
|
|
42
|
+
PUT /clients/:id — Update client
|
|
43
|
+
DELETE /clients/:id — Delete client
|
|
44
|
+
|
|
45
|
+
GET /products — List products (paginated)
|
|
46
|
+
GET /products/:id — Get product by ID
|
|
47
|
+
POST /products — Create product
|
|
48
|
+
PUT /products/:id — Update product
|
|
49
|
+
DELETE /products/:id — Delete product
|
|
50
|
+
|
|
51
|
+
GET /quotes — List quotes (paginated)
|
|
52
|
+
GET /quotes/:id — Get quote by ID
|
|
53
|
+
POST /quotes — Create quote
|
|
54
|
+
PUT /quotes/:id — Update quote
|
|
55
|
+
DELETE /quotes/:id — Delete quote
|
|
56
|
+
|
|
57
|
+
GET /webhooks — List webhooks (paginated)
|
|
58
|
+
GET /webhooks/:id — Get webhook by ID
|
|
59
|
+
POST /webhooks — Create webhook
|
|
60
|
+
PUT /webhooks/:id — Update webhook
|
|
61
|
+
DELETE /webhooks/:id — Delete webhook
|
|
62
|
+
|
|
63
|
+
Pagination:
|
|
64
|
+
Query params: limit (1-100, default 50), offset (default 0)
|
|
65
|
+
Response: { data: [...], total: number, limit: number, offset: number }
|
|
66
|
+
|
|
67
|
+
Error responses:
|
|
68
|
+
400 — Bad request (validation error)
|
|
69
|
+
401 — Invalid or missing API key
|
|
70
|
+
403 — Insufficient permissions
|
|
71
|
+
404 — Resource not found
|
|
72
|
+
429 — Rate limit exceeded
|
|
73
|
+
500 — Internal server error
|
|
74
|
+
|
|
75
|
+
Content-Type: application/json
|
|
76
|
+
All monetary values in EUR (cents not used — decimal euros).
|
|
77
|
+
Dates in ISO 8601 format (YYYY-MM-DD or full datetime).`;
|
|
78
|
+
const TAX_RATES = `Spanish Tax Rates by Fiscal Zone
|
|
79
|
+
================================
|
|
80
|
+
|
|
81
|
+
PENINSULA & BALEARIC ISLANDS — IVA (Impuesto sobre el Valor Añadido)
|
|
82
|
+
General: 21% — Most goods and services
|
|
83
|
+
Reduced: 10% — Food, transport, hospitality, renovation
|
|
84
|
+
Super-reduced: 4% — Bread, milk, eggs, fruit, vegetables, books, medicines, wheelchairs
|
|
85
|
+
Exempt: 0% — Education, healthcare, financial services, insurance, postal
|
|
86
|
+
|
|
87
|
+
CANARY ISLANDS — IGIC (Impuesto General Indirecto Canario)
|
|
88
|
+
General: 7% — Most goods and services
|
|
89
|
+
Reduced: 3% — Food, water, transport, hospitality
|
|
90
|
+
Zero: 0% — Basic food (bread, milk, eggs, fruit, vegetables), books, medicines
|
|
91
|
+
Increased: 9.5% — Vehicles, jewelry, electronics >€1,000
|
|
92
|
+
Special: 15% — Tobacco
|
|
93
|
+
Exempt: 0% — Education, healthcare, financial services
|
|
94
|
+
|
|
95
|
+
CEUTA & MELILLA — IPSI (Impuesto sobre la Producción, los Servicios y la Importación)
|
|
96
|
+
General: 10% — Most goods and services
|
|
97
|
+
Reduced: 2% — Basic food, water
|
|
98
|
+
Intermediate: 5% — Other food, hospitality
|
|
99
|
+
Increased: 8% — Vehicles, electronics
|
|
100
|
+
Special: 10% — Tobacco, alcohol
|
|
101
|
+
|
|
102
|
+
EU INTRA-COMMUNITY — Reverse Charge
|
|
103
|
+
B2B: 0% — Buyer self-assesses VAT in their country (reverse charge / inversión del sujeto pasivo)
|
|
104
|
+
B2C: Destination country rate — Via OSS (One-Stop Shop) if >€10,000/year
|
|
105
|
+
|
|
106
|
+
INTERNATIONAL (outside EU)
|
|
107
|
+
Exports: 0% — Exempt with right to deduction (exención plena)
|
|
108
|
+
Imports: Destination country duties + VAT at border
|
|
109
|
+
|
|
110
|
+
WITHHOLDING TAX — IRPF (professionals / autónomos)
|
|
111
|
+
Standard: 15% — Retention on professional invoices
|
|
112
|
+
New freelancer: 7% — First 3 full calendar years of activity
|
|
113
|
+
Applies to: Professional services invoiced to other businesses (B2B)
|
|
114
|
+
|
|
115
|
+
SPECIAL REGIMES
|
|
116
|
+
Equivalence surcharge (recargo de equivalencia): +5.2% / +1.4% / +0.5% on IVA rates
|
|
117
|
+
Applies to: Retail businesses (comercio minorista) buying from wholesalers
|
|
118
|
+
Simplified regime: Fixed quarterly quotas based on activity modules
|
|
119
|
+
Agriculture: 12% / 10.5% flat-rate compensation`;
|
|
120
|
+
const TAX_CALENDAR = `Spanish Quarterly Tax Calendar
|
|
121
|
+
===============================
|
|
122
|
+
|
|
123
|
+
All deadlines apply to the corresponding fiscal quarter unless noted.
|
|
124
|
+
|
|
125
|
+
Q1 (January–March) — File by April 20
|
|
126
|
+
Modelo 303 — IVA quarterly return (autoliquidación trimestral IVA)
|
|
127
|
+
Modelo 130 — IRPF quarterly advance payment (pago fraccionado IRPF)
|
|
128
|
+
Modelo 349 — Intra-community operations summary (if applicable)
|
|
129
|
+
Modelo 115 — Withholding on rental payments (if applicable)
|
|
130
|
+
|
|
131
|
+
Q2 (April–June) — File by July 20
|
|
132
|
+
Modelo 303 — IVA quarterly return
|
|
133
|
+
Modelo 130 — IRPF quarterly advance payment
|
|
134
|
+
Modelo 349 — Intra-community operations (if applicable)
|
|
135
|
+
Modelo 115 — Rental withholdings (if applicable)
|
|
136
|
+
|
|
137
|
+
Q3 (July–September) — File by October 20
|
|
138
|
+
Modelo 303 — IVA quarterly return
|
|
139
|
+
Modelo 130 — IRPF quarterly advance payment
|
|
140
|
+
Modelo 349 — Intra-community operations (if applicable)
|
|
141
|
+
Modelo 115 — Rental withholdings (if applicable)
|
|
142
|
+
|
|
143
|
+
Q4 (October–December) — File by January 30 (next year)
|
|
144
|
+
Modelo 303 — IVA quarterly return
|
|
145
|
+
Modelo 130 — IRPF quarterly advance payment
|
|
146
|
+
Modelo 349 — Intra-community operations (if applicable)
|
|
147
|
+
Modelo 115 — Rental withholdings (if applicable)
|
|
148
|
+
|
|
149
|
+
ANNUAL RETURNS — File by January 30
|
|
150
|
+
Modelo 390 — Annual IVA summary (resumen anual IVA)
|
|
151
|
+
Modelo 180 — Annual rental withholdings summary
|
|
152
|
+
Modelo 190 — Annual professional withholdings summary (IRPF retenciones)
|
|
153
|
+
|
|
154
|
+
ANNUAL INCOME TAX — File April 1 – June 30
|
|
155
|
+
Modelo 100 — Personal income tax return (Renta / IRPF)
|
|
156
|
+
|
|
157
|
+
CANARY ISLANDS (IGIC instead of IVA)
|
|
158
|
+
Modelo 420 — IGIC quarterly return (same deadlines as Modelo 303)
|
|
159
|
+
Modelo 425 — Annual IGIC summary (same deadline as Modelo 390)
|
|
160
|
+
Filed with ATC (Administración Tributaria Canaria), NOT AEAT
|
|
161
|
+
|
|
162
|
+
VERIFACTU (mandatory e-invoicing, phased rollout)
|
|
163
|
+
2026: Voluntary adoption
|
|
164
|
+
2027: Mandatory for large companies
|
|
165
|
+
2028: Mandatory for all businesses
|
|
166
|
+
|
|
167
|
+
KEY DATES SUMMARY
|
|
168
|
+
Apr 20 — Q1 filings
|
|
169
|
+
Jul 20 — Q2 filings
|
|
170
|
+
Oct 20 — Q3 filings
|
|
171
|
+
Jan 30 — Q4 filings + annual summaries (390, 180, 190)
|
|
172
|
+
Apr 1–Jun 30 — Annual income tax (Modelo 100)`;
|
|
173
|
+
const EXPENSE_CATEGORIES = `Frihet Expense Categories & Deductibility Rules
|
|
174
|
+
=================================================
|
|
175
|
+
|
|
176
|
+
1. OFFICE (oficina)
|
|
177
|
+
Examples: Rent, utilities, internet, phone, office supplies, cleaning
|
|
178
|
+
Deductibility: 100% if exclusively for business use
|
|
179
|
+
Mixed use: Proportional deduction (e.g., home office = % of m²)
|
|
180
|
+
IVA deductible: Yes (with invoice)
|
|
181
|
+
|
|
182
|
+
2. TRAVEL (viajes)
|
|
183
|
+
Examples: Flights, trains, taxis, hotel, car rental, fuel, tolls, parking
|
|
184
|
+
Deductibility: 100% if business-related
|
|
185
|
+
Meals during travel: Max €26.67/day (Spain), €48.08/day (abroad)
|
|
186
|
+
IVA deductible: Yes (except parking meters, some tolls)
|
|
187
|
+
|
|
188
|
+
3. SOFTWARE (software)
|
|
189
|
+
Examples: SaaS subscriptions, licenses, hosting, domains, cloud services
|
|
190
|
+
Deductibility: 100% as operating expense
|
|
191
|
+
IVA deductible: Yes (EU reverse charge for non-Spanish providers)
|
|
192
|
+
Note: If >€300/unit, may need to amortize over 3 years
|
|
193
|
+
|
|
194
|
+
4. MARKETING (marketing)
|
|
195
|
+
Examples: Advertising, social media ads, design, print materials, events, sponsorship
|
|
196
|
+
Deductibility: 100% as operating expense
|
|
197
|
+
IVA deductible: Yes
|
|
198
|
+
Note: Gifts to clients deductible up to 1% of net revenue
|
|
199
|
+
|
|
200
|
+
5. PROFESSIONAL (servicios profesionales)
|
|
201
|
+
Examples: Legal fees, accounting, consulting, freelancers, subcontractors
|
|
202
|
+
Deductibility: 100%
|
|
203
|
+
IRPF withholding: Provider should apply 15% (or 7% if new freelancer)
|
|
204
|
+
IVA deductible: Yes
|
|
205
|
+
|
|
206
|
+
6. EQUIPMENT (equipamiento)
|
|
207
|
+
Examples: Computers, monitors, furniture, phones, machinery
|
|
208
|
+
Deductibility: Amortization (not instant deduction if >€300)
|
|
209
|
+
Amortization: Computers 25%/yr (4yr), furniture 10%/yr (10yr), vehicles 16%/yr
|
|
210
|
+
IVA deductible: Yes (vehicles: 50% unless exclusively business)
|
|
211
|
+
Freelancer benefit: Items <€300 can be fully expensed in the year
|
|
212
|
+
|
|
213
|
+
7. INSURANCE (seguros)
|
|
214
|
+
Examples: Professional liability, health (autónomo), property, cyber, D&O
|
|
215
|
+
Deductibility: 100% if business-related
|
|
216
|
+
Health insurance: Deductible up to €500/person/year for autónomos + family
|
|
217
|
+
IVA: Insurance is IVA-exempt (no input IVA to deduct)
|
|
218
|
+
|
|
219
|
+
8. OTHER (otros)
|
|
220
|
+
Examples: Bank fees, taxes (non-income), fines, donations, miscellaneous
|
|
221
|
+
Deductibility: Varies
|
|
222
|
+
NOT deductible: Fines, penalties, personal expenses, income tax itself
|
|
223
|
+
Bank fees: 100% deductible
|
|
224
|
+
Donations: Deduction in IRPF (not expense), 80% of first €250 + 40% rest`;
|
|
225
|
+
const INVOICE_STATUSES = `Frihet Invoice Status Flow
|
|
226
|
+
===========================
|
|
227
|
+
|
|
228
|
+
Statuses and transitions:
|
|
229
|
+
|
|
230
|
+
DRAFT ──────► SENT ──────► PAID
|
|
231
|
+
│ │
|
|
232
|
+
│ └──────► OVERDUE ────► PAID
|
|
233
|
+
│ │
|
|
234
|
+
│ └────────► CANCELLED
|
|
235
|
+
│
|
|
236
|
+
└─────────────────────────────────► CANCELLED
|
|
237
|
+
|
|
238
|
+
Status definitions:
|
|
239
|
+
|
|
240
|
+
draft — Invoice created but not yet sent to client.
|
|
241
|
+
Can be freely edited. No fiscal implications yet.
|
|
242
|
+
This is the default status for new invoices.
|
|
243
|
+
|
|
244
|
+
sent — Invoice delivered to the client (email, PDF, etc.).
|
|
245
|
+
Payment is expected. The invoice number and date become
|
|
246
|
+
fiscally relevant — avoid modifications after this point.
|
|
247
|
+
|
|
248
|
+
paid — Payment received in full. Terminal state.
|
|
249
|
+
Records the payment date. Invoice is complete.
|
|
250
|
+
|
|
251
|
+
overdue — Payment deadline (dueDate) has passed without payment.
|
|
252
|
+
Triggers follow-up workflows. Can transition to paid
|
|
253
|
+
(late payment) or cancelled (write-off / bad debt).
|
|
254
|
+
|
|
255
|
+
cancelled — Invoice voided. Requires a corrective invoice or
|
|
256
|
+
credit note for fiscal compliance if previously sent.
|
|
257
|
+
Terminal state. Cannot transition to other statuses.
|
|
258
|
+
|
|
259
|
+
Automation rules (when configured):
|
|
260
|
+
- Auto-transition sent → overdue when dueDate passes (daily check)
|
|
261
|
+
- Webhook events: invoice.created, invoice.sent, invoice.paid,
|
|
262
|
+
invoice.overdue, invoice.cancelled
|
|
263
|
+
- Overdue reminders can be configured per-client
|
|
264
|
+
|
|
265
|
+
Best practices:
|
|
266
|
+
- Always set a dueDate when creating invoices (default: 30 days)
|
|
267
|
+
- Use draft status while iterating with the client
|
|
268
|
+
- Once sent, create a new corrective invoice rather than editing
|
|
269
|
+
- For partial payments, keep status as sent until full payment
|
|
270
|
+
- cancelled requires a reason (notes field) for audit trail`;
|
|
271
|
+
/* ------------------------------------------------------------------ */
|
|
272
|
+
/* Registration */
|
|
273
|
+
/* ------------------------------------------------------------------ */
|
|
274
|
+
export function registerAllResources(server) {
|
|
275
|
+
server.registerResource("api-schema", "frihet://api/schema", {
|
|
276
|
+
description: "OpenAPI schema summary: all endpoints, authentication method, rate limits, pagination, and error codes. " +
|
|
277
|
+
"/ Resumen del esquema OpenAPI: endpoints, autenticación, límites, paginación y errores.",
|
|
278
|
+
mimeType: "text/plain",
|
|
279
|
+
}, async () => ({
|
|
280
|
+
contents: [
|
|
281
|
+
{
|
|
282
|
+
uri: "frihet://api/schema",
|
|
283
|
+
mimeType: "text/plain",
|
|
284
|
+
text: API_SCHEMA_SUMMARY,
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
}));
|
|
288
|
+
server.registerResource("tax-rates", "frihet://tax/rates", {
|
|
289
|
+
description: "Current tax rates by Spanish fiscal zone: Peninsula IVA (21/10/4%), Canary Islands IGIC (7/3/0%), " +
|
|
290
|
+
"Ceuta IPSI, EU reverse charge, international exports, IRPF withholding, and special regimes. " +
|
|
291
|
+
"/ Tipos impositivos por zona fiscal: IVA, IGIC, IPSI, intracomunitario, exportaciones, IRPF, regímenes especiales.",
|
|
292
|
+
mimeType: "text/plain",
|
|
293
|
+
}, async () => ({
|
|
294
|
+
contents: [
|
|
295
|
+
{
|
|
296
|
+
uri: "frihet://tax/rates",
|
|
297
|
+
mimeType: "text/plain",
|
|
298
|
+
text: TAX_RATES,
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
}));
|
|
302
|
+
server.registerResource("tax-calendar", "frihet://tax/calendar", {
|
|
303
|
+
description: "Spanish quarterly tax calendar with filing deadlines for Modelo 303, 130, 390, 420 (IGIC), and annual returns. " +
|
|
304
|
+
"Includes VeriFactu e-invoicing timeline. " +
|
|
305
|
+
"/ Calendario fiscal trimestral español con plazos de presentación de modelos y VeriFactu.",
|
|
306
|
+
mimeType: "text/plain",
|
|
307
|
+
}, async () => ({
|
|
308
|
+
contents: [
|
|
309
|
+
{
|
|
310
|
+
uri: "frihet://tax/calendar",
|
|
311
|
+
mimeType: "text/plain",
|
|
312
|
+
text: TAX_CALENDAR,
|
|
313
|
+
},
|
|
314
|
+
],
|
|
315
|
+
}));
|
|
316
|
+
server.registerResource("expense-categories", "frihet://config/expense-categories", {
|
|
317
|
+
description: "The 8 expense categories in Frihet with deductibility rules, IVA treatment, and amortization periods. " +
|
|
318
|
+
"Essential for correctly categorizing business expenses. " +
|
|
319
|
+
"/ Las 8 categorías de gastos con reglas de deducibilidad, IVA y amortización.",
|
|
320
|
+
mimeType: "text/plain",
|
|
321
|
+
}, async () => ({
|
|
322
|
+
contents: [
|
|
323
|
+
{
|
|
324
|
+
uri: "frihet://config/expense-categories",
|
|
325
|
+
mimeType: "text/plain",
|
|
326
|
+
text: EXPENSE_CATEGORIES,
|
|
327
|
+
},
|
|
328
|
+
],
|
|
329
|
+
}));
|
|
330
|
+
server.registerResource("invoice-statuses", "frihet://config/invoice-statuses", {
|
|
331
|
+
description: "Invoice status flow in Frihet: draft → sent → paid/overdue → cancelled. " +
|
|
332
|
+
"Includes transition rules, automation triggers, webhook events, and fiscal compliance notes. " +
|
|
333
|
+
"/ Flujo de estados de factura: borrador → enviada → pagada/vencida → cancelada.",
|
|
334
|
+
mimeType: "text/plain",
|
|
335
|
+
}, async () => ({
|
|
336
|
+
contents: [
|
|
337
|
+
{
|
|
338
|
+
uri: "frihet://config/invoice-statuses",
|
|
339
|
+
mimeType: "text/plain",
|
|
340
|
+
text: INVOICE_STATUSES,
|
|
341
|
+
},
|
|
342
|
+
],
|
|
343
|
+
}));
|
|
344
|
+
}
|
|
345
|
+
//# sourceMappingURL=register-all.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-all.js","sourceRoot":"","sources":["../../src/resources/register-all.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,wEAAwE;AACxE,yEAAyE;AACzE,wEAAwE;AAExE,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wDAgE6B,CAAC;AAEzD,MAAM,SAAS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kDAyCgC,CAAC;AAEnD,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gDAoD2B,CAAC;AAEjD,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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0DAA0D;YAC1D,+EAA+E;QACjF,QAAQ,EAAE,YAAY;KACvB,EACD,KAAK,IAAI,EAAE,CAAC,CAAC;QACX,QAAQ,EAAE;YACR;gBACE,GAAG,EAAE,oCAAoC;gBACzC,QAAQ,EAAE,YAAY;gBACtB,IAAI,EAAE,kBAAkB;aACzB;SACF;KACF,CAAC,CACH,CAAC;IAEF,MAAM,CAAC,gBAAgB,CACrB,kBAAkB,EAClB,kCAAkC,EAClC;QACE,WAAW,EACT,0EAA0E;YAC1E,+FAA+F;YAC/F,iFAAiF;QACnF,QAAQ,EAAE,YAAY;KACvB,EACD,KAAK,IAAI,EAAE,CAAC,CAAC;QACX,QAAQ,EAAE;YACR;gBACE,GAAG,EAAE,kCAAkC;gBACvC,QAAQ,EAAE,YAAY;gBACtB,IAAI,EAAE,gBAAgB;aACvB;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../../src/tools/clients.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAa5D,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"clients.d.ts","sourceRoot":"","sources":["../../src/tools/clients.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAa5D,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CA4JlF"}
|
package/dist/tools/clients.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Client tools for the Frihet MCP server.
|
|
3
3
|
*/
|
|
4
4
|
import { z } from "zod/v4";
|
|
5
|
-
import { handleToolError, formatPaginatedResponse, formatRecord } from "./shared.js";
|
|
5
|
+
import { handleToolError, formatPaginatedResponse, formatRecord, listContent, getContent, mutateContent, READ_ONLY_ANNOTATIONS, CREATE_ANNOTATIONS, UPDATE_ANNOTATIONS, DELETE_ANNOTATIONS, paginatedOutput, deleteResultOutput, clientItemOutput } from "./shared.js";
|
|
6
6
|
const addressSchema = z
|
|
7
7
|
.object({
|
|
8
8
|
street: z.string().optional().describe("Street address / Direccion"),
|
|
@@ -20,15 +20,18 @@ export function registerClientTools(server, client) {
|
|
|
20
20
|
"Returns contact info, tax IDs, and addresses. " +
|
|
21
21
|
"/ Lista todos los clientes con paginacion opcional. " +
|
|
22
22
|
"Devuelve informacion de contacto, NIF/CIF y direcciones.",
|
|
23
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
23
24
|
inputSchema: {
|
|
24
25
|
limit: z.number().int().min(1).max(100).optional().describe("Max results (1-100) / Resultados maximos"),
|
|
25
26
|
offset: z.number().int().min(0).optional().describe("Offset / Desplazamiento"),
|
|
26
27
|
},
|
|
28
|
+
outputSchema: paginatedOutput(clientItemOutput),
|
|
27
29
|
}, async ({ limit, offset }) => {
|
|
28
30
|
try {
|
|
29
31
|
const result = await client.listClients({ limit, offset });
|
|
30
32
|
return {
|
|
31
|
-
content: [
|
|
33
|
+
content: [listContent(formatPaginatedResponse("clients", result))],
|
|
34
|
+
structuredContent: result,
|
|
32
35
|
};
|
|
33
36
|
}
|
|
34
37
|
catch (error) {
|
|
@@ -40,14 +43,17 @@ export function registerClientTools(server, client) {
|
|
|
40
43
|
title: "Get Client",
|
|
41
44
|
description: "Get a single client by their ID. Returns full contact details. " +
|
|
42
45
|
"/ Obtiene un cliente por su ID. Devuelve todos los datos de contacto.",
|
|
46
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
43
47
|
inputSchema: {
|
|
44
48
|
id: z.string().describe("Client ID / ID del cliente"),
|
|
45
49
|
},
|
|
50
|
+
outputSchema: clientItemOutput,
|
|
46
51
|
}, async ({ id }) => {
|
|
47
52
|
try {
|
|
48
53
|
const result = await client.getClient(id);
|
|
49
54
|
return {
|
|
50
|
-
content: [
|
|
55
|
+
content: [getContent(formatRecord("Client", result))],
|
|
56
|
+
structuredContent: result,
|
|
51
57
|
};
|
|
52
58
|
}
|
|
53
59
|
catch (error) {
|
|
@@ -61,6 +67,7 @@ export function registerClientTools(server, client) {
|
|
|
61
67
|
"Clients are used when creating invoices and quotes. " +
|
|
62
68
|
"/ Crea un nuevo cliente. Requiere como minimo un nombre. " +
|
|
63
69
|
"Los clientes se usan al crear facturas y presupuestos.",
|
|
70
|
+
annotations: CREATE_ANNOTATIONS,
|
|
64
71
|
inputSchema: {
|
|
65
72
|
name: z.string().describe("Client/company name / Nombre del cliente o empresa"),
|
|
66
73
|
email: z.string().optional().describe("Email address / Correo electronico"),
|
|
@@ -68,11 +75,13 @@ export function registerClientTools(server, client) {
|
|
|
68
75
|
taxId: z.string().optional().describe("Tax ID (NIF/CIF/VAT) / NIF o CIF"),
|
|
69
76
|
address: addressSchema,
|
|
70
77
|
},
|
|
78
|
+
outputSchema: clientItemOutput,
|
|
71
79
|
}, async (input) => {
|
|
72
80
|
try {
|
|
73
81
|
const result = await client.createClient(input);
|
|
74
82
|
return {
|
|
75
|
-
content: [
|
|
83
|
+
content: [mutateContent(formatRecord("Client created", result))],
|
|
84
|
+
structuredContent: result,
|
|
76
85
|
};
|
|
77
86
|
}
|
|
78
87
|
catch (error) {
|
|
@@ -84,6 +93,7 @@ export function registerClientTools(server, client) {
|
|
|
84
93
|
title: "Update Client",
|
|
85
94
|
description: "Update an existing client. Only the provided fields will be changed. " +
|
|
86
95
|
"/ Actualiza un cliente existente. Solo se modifican los campos proporcionados.",
|
|
96
|
+
annotations: UPDATE_ANNOTATIONS,
|
|
87
97
|
inputSchema: {
|
|
88
98
|
id: z.string().describe("Client ID / ID del cliente"),
|
|
89
99
|
name: z.string().optional().describe("Name / Nombre"),
|
|
@@ -92,11 +102,13 @@ export function registerClientTools(server, client) {
|
|
|
92
102
|
taxId: z.string().optional().describe("Tax ID / NIF/CIF"),
|
|
93
103
|
address: addressSchema,
|
|
94
104
|
},
|
|
105
|
+
outputSchema: clientItemOutput,
|
|
95
106
|
}, async ({ id, ...data }) => {
|
|
96
107
|
try {
|
|
97
108
|
const result = await client.updateClient(id, data);
|
|
98
109
|
return {
|
|
99
|
-
content: [
|
|
110
|
+
content: [mutateContent(formatRecord("Client updated", result))],
|
|
111
|
+
structuredContent: result,
|
|
100
112
|
};
|
|
101
113
|
}
|
|
102
114
|
catch (error) {
|
|
@@ -110,14 +122,17 @@ export function registerClientTools(server, client) {
|
|
|
110
122
|
"Warning: this may affect existing invoices and quotes referencing this client. " +
|
|
111
123
|
"/ Elimina permanentemente un cliente por su ID. Esta accion no se puede deshacer. " +
|
|
112
124
|
"Advertencia: puede afectar a facturas y presupuestos existentes.",
|
|
125
|
+
annotations: DELETE_ANNOTATIONS,
|
|
113
126
|
inputSchema: {
|
|
114
127
|
id: z.string().describe("Client ID / ID del cliente"),
|
|
115
128
|
},
|
|
129
|
+
outputSchema: deleteResultOutput,
|
|
116
130
|
}, async ({ id }) => {
|
|
117
131
|
try {
|
|
118
132
|
await client.deleteClient(id);
|
|
119
133
|
return {
|
|
120
|
-
content: [
|
|
134
|
+
content: [mutateContent(`Client ${id} deleted successfully. / Cliente ${id} eliminado correctamente.`)],
|
|
135
|
+
structuredContent: { success: true, id },
|
|
121
136
|
};
|
|
122
137
|
}
|
|
123
138
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clients.js","sourceRoot":"","sources":["../../src/tools/clients.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE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EAAE,CAAC,QAAQ,CAAC,4BAA4B,CAAC;SACtD;QACD,YAAY,EAAE,kBAAkB;KACjC,EACD,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;QACf,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;YAC9B,OAAO;gBACL,OAAO,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,oCAAoC,EAAE,2BAA2B,CAAC,CAAC;gBACvG,iBAAiB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAwC;aAC/E,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expenses.d.ts","sourceRoot":"","sources":["../../src/tools/expenses.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG5D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"expenses.d.ts","sourceRoot":"","sources":["../../src/tools/expenses.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG5D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAmKnF"}
|
package/dist/tools/expenses.js
CHANGED
|
@@ -2,22 +2,25 @@
|
|
|
2
2
|
* Expense tools for the Frihet MCP server.
|
|
3
3
|
*/
|
|
4
4
|
import { z } from "zod/v4";
|
|
5
|
-
import { handleToolError, formatPaginatedResponse, formatRecord } from "./shared.js";
|
|
5
|
+
import { handleToolError, formatPaginatedResponse, formatRecord, listContent, getContent, mutateContent, READ_ONLY_ANNOTATIONS, CREATE_ANNOTATIONS, UPDATE_ANNOTATIONS, DELETE_ANNOTATIONS, paginatedOutput, deleteResultOutput, expenseItemOutput } from "./shared.js";
|
|
6
6
|
export function registerExpenseTools(server, client) {
|
|
7
7
|
// -- list_expenses --
|
|
8
8
|
server.registerTool("list_expenses", {
|
|
9
9
|
title: "List Expenses",
|
|
10
10
|
description: "List all expenses with optional pagination. " +
|
|
11
11
|
"/ Lista todos los gastos con paginacion opcional.",
|
|
12
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
12
13
|
inputSchema: {
|
|
13
14
|
limit: z.number().int().min(1).max(100).optional().describe("Max results (1-100) / Resultados maximos"),
|
|
14
15
|
offset: z.number().int().min(0).optional().describe("Offset / Desplazamiento"),
|
|
15
16
|
},
|
|
17
|
+
outputSchema: paginatedOutput(expenseItemOutput),
|
|
16
18
|
}, async ({ limit, offset }) => {
|
|
17
19
|
try {
|
|
18
20
|
const result = await client.listExpenses({ limit, offset });
|
|
19
21
|
return {
|
|
20
|
-
content: [
|
|
22
|
+
content: [listContent(formatPaginatedResponse("expenses", result))],
|
|
23
|
+
structuredContent: result,
|
|
21
24
|
};
|
|
22
25
|
}
|
|
23
26
|
catch (error) {
|
|
@@ -29,14 +32,17 @@ export function registerExpenseTools(server, client) {
|
|
|
29
32
|
title: "Get Expense",
|
|
30
33
|
description: "Get a single expense by its ID. " +
|
|
31
34
|
"/ Obtiene un gasto por su ID.",
|
|
35
|
+
annotations: READ_ONLY_ANNOTATIONS,
|
|
32
36
|
inputSchema: {
|
|
33
37
|
id: z.string().describe("Expense ID / ID del gasto"),
|
|
34
38
|
},
|
|
39
|
+
outputSchema: expenseItemOutput,
|
|
35
40
|
}, async ({ id }) => {
|
|
36
41
|
try {
|
|
37
42
|
const result = await client.getExpense(id);
|
|
38
43
|
return {
|
|
39
|
-
content: [
|
|
44
|
+
content: [getContent(formatRecord("Expense", result))],
|
|
45
|
+
structuredContent: result,
|
|
40
46
|
};
|
|
41
47
|
}
|
|
42
48
|
catch (error) {
|
|
@@ -50,6 +56,7 @@ export function registerExpenseTools(server, client) {
|
|
|
50
56
|
"Useful for tracking business costs, deductible expenses, and vendor payments. " +
|
|
51
57
|
"/ Registra un nuevo gasto. Requiere descripcion e importe. " +
|
|
52
58
|
"Util para seguimiento de costes, gastos deducibles y pagos a proveedores.",
|
|
59
|
+
annotations: CREATE_ANNOTATIONS,
|
|
53
60
|
inputSchema: {
|
|
54
61
|
description: z.string().describe("Expense description / Descripcion del gasto"),
|
|
55
62
|
amount: z.number().describe("Amount in EUR / Importe en EUR"),
|
|
@@ -67,11 +74,13 @@ export function registerExpenseTools(server, client) {
|
|
|
67
74
|
.optional()
|
|
68
75
|
.describe("Whether the expense is tax deductible / Si el gasto es deducible fiscalmente"),
|
|
69
76
|
},
|
|
77
|
+
outputSchema: expenseItemOutput,
|
|
70
78
|
}, async (input) => {
|
|
71
79
|
try {
|
|
72
80
|
const result = await client.createExpense(input);
|
|
73
81
|
return {
|
|
74
|
-
content: [
|
|
82
|
+
content: [mutateContent(formatRecord("Expense created", result))],
|
|
83
|
+
structuredContent: result,
|
|
75
84
|
};
|
|
76
85
|
}
|
|
77
86
|
catch (error) {
|
|
@@ -83,6 +92,7 @@ export function registerExpenseTools(server, client) {
|
|
|
83
92
|
title: "Update Expense",
|
|
84
93
|
description: "Update an existing expense. Only the provided fields will be changed. " +
|
|
85
94
|
"/ Actualiza un gasto existente. Solo se modifican los campos proporcionados.",
|
|
95
|
+
annotations: UPDATE_ANNOTATIONS,
|
|
86
96
|
inputSchema: {
|
|
87
97
|
id: z.string().describe("Expense ID / ID del gasto"),
|
|
88
98
|
description: z.string().optional().describe("Description / Descripcion"),
|
|
@@ -92,11 +102,13 @@ export function registerExpenseTools(server, client) {
|
|
|
92
102
|
vendor: z.string().optional().describe("Vendor / Proveedor"),
|
|
93
103
|
taxDeductible: z.boolean().optional().describe("Tax deductible / Deducible"),
|
|
94
104
|
},
|
|
105
|
+
outputSchema: expenseItemOutput,
|
|
95
106
|
}, async ({ id, ...data }) => {
|
|
96
107
|
try {
|
|
97
108
|
const result = await client.updateExpense(id, data);
|
|
98
109
|
return {
|
|
99
|
-
content: [
|
|
110
|
+
content: [mutateContent(formatRecord("Expense updated", result))],
|
|
111
|
+
structuredContent: result,
|
|
100
112
|
};
|
|
101
113
|
}
|
|
102
114
|
catch (error) {
|
|
@@ -108,14 +120,17 @@ export function registerExpenseTools(server, client) {
|
|
|
108
120
|
title: "Delete Expense",
|
|
109
121
|
description: "Permanently delete an expense by its ID. This action cannot be undone. " +
|
|
110
122
|
"/ Elimina permanentemente un gasto por su ID. Esta accion no se puede deshacer.",
|
|
123
|
+
annotations: DELETE_ANNOTATIONS,
|
|
111
124
|
inputSchema: {
|
|
112
125
|
id: z.string().describe("Expense ID / ID del gasto"),
|
|
113
126
|
},
|
|
127
|
+
outputSchema: deleteResultOutput,
|
|
114
128
|
}, async ({ id }) => {
|
|
115
129
|
try {
|
|
116
130
|
await client.deleteExpense(id);
|
|
117
131
|
return {
|
|
118
|
-
content: [
|
|
132
|
+
content: [mutateContent(`Expense ${id} deleted successfully. / Gasto ${id} eliminado correctamente.`)],
|
|
133
|
+
structuredContent: { success: true, id },
|
|
119
134
|
};
|
|
120
135
|
}
|
|
121
136
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expenses.js","sourceRoot":"","sources":["../../src/tools/expenses.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"expenses.js","sourceRoot":"","sources":["../../src/tools/expen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EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAwC;aAC/E,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;QAChC,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoices.d.ts","sourceRoot":"","sources":["../../src/tools/invoices.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAS5D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"invoices.d.ts","sourceRoot":"","sources":["../../src/tools/invoices.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAS5D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CA+NnF"}
|