siigo-mcp-server 2.1.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +93 -1
- package/README.md +263 -170
- package/bin/siigo-mcp +5 -15
- package/dist/index.js +1410 -1162
- package/dist/index.js.map +1 -1
- package/dist/siigo-client.d.ts +70 -61
- package/dist/siigo-client.d.ts.map +1 -1
- package/dist/siigo-client.js +155 -70
- package/dist/siigo-client.js.map +1 -1
- package/dist/types.d.ts +540 -102
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -2
- package/dist/types.js.map +1 -1
- package/package.json +20 -19
package/dist/index.js
CHANGED
|
@@ -1,1179 +1,1427 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
|
|
38
|
-
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
39
|
-
const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
|
|
40
|
-
const siigo_client_js_1 = require("./siigo-client.js");
|
|
41
|
-
const dotenv = __importStar(require("dotenv"));
|
|
2
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { SiigoApiError, SiigoClient } from './siigo-client.js';
|
|
6
|
+
import * as dotenv from 'dotenv';
|
|
42
7
|
dotenv.config();
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
accessKey: process.env.SIIGO_ACCESS_KEY || '',
|
|
56
|
-
baseUrl: process.env.SIIGO_BASE_URL || 'https://api.siigo.com',
|
|
57
|
-
partnerId: process.env.SIIGO_PARTNER_ID || '',
|
|
58
|
-
};
|
|
59
|
-
if (!config.username || !config.accessKey || !config.partnerId) {
|
|
60
|
-
throw new Error('SIIGO_USERNAME, SIIGO_ACCESS_KEY, and SIIGO_PARTNER_ID environment variables are required');
|
|
61
|
-
}
|
|
62
|
-
this.siigoClient = new siigo_client_js_1.SiigoClient(config);
|
|
63
|
-
this.setupHandlers();
|
|
64
|
-
}
|
|
65
|
-
setupHandlers() {
|
|
66
|
-
this.server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
|
|
67
|
-
return {
|
|
68
|
-
tools: this.getTools(),
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
this.server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
|
|
72
|
-
const { name, arguments: args } = request.params;
|
|
73
|
-
try {
|
|
74
|
-
switch (name) {
|
|
75
|
-
// Products
|
|
76
|
-
case 'siigo_get_products':
|
|
77
|
-
return await this.handleGetProducts(args);
|
|
78
|
-
case 'siigo_get_product':
|
|
79
|
-
return await this.handleGetProduct(args);
|
|
80
|
-
case 'siigo_create_product':
|
|
81
|
-
return await this.handleCreateProduct(args);
|
|
82
|
-
case 'siigo_update_product':
|
|
83
|
-
return await this.handleUpdateProduct(args);
|
|
84
|
-
case 'siigo_delete_product':
|
|
85
|
-
return await this.handleDeleteProduct(args);
|
|
86
|
-
case 'siigo_search_products':
|
|
87
|
-
return await this.handleSearchProducts(args);
|
|
88
|
-
// Customers
|
|
89
|
-
case 'siigo_get_customers':
|
|
90
|
-
return await this.handleGetCustomers(args);
|
|
91
|
-
case 'siigo_get_customer':
|
|
92
|
-
return await this.handleGetCustomer(args);
|
|
93
|
-
case 'siigo_create_customer':
|
|
94
|
-
return await this.handleCreateCustomer(args);
|
|
95
|
-
case 'siigo_update_customer':
|
|
96
|
-
return await this.handleUpdateCustomer(args);
|
|
97
|
-
case 'siigo_search_customers':
|
|
98
|
-
return await this.handleSearchCustomers(args);
|
|
99
|
-
// Invoices
|
|
100
|
-
case 'siigo_get_invoices':
|
|
101
|
-
return await this.handleGetInvoices(args);
|
|
102
|
-
case 'siigo_get_invoice':
|
|
103
|
-
return await this.handleGetInvoice(args);
|
|
104
|
-
case 'siigo_create_invoice':
|
|
105
|
-
return await this.handleCreateInvoice(args);
|
|
106
|
-
case 'siigo_update_invoice':
|
|
107
|
-
return await this.handleUpdateInvoice(args);
|
|
108
|
-
case 'siigo_delete_invoice':
|
|
109
|
-
return await this.handleDeleteInvoice(args);
|
|
110
|
-
case 'siigo_get_invoice_pdf':
|
|
111
|
-
return await this.handleGetInvoicePdf(args);
|
|
112
|
-
case 'siigo_send_invoice_email':
|
|
113
|
-
return await this.handleSendInvoiceEmail(args);
|
|
114
|
-
// Credit Notes
|
|
115
|
-
case 'siigo_get_credit_notes':
|
|
116
|
-
return await this.handleGetCreditNotes(args);
|
|
117
|
-
case 'siigo_get_credit_note':
|
|
118
|
-
return await this.handleGetCreditNote(args);
|
|
119
|
-
case 'siigo_create_credit_note':
|
|
120
|
-
return await this.handleCreateCreditNote(args);
|
|
121
|
-
// Vouchers
|
|
122
|
-
case 'siigo_get_vouchers':
|
|
123
|
-
return await this.handleGetVouchers(args);
|
|
124
|
-
case 'siigo_get_voucher':
|
|
125
|
-
return await this.handleGetVoucher(args);
|
|
126
|
-
case 'siigo_create_voucher':
|
|
127
|
-
return await this.handleCreateVoucher(args);
|
|
128
|
-
// Purchases
|
|
129
|
-
case 'siigo_get_purchases':
|
|
130
|
-
return await this.handleGetPurchases(args);
|
|
131
|
-
case 'siigo_get_purchase':
|
|
132
|
-
return await this.handleGetPurchase(args);
|
|
133
|
-
case 'siigo_create_purchase':
|
|
134
|
-
return await this.handleCreatePurchase(args);
|
|
135
|
-
case 'siigo_update_purchase':
|
|
136
|
-
return await this.handleUpdatePurchase(args);
|
|
137
|
-
case 'siigo_delete_purchase':
|
|
138
|
-
return await this.handleDeletePurchase(args);
|
|
139
|
-
// Payment Receipts
|
|
140
|
-
case 'siigo_get_payment_receipts':
|
|
141
|
-
return await this.handleGetPaymentReceipts(args);
|
|
142
|
-
case 'siigo_get_payment_receipt':
|
|
143
|
-
return await this.handleGetPaymentReceipt(args);
|
|
144
|
-
case 'siigo_create_payment_receipt':
|
|
145
|
-
return await this.handleCreatePaymentReceipt(args);
|
|
146
|
-
case 'siigo_update_payment_receipt':
|
|
147
|
-
return await this.handleUpdatePaymentReceipt(args);
|
|
148
|
-
case 'siigo_delete_payment_receipt':
|
|
149
|
-
return await this.handleDeletePaymentReceipt(args);
|
|
150
|
-
// Journals
|
|
151
|
-
case 'siigo_get_journals':
|
|
152
|
-
return await this.handleGetJournals(args);
|
|
153
|
-
case 'siigo_get_journal':
|
|
154
|
-
return await this.handleGetJournal(args);
|
|
155
|
-
case 'siigo_create_journal':
|
|
156
|
-
return await this.handleCreateJournal(args);
|
|
157
|
-
// Catalogs
|
|
158
|
-
case 'siigo_get_document_types':
|
|
159
|
-
return await this.handleGetDocumentTypes(args);
|
|
160
|
-
case 'siigo_get_taxes':
|
|
161
|
-
return await this.handleGetTaxes(args);
|
|
162
|
-
case 'siigo_get_payment_types':
|
|
163
|
-
return await this.handleGetPaymentTypes(args);
|
|
164
|
-
case 'siigo_get_cost_centers':
|
|
165
|
-
return await this.handleGetCostCenters(args);
|
|
166
|
-
case 'siigo_get_users':
|
|
167
|
-
return await this.handleGetUsers(args);
|
|
168
|
-
case 'siigo_get_warehouses':
|
|
169
|
-
return await this.handleGetWarehouses(args);
|
|
170
|
-
case 'siigo_get_price_lists':
|
|
171
|
-
return await this.handleGetPriceLists(args);
|
|
172
|
-
case 'siigo_get_account_groups':
|
|
173
|
-
return await this.handleGetAccountGroups(args);
|
|
174
|
-
case 'siigo_get_cities':
|
|
175
|
-
return await this.handleGetCities(args);
|
|
176
|
-
case 'siigo_get_id_types':
|
|
177
|
-
return await this.handleGetIdTypes(args);
|
|
178
|
-
case 'siigo_get_fiscal_responsibilities':
|
|
179
|
-
return await this.handleGetFiscalResponsibilities(args);
|
|
180
|
-
// Reports
|
|
181
|
-
case 'siigo_get_trial_balance':
|
|
182
|
-
return await this.handleGetTrialBalance(args);
|
|
183
|
-
case 'siigo_get_trial_balance_by_third':
|
|
184
|
-
return await this.handleGetTrialBalanceByThird(args);
|
|
185
|
-
case 'siigo_get_accounts_payable':
|
|
186
|
-
return await this.handleGetAccountsPayable(args);
|
|
187
|
-
default:
|
|
188
|
-
throw new Error(`Unknown tool: ${name}`);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
catch (error) {
|
|
192
|
-
return {
|
|
193
|
-
content: [
|
|
194
|
-
{
|
|
195
|
-
type: 'text',
|
|
196
|
-
text: `Error executing ${name}: ${error instanceof Error ? error.message : String(error)}`,
|
|
197
|
-
},
|
|
198
|
-
],
|
|
199
|
-
isError: true,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
getTools() {
|
|
205
|
-
return [
|
|
206
|
-
// Products
|
|
207
|
-
{
|
|
208
|
-
name: 'siigo_get_products',
|
|
209
|
-
description: 'Get list of products from Siigo',
|
|
210
|
-
inputSchema: {
|
|
211
|
-
type: 'object',
|
|
212
|
-
properties: {
|
|
213
|
-
page: { type: 'number', description: 'Page number' },
|
|
214
|
-
page_size: { type: 'number', description: 'Number of items per page' },
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
name: 'siigo_get_product',
|
|
220
|
-
description: 'Get a specific product by ID',
|
|
221
|
-
inputSchema: {
|
|
222
|
-
type: 'object',
|
|
223
|
-
properties: {
|
|
224
|
-
id: { type: 'string', description: 'Product ID' },
|
|
225
|
-
},
|
|
226
|
-
required: ['id'],
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
name: 'siigo_create_product',
|
|
231
|
-
description: 'Create a new product',
|
|
232
|
-
inputSchema: {
|
|
233
|
-
type: 'object',
|
|
234
|
-
properties: {
|
|
235
|
-
product: {
|
|
236
|
-
type: 'object',
|
|
237
|
-
description: 'Product data',
|
|
238
|
-
properties: {
|
|
239
|
-
code: { type: 'string', description: 'Product code' },
|
|
240
|
-
name: { type: 'string', description: 'Product name' },
|
|
241
|
-
account_group: { type: 'number', description: 'Account group ID' },
|
|
242
|
-
type: { type: 'string', enum: ['Product', 'Service', 'ConsumerGood'] },
|
|
243
|
-
stock_control: { type: 'boolean' },
|
|
244
|
-
active: { type: 'boolean' },
|
|
245
|
-
tax_classification: { type: 'string', enum: ['Taxed', 'Exempt', 'Excluded'] },
|
|
246
|
-
tax_included: { type: 'boolean' },
|
|
247
|
-
unit: { type: 'string' },
|
|
248
|
-
unit_label: { type: 'string' },
|
|
249
|
-
reference: { type: 'string' },
|
|
250
|
-
description: { type: 'string' },
|
|
251
|
-
},
|
|
252
|
-
required: ['code', 'name', 'account_group'],
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
required: ['product'],
|
|
256
|
-
},
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
name: 'siigo_update_product',
|
|
260
|
-
description: 'Update an existing product',
|
|
261
|
-
inputSchema: {
|
|
262
|
-
type: 'object',
|
|
263
|
-
properties: {
|
|
264
|
-
id: { type: 'string', description: 'Product ID' },
|
|
265
|
-
product: { type: 'object', description: 'Product data to update' },
|
|
266
|
-
},
|
|
267
|
-
required: ['id', 'product'],
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
name: 'siigo_delete_product',
|
|
272
|
-
description: 'Delete a product',
|
|
273
|
-
inputSchema: {
|
|
274
|
-
type: 'object',
|
|
275
|
-
properties: {
|
|
276
|
-
id: { type: 'string', description: 'Product ID' },
|
|
277
|
-
},
|
|
278
|
-
required: ['id'],
|
|
279
|
-
},
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
name: 'siigo_search_products',
|
|
283
|
-
description: 'Search for products by code, name, or reference with filtering capabilities',
|
|
284
|
-
inputSchema: {
|
|
285
|
-
type: 'object',
|
|
286
|
-
properties: {
|
|
287
|
-
code: {
|
|
288
|
-
type: 'string',
|
|
289
|
-
description: 'Search by product code (partial match)'
|
|
290
|
-
},
|
|
291
|
-
name: {
|
|
292
|
-
type: 'string',
|
|
293
|
-
description: 'Search by product name (partial match)'
|
|
294
|
-
},
|
|
295
|
-
reference: {
|
|
296
|
-
type: 'string',
|
|
297
|
-
description: 'Search by product reference (partial match)'
|
|
298
|
-
},
|
|
299
|
-
page: {
|
|
300
|
-
type: 'number',
|
|
301
|
-
description: 'Page number for pagination'
|
|
302
|
-
},
|
|
303
|
-
page_size: {
|
|
304
|
-
type: 'number',
|
|
305
|
-
description: 'Number of items per page (max 100)'
|
|
306
|
-
},
|
|
307
|
-
},
|
|
308
|
-
},
|
|
309
|
-
},
|
|
310
|
-
// Customers
|
|
311
|
-
{
|
|
312
|
-
name: 'siigo_get_customers',
|
|
313
|
-
description: 'Get list of customers from Siigo',
|
|
314
|
-
inputSchema: {
|
|
315
|
-
type: 'object',
|
|
316
|
-
properties: {
|
|
317
|
-
page: { type: 'number', description: 'Page number' },
|
|
318
|
-
page_size: { type: 'number', description: 'Number of items per page' },
|
|
319
|
-
type: { type: 'string', description: 'Customer type filter' },
|
|
320
|
-
},
|
|
321
|
-
},
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
name: 'siigo_get_customer',
|
|
325
|
-
description: 'Get a specific customer by ID',
|
|
326
|
-
inputSchema: {
|
|
327
|
-
type: 'object',
|
|
328
|
-
properties: {
|
|
329
|
-
id: { type: 'string', description: 'Customer ID' },
|
|
330
|
-
},
|
|
331
|
-
required: ['id'],
|
|
332
|
-
},
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
name: 'siigo_create_customer',
|
|
336
|
-
description: 'Create a new customer',
|
|
337
|
-
inputSchema: {
|
|
338
|
-
type: 'object',
|
|
339
|
-
properties: {
|
|
340
|
-
customer: {
|
|
341
|
-
type: 'object',
|
|
342
|
-
description: 'Customer data',
|
|
343
|
-
properties: {
|
|
344
|
-
person_type: { type: 'string', enum: ['Person', 'Company'] },
|
|
345
|
-
id_type: { type: 'string', description: 'ID type code' },
|
|
346
|
-
identification: { type: 'string', description: 'Customer identification' },
|
|
347
|
-
name: { type: 'array', items: { type: 'string' }, description: 'Customer names' },
|
|
348
|
-
address: {
|
|
349
|
-
type: 'object',
|
|
350
|
-
properties: {
|
|
351
|
-
address: { type: 'string' },
|
|
352
|
-
city: {
|
|
353
|
-
type: 'object',
|
|
354
|
-
properties: {
|
|
355
|
-
country_code: { type: 'string' },
|
|
356
|
-
state_code: { type: 'string' },
|
|
357
|
-
city_code: { type: 'string' },
|
|
358
|
-
},
|
|
359
|
-
required: ['country_code', 'state_code', 'city_code'],
|
|
360
|
-
},
|
|
361
|
-
},
|
|
362
|
-
required: ['address', 'city'],
|
|
363
|
-
},
|
|
364
|
-
phones: { type: 'array', items: { type: 'object' } },
|
|
365
|
-
contacts: { type: 'array', items: { type: 'object' } },
|
|
366
|
-
},
|
|
367
|
-
required: ['person_type', 'id_type', 'identification', 'name', 'address', 'phones', 'contacts'],
|
|
368
|
-
},
|
|
369
|
-
},
|
|
370
|
-
required: ['customer'],
|
|
371
|
-
},
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
name: 'siigo_update_customer',
|
|
375
|
-
description: 'Update an existing customer',
|
|
376
|
-
inputSchema: {
|
|
377
|
-
type: 'object',
|
|
378
|
-
properties: {
|
|
379
|
-
id: { type: 'string', description: 'Customer ID' },
|
|
380
|
-
customer: { type: 'object', description: 'Customer data to update' },
|
|
381
|
-
},
|
|
382
|
-
required: ['id', 'customer'],
|
|
383
|
-
},
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
name: 'siigo_search_customers',
|
|
387
|
-
description: 'Search for customers by identification, name, or type with filtering capabilities',
|
|
388
|
-
inputSchema: {
|
|
389
|
-
type: 'object',
|
|
390
|
-
properties: {
|
|
391
|
-
identification: {
|
|
392
|
-
type: 'string',
|
|
393
|
-
description: 'Search by customer identification number (partial or exact match)'
|
|
394
|
-
},
|
|
395
|
-
name: {
|
|
396
|
-
type: 'string',
|
|
397
|
-
description: 'Search by customer name (partial match across all name fields)'
|
|
398
|
-
},
|
|
399
|
-
type: {
|
|
400
|
-
type: 'string',
|
|
401
|
-
enum: ['Customer', 'Supplier', 'Other'],
|
|
402
|
-
description: 'Filter by customer type'
|
|
403
|
-
},
|
|
404
|
-
page: {
|
|
405
|
-
type: 'number',
|
|
406
|
-
description: 'Page number for pagination'
|
|
407
|
-
},
|
|
408
|
-
page_size: {
|
|
409
|
-
type: 'number',
|
|
410
|
-
description: 'Number of items per page (max 100)'
|
|
411
|
-
},
|
|
412
|
-
},
|
|
413
|
-
},
|
|
414
|
-
},
|
|
415
|
-
// Invoices
|
|
416
|
-
{
|
|
417
|
-
name: 'siigo_get_invoices',
|
|
418
|
-
description: 'Get list of invoices from Siigo',
|
|
419
|
-
inputSchema: {
|
|
420
|
-
type: 'object',
|
|
421
|
-
properties: {
|
|
422
|
-
page: { type: 'number', description: 'Page number' },
|
|
423
|
-
page_size: { type: 'number', description: 'Number of items per page' },
|
|
424
|
-
created_start: { type: 'string', description: 'Start date filter (YYYY-MM-DD)' },
|
|
425
|
-
created_end: { type: 'string', description: 'End date filter (YYYY-MM-DD)' },
|
|
426
|
-
},
|
|
427
|
-
},
|
|
428
|
-
},
|
|
429
|
-
{
|
|
430
|
-
name: 'siigo_get_invoice',
|
|
431
|
-
description: 'Get a specific invoice by ID',
|
|
432
|
-
inputSchema: {
|
|
433
|
-
type: 'object',
|
|
434
|
-
properties: {
|
|
435
|
-
id: { type: 'string', description: 'Invoice ID' },
|
|
436
|
-
},
|
|
437
|
-
required: ['id'],
|
|
438
|
-
},
|
|
439
|
-
},
|
|
440
|
-
{
|
|
441
|
-
name: 'siigo_create_invoice',
|
|
442
|
-
description: 'Create a new invoice',
|
|
443
|
-
inputSchema: {
|
|
444
|
-
type: 'object',
|
|
445
|
-
properties: {
|
|
446
|
-
invoice: {
|
|
447
|
-
type: 'object',
|
|
448
|
-
description: 'Invoice data',
|
|
449
|
-
properties: {
|
|
450
|
-
document: { type: 'object', properties: { id: { type: 'number' } }, required: ['id'] },
|
|
451
|
-
date: { type: 'string', description: 'Invoice date (YYYY-MM-DD)' },
|
|
452
|
-
customer: { type: 'object', description: 'Customer information' },
|
|
453
|
-
seller: { type: 'number', description: 'Seller ID' },
|
|
454
|
-
items: { type: 'array', items: { type: 'object' }, description: 'Invoice items' },
|
|
455
|
-
payments: { type: 'array', items: { type: 'object' }, description: 'Payment methods' },
|
|
456
|
-
},
|
|
457
|
-
required: ['document', 'date', 'customer', 'seller', 'items', 'payments'],
|
|
458
|
-
},
|
|
459
|
-
},
|
|
460
|
-
required: ['invoice'],
|
|
461
|
-
},
|
|
462
|
-
},
|
|
463
|
-
{
|
|
464
|
-
name: 'siigo_update_invoice',
|
|
465
|
-
description: 'Update an existing invoice',
|
|
466
|
-
inputSchema: {
|
|
467
|
-
type: 'object',
|
|
468
|
-
properties: {
|
|
469
|
-
id: { type: 'string', description: 'Invoice ID' },
|
|
470
|
-
invoice: { type: 'object', description: 'Invoice data to update' },
|
|
471
|
-
},
|
|
472
|
-
required: ['id', 'invoice'],
|
|
473
|
-
},
|
|
474
|
-
},
|
|
475
|
-
{
|
|
476
|
-
name: 'siigo_delete_invoice',
|
|
477
|
-
description: 'Delete an invoice',
|
|
478
|
-
inputSchema: {
|
|
479
|
-
type: 'object',
|
|
480
|
-
properties: {
|
|
481
|
-
id: { type: 'string', description: 'Invoice ID' },
|
|
482
|
-
},
|
|
483
|
-
required: ['id'],
|
|
484
|
-
},
|
|
485
|
-
},
|
|
486
|
-
{
|
|
487
|
-
name: 'siigo_get_invoice_pdf',
|
|
488
|
-
description: 'Get invoice PDF',
|
|
489
|
-
inputSchema: {
|
|
490
|
-
type: 'object',
|
|
491
|
-
properties: {
|
|
492
|
-
id: { type: 'string', description: 'Invoice ID' },
|
|
493
|
-
},
|
|
494
|
-
required: ['id'],
|
|
495
|
-
},
|
|
496
|
-
},
|
|
497
|
-
{
|
|
498
|
-
name: 'siigo_send_invoice_email',
|
|
499
|
-
description: 'Send invoice by email',
|
|
500
|
-
inputSchema: {
|
|
501
|
-
type: 'object',
|
|
502
|
-
properties: {
|
|
503
|
-
id: { type: 'string', description: 'Invoice ID' },
|
|
504
|
-
mail_to: { type: 'string', description: 'Recipient email' },
|
|
505
|
-
copy_to: { type: 'string', description: 'CC emails (semicolon separated)' },
|
|
506
|
-
},
|
|
507
|
-
required: ['id', 'mail_to'],
|
|
508
|
-
},
|
|
509
|
-
},
|
|
510
|
-
// Credit Notes
|
|
511
|
-
{
|
|
512
|
-
name: 'siigo_get_credit_notes',
|
|
513
|
-
description: 'Get list of credit notes from Siigo',
|
|
514
|
-
inputSchema: {
|
|
515
|
-
type: 'object',
|
|
516
|
-
properties: {
|
|
517
|
-
page: { type: 'number', description: 'Page number' },
|
|
518
|
-
page_size: { type: 'number', description: 'Number of items per page' },
|
|
519
|
-
},
|
|
520
|
-
},
|
|
521
|
-
},
|
|
522
|
-
{
|
|
523
|
-
name: 'siigo_get_credit_note',
|
|
524
|
-
description: 'Get a specific credit note by ID',
|
|
525
|
-
inputSchema: {
|
|
526
|
-
type: 'object',
|
|
527
|
-
properties: {
|
|
528
|
-
id: { type: 'string', description: 'Credit note ID' },
|
|
529
|
-
},
|
|
530
|
-
required: ['id'],
|
|
531
|
-
},
|
|
532
|
-
},
|
|
533
|
-
{
|
|
534
|
-
name: 'siigo_create_credit_note',
|
|
535
|
-
description: 'Create a new credit note',
|
|
536
|
-
inputSchema: {
|
|
537
|
-
type: 'object',
|
|
538
|
-
properties: {
|
|
539
|
-
creditNote: { type: 'object', description: 'Credit note data' },
|
|
540
|
-
},
|
|
541
|
-
required: ['creditNote'],
|
|
542
|
-
},
|
|
543
|
-
},
|
|
544
|
-
// Vouchers
|
|
545
|
-
{
|
|
546
|
-
name: 'siigo_get_vouchers',
|
|
547
|
-
description: 'Get list of vouchers (cash receipts) from Siigo',
|
|
548
|
-
inputSchema: {
|
|
549
|
-
type: 'object',
|
|
550
|
-
properties: {
|
|
551
|
-
page: { type: 'number', description: 'Page number' },
|
|
552
|
-
page_size: { type: 'number', description: 'Number of items per page' },
|
|
553
|
-
},
|
|
554
|
-
},
|
|
555
|
-
},
|
|
556
|
-
{
|
|
557
|
-
name: 'siigo_get_voucher',
|
|
558
|
-
description: 'Get a specific voucher by ID',
|
|
559
|
-
inputSchema: {
|
|
560
|
-
type: 'object',
|
|
561
|
-
properties: {
|
|
562
|
-
id: { type: 'string', description: 'Voucher ID' },
|
|
563
|
-
},
|
|
564
|
-
required: ['id'],
|
|
565
|
-
},
|
|
566
|
-
},
|
|
567
|
-
{
|
|
568
|
-
name: 'siigo_create_voucher',
|
|
569
|
-
description: 'Create a new voucher',
|
|
570
|
-
inputSchema: {
|
|
571
|
-
type: 'object',
|
|
572
|
-
properties: {
|
|
573
|
-
voucher: { type: 'object', description: 'Voucher data' },
|
|
574
|
-
},
|
|
575
|
-
required: ['voucher'],
|
|
576
|
-
},
|
|
577
|
-
},
|
|
578
|
-
// Purchases
|
|
579
|
-
{
|
|
580
|
-
name: 'siigo_get_purchases',
|
|
581
|
-
description: 'Get list of purchases from Siigo',
|
|
582
|
-
inputSchema: {
|
|
583
|
-
type: 'object',
|
|
584
|
-
properties: {
|
|
585
|
-
page: { type: 'number', description: 'Page number' },
|
|
586
|
-
page_size: { type: 'number', description: 'Number of items per page' },
|
|
587
|
-
},
|
|
588
|
-
},
|
|
589
|
-
},
|
|
590
|
-
{
|
|
591
|
-
name: 'siigo_get_purchase',
|
|
592
|
-
description: 'Get a specific purchase by ID',
|
|
593
|
-
inputSchema: {
|
|
594
|
-
type: 'object',
|
|
595
|
-
properties: {
|
|
596
|
-
id: { type: 'string', description: 'Purchase ID' },
|
|
597
|
-
},
|
|
598
|
-
required: ['id'],
|
|
599
|
-
},
|
|
600
|
-
},
|
|
601
|
-
{
|
|
602
|
-
name: 'siigo_create_purchase',
|
|
603
|
-
description: 'Create a new purchase',
|
|
604
|
-
inputSchema: {
|
|
605
|
-
type: 'object',
|
|
606
|
-
properties: {
|
|
607
|
-
purchase: { type: 'object', description: 'Purchase data' },
|
|
608
|
-
},
|
|
609
|
-
required: ['purchase'],
|
|
610
|
-
},
|
|
611
|
-
},
|
|
612
|
-
{
|
|
613
|
-
name: 'siigo_update_purchase',
|
|
614
|
-
description: 'Update an existing purchase',
|
|
615
|
-
inputSchema: {
|
|
616
|
-
type: 'object',
|
|
617
|
-
properties: {
|
|
618
|
-
id: { type: 'string', description: 'Purchase ID' },
|
|
619
|
-
purchase: { type: 'object', description: 'Purchase data to update' },
|
|
620
|
-
},
|
|
621
|
-
required: ['id', 'purchase'],
|
|
622
|
-
},
|
|
623
|
-
},
|
|
624
|
-
{
|
|
625
|
-
name: 'siigo_delete_purchase',
|
|
626
|
-
description: 'Delete a purchase',
|
|
627
|
-
inputSchema: {
|
|
628
|
-
type: 'object',
|
|
629
|
-
properties: {
|
|
630
|
-
id: { type: 'string', description: 'Purchase ID' },
|
|
631
|
-
},
|
|
632
|
-
required: ['id'],
|
|
633
|
-
},
|
|
634
|
-
},
|
|
635
|
-
// Payment Receipts
|
|
636
|
-
{
|
|
637
|
-
name: 'siigo_get_payment_receipts',
|
|
638
|
-
description: 'Get list of payment receipts from Siigo',
|
|
639
|
-
inputSchema: {
|
|
640
|
-
type: 'object',
|
|
641
|
-
properties: {
|
|
642
|
-
page: { type: 'number', description: 'Page number' },
|
|
643
|
-
page_size: { type: 'number', description: 'Number of items per page' },
|
|
644
|
-
},
|
|
645
|
-
},
|
|
646
|
-
},
|
|
647
|
-
{
|
|
648
|
-
name: 'siigo_get_payment_receipt',
|
|
649
|
-
description: 'Get a specific payment receipt by ID',
|
|
650
|
-
inputSchema: {
|
|
651
|
-
type: 'object',
|
|
652
|
-
properties: {
|
|
653
|
-
id: { type: 'string', description: 'Payment receipt ID' },
|
|
654
|
-
},
|
|
655
|
-
required: ['id'],
|
|
656
|
-
},
|
|
657
|
-
},
|
|
658
|
-
{
|
|
659
|
-
name: 'siigo_create_payment_receipt',
|
|
660
|
-
description: 'Create a new payment receipt',
|
|
661
|
-
inputSchema: {
|
|
662
|
-
type: 'object',
|
|
663
|
-
properties: {
|
|
664
|
-
paymentReceipt: { type: 'object', description: 'Payment receipt data' },
|
|
665
|
-
},
|
|
666
|
-
required: ['paymentReceipt'],
|
|
667
|
-
},
|
|
668
|
-
},
|
|
669
|
-
{
|
|
670
|
-
name: 'siigo_update_payment_receipt',
|
|
671
|
-
description: 'Update an existing payment receipt',
|
|
672
|
-
inputSchema: {
|
|
673
|
-
type: 'object',
|
|
674
|
-
properties: {
|
|
675
|
-
id: { type: 'string', description: 'Payment receipt ID' },
|
|
676
|
-
paymentReceipt: { type: 'object', description: 'Payment receipt data to update' },
|
|
677
|
-
},
|
|
678
|
-
required: ['id', 'paymentReceipt'],
|
|
679
|
-
},
|
|
680
|
-
},
|
|
681
|
-
{
|
|
682
|
-
name: 'siigo_delete_payment_receipt',
|
|
683
|
-
description: 'Delete a payment receipt',
|
|
684
|
-
inputSchema: {
|
|
685
|
-
type: 'object',
|
|
686
|
-
properties: {
|
|
687
|
-
id: { type: 'string', description: 'Payment receipt ID' },
|
|
688
|
-
},
|
|
689
|
-
required: ['id'],
|
|
690
|
-
},
|
|
691
|
-
},
|
|
692
|
-
// Journals
|
|
693
|
-
{
|
|
694
|
-
name: 'siigo_get_journals',
|
|
695
|
-
description: 'Get list of accounting journals from Siigo',
|
|
696
|
-
inputSchema: {
|
|
697
|
-
type: 'object',
|
|
698
|
-
properties: {
|
|
699
|
-
page: { type: 'number', description: 'Page number' },
|
|
700
|
-
page_size: { type: 'number', description: 'Number of items per page' },
|
|
701
|
-
},
|
|
702
|
-
},
|
|
703
|
-
},
|
|
704
|
-
{
|
|
705
|
-
name: 'siigo_get_journal',
|
|
706
|
-
description: 'Get a specific journal by ID',
|
|
707
|
-
inputSchema: {
|
|
708
|
-
type: 'object',
|
|
709
|
-
properties: {
|
|
710
|
-
id: { type: 'string', description: 'Journal ID' },
|
|
711
|
-
},
|
|
712
|
-
required: ['id'],
|
|
713
|
-
},
|
|
714
|
-
},
|
|
715
|
-
{
|
|
716
|
-
name: 'siigo_create_journal',
|
|
717
|
-
description: 'Create a new accounting journal',
|
|
718
|
-
inputSchema: {
|
|
719
|
-
type: 'object',
|
|
720
|
-
properties: {
|
|
721
|
-
journal: { type: 'object', description: 'Journal data' },
|
|
722
|
-
},
|
|
723
|
-
required: ['journal'],
|
|
724
|
-
},
|
|
725
|
-
},
|
|
726
|
-
// Catalogs
|
|
727
|
-
{
|
|
728
|
-
name: 'siigo_get_document_types',
|
|
729
|
-
description: 'Get document types catalog',
|
|
730
|
-
inputSchema: {
|
|
731
|
-
type: 'object',
|
|
732
|
-
properties: {
|
|
733
|
-
type: { type: 'string', description: 'Document type filter (FV, RC, NC, FC, CC)' },
|
|
734
|
-
},
|
|
735
|
-
},
|
|
736
|
-
},
|
|
737
|
-
{
|
|
738
|
-
name: 'siigo_get_taxes',
|
|
739
|
-
description: 'Get taxes catalog',
|
|
740
|
-
inputSchema: { type: 'object', properties: {} },
|
|
741
|
-
},
|
|
742
|
-
{
|
|
743
|
-
name: 'siigo_get_payment_types',
|
|
744
|
-
description: 'Get payment types catalog',
|
|
745
|
-
inputSchema: {
|
|
746
|
-
type: 'object',
|
|
747
|
-
properties: {
|
|
748
|
-
document_type: { type: 'string', description: 'Document type filter' },
|
|
749
|
-
},
|
|
750
|
-
},
|
|
751
|
-
},
|
|
752
|
-
{
|
|
753
|
-
name: 'siigo_get_cost_centers',
|
|
754
|
-
description: 'Get cost centers catalog',
|
|
755
|
-
inputSchema: { type: 'object', properties: {} },
|
|
756
|
-
},
|
|
757
|
-
{
|
|
758
|
-
name: 'siigo_get_users',
|
|
759
|
-
description: 'Get users catalog',
|
|
760
|
-
inputSchema: { type: 'object', properties: {} },
|
|
761
|
-
},
|
|
762
|
-
{
|
|
763
|
-
name: 'siigo_get_warehouses',
|
|
764
|
-
description: 'Get warehouses catalog',
|
|
765
|
-
inputSchema: { type: 'object', properties: {} },
|
|
766
|
-
},
|
|
767
|
-
{
|
|
768
|
-
name: 'siigo_get_price_lists',
|
|
769
|
-
description: 'Get price lists catalog',
|
|
770
|
-
inputSchema: { type: 'object', properties: {} },
|
|
771
|
-
},
|
|
772
|
-
{
|
|
773
|
-
name: 'siigo_get_account_groups',
|
|
774
|
-
description: 'Get account groups catalog',
|
|
775
|
-
inputSchema: { type: 'object', properties: {} },
|
|
776
|
-
},
|
|
777
|
-
{
|
|
778
|
-
name: 'siigo_get_cities',
|
|
779
|
-
description: 'Get cities catalog',
|
|
780
|
-
inputSchema: { type: 'object', properties: {} },
|
|
781
|
-
},
|
|
782
|
-
{
|
|
783
|
-
name: 'siigo_get_id_types',
|
|
784
|
-
description: 'Get ID types catalog',
|
|
785
|
-
inputSchema: { type: 'object', properties: {} },
|
|
786
|
-
},
|
|
787
|
-
{
|
|
788
|
-
name: 'siigo_get_fiscal_responsibilities',
|
|
789
|
-
description: 'Get fiscal responsibilities catalog',
|
|
790
|
-
inputSchema: { type: 'object', properties: {} },
|
|
791
|
-
},
|
|
792
|
-
// Reports
|
|
793
|
-
{
|
|
794
|
-
name: 'siigo_get_trial_balance',
|
|
795
|
-
description: 'Get trial balance report',
|
|
796
|
-
inputSchema: {
|
|
797
|
-
type: 'object',
|
|
798
|
-
properties: {
|
|
799
|
-
account_start: { type: 'string', description: 'Starting account code' },
|
|
800
|
-
account_end: { type: 'string', description: 'Ending account code' },
|
|
801
|
-
year: { type: 'number', description: 'Year' },
|
|
802
|
-
month_start: { type: 'number', description: 'Starting month (1-13)' },
|
|
803
|
-
month_end: { type: 'number', description: 'Ending month (1-13)' },
|
|
804
|
-
includes_tax_difference: { type: 'boolean', description: 'Include tax differences' },
|
|
805
|
-
},
|
|
806
|
-
required: ['year', 'month_start', 'month_end', 'includes_tax_difference'],
|
|
807
|
-
},
|
|
808
|
-
},
|
|
809
|
-
{
|
|
810
|
-
name: 'siigo_get_trial_balance_by_third',
|
|
811
|
-
description: 'Get trial balance by third party report',
|
|
812
|
-
inputSchema: {
|
|
813
|
-
type: 'object',
|
|
814
|
-
properties: {
|
|
815
|
-
account_start: { type: 'string', description: 'Starting account code' },
|
|
816
|
-
account_end: { type: 'string', description: 'Ending account code' },
|
|
817
|
-
year: { type: 'number', description: 'Year' },
|
|
818
|
-
month_start: { type: 'number', description: 'Starting month (1-13)' },
|
|
819
|
-
month_end: { type: 'number', description: 'Ending month (1-13)' },
|
|
820
|
-
includes_tax_difference: { type: 'boolean', description: 'Include tax differences' },
|
|
821
|
-
customer: { type: 'object', description: 'Customer filter' },
|
|
822
|
-
},
|
|
823
|
-
required: ['year', 'month_start', 'month_end', 'includes_tax_difference'],
|
|
824
|
-
},
|
|
825
|
-
},
|
|
8
|
+
// ─── Helper ────────────────────────────────────────────────────────────────
|
|
9
|
+
function jsonResult(data) {
|
|
10
|
+
return {
|
|
11
|
+
content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function errorResult(toolName, error) {
|
|
15
|
+
const detail = error instanceof SiigoApiError && error.response
|
|
16
|
+
? `\n${JSON.stringify(error.response, null, 2)}`
|
|
17
|
+
: '';
|
|
18
|
+
return {
|
|
19
|
+
content: [
|
|
826
20
|
{
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
inputSchema: {
|
|
830
|
-
type: 'object',
|
|
831
|
-
properties: {
|
|
832
|
-
page: { type: 'number', description: 'Page number' },
|
|
833
|
-
page_size: { type: 'number', description: 'Number of items per page' },
|
|
834
|
-
},
|
|
835
|
-
},
|
|
21
|
+
type: 'text',
|
|
22
|
+
text: `Error executing ${toolName}: ${error instanceof Error ? error.message : String(error)}${detail}`,
|
|
836
23
|
},
|
|
837
|
-
]
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
return
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
return
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
return
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
return
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
return
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
return
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
24
|
+
],
|
|
25
|
+
isError: true,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
// ─── Config ────────────────────────────────────────────────────────────────
|
|
29
|
+
const config = {
|
|
30
|
+
username: process.env.SIIGO_USERNAME || '',
|
|
31
|
+
accessKey: process.env.SIIGO_ACCESS_KEY || '',
|
|
32
|
+
baseUrl: process.env.SIIGO_BASE_URL || 'https://api.siigo.com',
|
|
33
|
+
partnerId: process.env.SIIGO_PARTNER_ID || '',
|
|
34
|
+
};
|
|
35
|
+
if (!config.username || !config.accessKey || !config.partnerId) {
|
|
36
|
+
console.error('SIIGO_USERNAME, SIIGO_ACCESS_KEY, and SIIGO_PARTNER_ID environment variables are required');
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
const client = new SiigoClient(config);
|
|
40
|
+
// ─── Server ────────────────────────────────────────────────────────────────
|
|
41
|
+
const server = new McpServer({
|
|
42
|
+
name: 'siigo-mcp-server',
|
|
43
|
+
version: '3.0.1',
|
|
44
|
+
}, {
|
|
45
|
+
capabilities: {
|
|
46
|
+
tools: {},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
50
|
+
// PRODUCTS (6 tools)
|
|
51
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
52
|
+
server.registerTool('siigo_get_products', {
|
|
53
|
+
title: 'Get Products',
|
|
54
|
+
description: 'Get list of products from Siigo',
|
|
55
|
+
inputSchema: z.object({
|
|
56
|
+
page: z.number().optional().describe('Page number'),
|
|
57
|
+
page_size: z.number().optional().describe('Number of items per page'),
|
|
58
|
+
}),
|
|
59
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
60
|
+
}, async (args) => {
|
|
61
|
+
try {
|
|
62
|
+
return jsonResult(await client.getProducts(args));
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
return errorResult('siigo_get_products', e);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
server.registerTool('siigo_get_product', {
|
|
69
|
+
title: 'Get Product',
|
|
70
|
+
description: 'Get a specific product by ID',
|
|
71
|
+
inputSchema: z.object({
|
|
72
|
+
id: z.string().describe('Product ID'),
|
|
73
|
+
}),
|
|
74
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
75
|
+
}, async ({ id }) => {
|
|
76
|
+
try {
|
|
77
|
+
return jsonResult(await client.getProduct(id));
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
return errorResult('siigo_get_product', e);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
server.registerTool('siigo_create_product', {
|
|
84
|
+
title: 'Create Product',
|
|
85
|
+
description: 'Create a new product. Supports Product, Service, ConsumerGood, and Combo types. For Combo products, include a components array with code and quantity.',
|
|
86
|
+
inputSchema: z.object({
|
|
87
|
+
product: z.object({
|
|
88
|
+
code: z.string().describe('Unique product code'),
|
|
89
|
+
name: z.string().describe('Product name'),
|
|
90
|
+
account_group: z.number().describe('Account group / inventory category ID'),
|
|
91
|
+
type: z.enum(['Product', 'Service', 'ConsumerGood', 'Combo']).optional().describe('Product type (default: Product)'),
|
|
92
|
+
stock_control: z.boolean().optional().describe('Enable stock control'),
|
|
93
|
+
active: z.boolean().optional().describe('Product active status'),
|
|
94
|
+
tax_classification: z.enum(['Taxed', 'Exempt', 'Excluded']).optional().describe('Tax classification'),
|
|
95
|
+
tax_included: z.boolean().optional().describe('Tax included in price'),
|
|
96
|
+
taxes: z.array(z.object({
|
|
97
|
+
id: z.number().describe('Tax ID'),
|
|
98
|
+
milliliters: z.number().optional().describe('Milliliters (for sweetened beverages tax)'),
|
|
99
|
+
rate: z.number().optional().describe('Tax rate'),
|
|
100
|
+
})).optional().describe('Product taxes'),
|
|
101
|
+
prices: z.array(z.object({
|
|
102
|
+
currency_code: z.string().describe('Currency code'),
|
|
103
|
+
price_list: z.array(z.object({
|
|
104
|
+
position: z.number().describe('Price list position'),
|
|
105
|
+
value: z.number().describe('Price value'),
|
|
106
|
+
})).describe('Price list entries'),
|
|
107
|
+
})).optional().describe('Product prices'),
|
|
108
|
+
unit: z.string().optional().describe('Unit of measure code (default: 94)'),
|
|
109
|
+
unit_label: z.string().optional().describe('Unit label for invoice printing'),
|
|
110
|
+
reference: z.string().optional().describe('Product reference / factory code'),
|
|
111
|
+
description: z.string().optional().describe('Product description'),
|
|
112
|
+
additional_fields: z.object({
|
|
113
|
+
barcode: z.string().optional(),
|
|
114
|
+
brand: z.string().optional(),
|
|
115
|
+
tariff: z.string().optional(),
|
|
116
|
+
model: z.string().optional(),
|
|
117
|
+
}).optional().describe('Additional fields'),
|
|
118
|
+
components: z.array(z.object({
|
|
119
|
+
code: z.string().describe('Component product code'),
|
|
120
|
+
quantity: z.number().describe('Component quantity'),
|
|
121
|
+
})).optional().describe('Combo product components (only for type Combo)'),
|
|
122
|
+
}).describe('Product data'),
|
|
123
|
+
}),
|
|
124
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
125
|
+
}, async ({ product }) => {
|
|
126
|
+
try {
|
|
127
|
+
return jsonResult(await client.createProduct(product));
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
return errorResult('siigo_create_product', e);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
server.registerTool('siigo_update_product', {
|
|
134
|
+
title: 'Update Product',
|
|
135
|
+
description: 'Update an existing product',
|
|
136
|
+
inputSchema: z.object({
|
|
137
|
+
id: z.string().describe('Product ID'),
|
|
138
|
+
product: z.record(z.unknown()).describe('Product data to update (partial)'),
|
|
139
|
+
}),
|
|
140
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
141
|
+
}, async ({ id, product }) => {
|
|
142
|
+
try {
|
|
143
|
+
return jsonResult(await client.updateProduct(id, product));
|
|
144
|
+
}
|
|
145
|
+
catch (e) {
|
|
146
|
+
return errorResult('siigo_update_product', e);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
server.registerTool('siigo_delete_product', {
|
|
150
|
+
title: 'Delete Product',
|
|
151
|
+
description: 'Delete a product',
|
|
152
|
+
inputSchema: z.object({
|
|
153
|
+
id: z.string().describe('Product ID'),
|
|
154
|
+
}),
|
|
155
|
+
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
156
|
+
}, async ({ id }) => {
|
|
157
|
+
try {
|
|
158
|
+
return jsonResult(await client.deleteProduct(id));
|
|
159
|
+
}
|
|
160
|
+
catch (e) {
|
|
161
|
+
return errorResult('siigo_delete_product', e);
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
server.registerTool('siigo_search_products', {
|
|
165
|
+
title: 'Search Products',
|
|
166
|
+
description: 'Search for products by code, name, or reference with client-side filtering for partial matches',
|
|
167
|
+
inputSchema: z.object({
|
|
168
|
+
code: z.string().optional().describe('Search by product code (partial match)'),
|
|
169
|
+
name: z.string().optional().describe('Search by product name (partial match)'),
|
|
170
|
+
reference: z.string().optional().describe('Search by product reference (partial match)'),
|
|
171
|
+
page: z.number().optional().describe('Page number for pagination'),
|
|
172
|
+
page_size: z.number().optional().describe('Number of items per page (max 100)'),
|
|
173
|
+
}),
|
|
174
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
175
|
+
}, async (args) => {
|
|
176
|
+
try {
|
|
177
|
+
return jsonResult(await client.searchProducts(args));
|
|
178
|
+
}
|
|
179
|
+
catch (e) {
|
|
180
|
+
return errorResult('siigo_search_products', e);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
184
|
+
// ACCOUNT GROUPS / INVENTORY CATEGORIES (3 tools)
|
|
185
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
186
|
+
server.registerTool('siigo_get_account_groups', {
|
|
187
|
+
title: 'Get Account Groups',
|
|
188
|
+
description: 'Get inventory classification groups (account groups) catalog',
|
|
189
|
+
inputSchema: z.object({}),
|
|
190
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
191
|
+
}, async () => {
|
|
192
|
+
try {
|
|
193
|
+
return jsonResult(await client.getAccountGroups());
|
|
194
|
+
}
|
|
195
|
+
catch (e) {
|
|
196
|
+
return errorResult('siigo_get_account_groups', e);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
server.registerTool('siigo_create_account_group', {
|
|
200
|
+
title: 'Create Account Group',
|
|
201
|
+
description: 'Create a new inventory category (account group). Code must be max 10 alphanumeric chars, name max 50 chars.',
|
|
202
|
+
inputSchema: z.object({
|
|
203
|
+
code: z.string().describe('Unique category code (max 10 alphanumeric chars, no special chars or spaces)'),
|
|
204
|
+
name: z.string().describe('Category name (max 50 chars)'),
|
|
205
|
+
}),
|
|
206
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
207
|
+
}, async (args) => {
|
|
208
|
+
try {
|
|
209
|
+
return jsonResult(await client.createAccountGroup(args));
|
|
210
|
+
}
|
|
211
|
+
catch (e) {
|
|
212
|
+
return errorResult('siigo_create_account_group', e);
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
server.registerTool('siigo_update_account_group', {
|
|
216
|
+
title: 'Update Account Group',
|
|
217
|
+
description: 'Update an existing inventory category (account group)',
|
|
218
|
+
inputSchema: z.object({
|
|
219
|
+
id: z.number().describe('Account group ID'),
|
|
220
|
+
code: z.string().describe('Category code'),
|
|
221
|
+
name: z.string().describe('Category name'),
|
|
222
|
+
}),
|
|
223
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
224
|
+
}, async ({ id, code, name }) => {
|
|
225
|
+
try {
|
|
226
|
+
return jsonResult(await client.updateAccountGroup(id, { code, name }));
|
|
227
|
+
}
|
|
228
|
+
catch (e) {
|
|
229
|
+
return errorResult('siigo_update_account_group', e);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
233
|
+
// CUSTOMERS (5 tools)
|
|
234
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
235
|
+
server.registerTool('siigo_get_customers', {
|
|
236
|
+
title: 'Get Customers',
|
|
237
|
+
description: 'Get list of customers from Siigo',
|
|
238
|
+
inputSchema: z.object({
|
|
239
|
+
page: z.number().optional().describe('Page number'),
|
|
240
|
+
page_size: z.number().optional().describe('Number of items per page'),
|
|
241
|
+
type: z.string().optional().describe('Customer type filter'),
|
|
242
|
+
}),
|
|
243
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
244
|
+
}, async (args) => {
|
|
245
|
+
try {
|
|
246
|
+
return jsonResult(await client.getCustomers(args));
|
|
247
|
+
}
|
|
248
|
+
catch (e) {
|
|
249
|
+
return errorResult('siigo_get_customers', e);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
server.registerTool('siigo_get_customer', {
|
|
253
|
+
title: 'Get Customer',
|
|
254
|
+
description: 'Get a specific customer by ID',
|
|
255
|
+
inputSchema: z.object({
|
|
256
|
+
id: z.string().describe('Customer ID'),
|
|
257
|
+
}),
|
|
258
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
259
|
+
}, async ({ id }) => {
|
|
260
|
+
try {
|
|
261
|
+
return jsonResult(await client.getCustomer(id));
|
|
262
|
+
}
|
|
263
|
+
catch (e) {
|
|
264
|
+
return errorResult('siigo_get_customer', e);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
server.registerTool('siigo_create_customer', {
|
|
268
|
+
title: 'Create Customer',
|
|
269
|
+
description: 'Create a new customer / third party',
|
|
270
|
+
inputSchema: z.object({
|
|
271
|
+
customer: z.object({
|
|
272
|
+
type: z.enum(['Customer', 'Supplier', 'Other']).optional().describe('Customer type (default: Customer)'),
|
|
273
|
+
person_type: z.enum(['Person', 'Company']).describe('Person type'),
|
|
274
|
+
id_type: z.string().describe('ID type code'),
|
|
275
|
+
identification: z.string().describe('Customer identification number'),
|
|
276
|
+
check_digit: z.string().optional().describe('Check digit (auto-calculated)'),
|
|
277
|
+
name: z.array(z.string()).describe('Customer names: [first, last] for Person, [company_name] for Company'),
|
|
278
|
+
commercial_name: z.string().optional().describe('Commercial name'),
|
|
279
|
+
branch_office: z.number().optional().describe('Branch office number'),
|
|
280
|
+
active: z.boolean().optional().describe('Active status'),
|
|
281
|
+
vat_responsible: z.boolean().optional().describe('VAT responsible'),
|
|
282
|
+
fiscal_responsibilities: z.array(z.object({ code: z.string() })).optional().describe('Fiscal responsibilities'),
|
|
283
|
+
address: z.object({
|
|
284
|
+
address: z.string().describe('Street address'),
|
|
285
|
+
city: z.object({
|
|
286
|
+
country_code: z.string().describe('Country code'),
|
|
287
|
+
state_code: z.string().describe('State/department code'),
|
|
288
|
+
city_code: z.string().describe('City code'),
|
|
289
|
+
}),
|
|
290
|
+
postal_code: z.string().optional().describe('Postal code'),
|
|
291
|
+
}).describe('Customer address'),
|
|
292
|
+
phones: z.array(z.object({
|
|
293
|
+
indicative: z.string().optional(),
|
|
294
|
+
number: z.string().describe('Phone number'),
|
|
295
|
+
extension: z.string().optional(),
|
|
296
|
+
})).describe('Phone numbers'),
|
|
297
|
+
contacts: z.array(z.object({
|
|
298
|
+
first_name: z.string().describe('Contact first name'),
|
|
299
|
+
last_name: z.string().describe('Contact last name'),
|
|
300
|
+
email: z.string().describe('Contact email'),
|
|
301
|
+
phone: z.object({
|
|
302
|
+
indicative: z.string().optional(),
|
|
303
|
+
number: z.string().optional(),
|
|
304
|
+
extension: z.string().optional(),
|
|
305
|
+
}).optional().describe('Contact phone'),
|
|
306
|
+
})).describe('Contacts (max 10)'),
|
|
307
|
+
comments: z.string().optional().describe('Comments'),
|
|
308
|
+
related_users: z.object({
|
|
309
|
+
seller_id: z.number().optional(),
|
|
310
|
+
collector_id: z.number().optional(),
|
|
311
|
+
}).optional().describe('Related users'),
|
|
312
|
+
}).describe('Customer data'),
|
|
313
|
+
}),
|
|
314
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
315
|
+
}, async ({ customer }) => {
|
|
316
|
+
try {
|
|
317
|
+
return jsonResult(await client.createCustomer(customer));
|
|
318
|
+
}
|
|
319
|
+
catch (e) {
|
|
320
|
+
return errorResult('siigo_create_customer', e);
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
server.registerTool('siigo_update_customer', {
|
|
324
|
+
title: 'Update Customer',
|
|
325
|
+
description: 'Update an existing customer',
|
|
326
|
+
inputSchema: z.object({
|
|
327
|
+
id: z.string().describe('Customer ID'),
|
|
328
|
+
customer: z.record(z.unknown()).describe('Customer data to update (partial)'),
|
|
329
|
+
}),
|
|
330
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
331
|
+
}, async ({ id, customer }) => {
|
|
332
|
+
try {
|
|
333
|
+
return jsonResult(await client.updateCustomer(id, customer));
|
|
334
|
+
}
|
|
335
|
+
catch (e) {
|
|
336
|
+
return errorResult('siigo_update_customer', e);
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
server.registerTool('siigo_search_customers', {
|
|
340
|
+
title: 'Search Customers',
|
|
341
|
+
description: 'Search for customers by identification, name, or type with client-side filtering for partial matches',
|
|
342
|
+
inputSchema: z.object({
|
|
343
|
+
identification: z.string().optional().describe('Search by identification number (partial match)'),
|
|
344
|
+
name: z.string().optional().describe('Search by customer name (partial match)'),
|
|
345
|
+
type: z.enum(['Customer', 'Supplier', 'Other']).optional().describe('Filter by customer type'),
|
|
346
|
+
page: z.number().optional().describe('Page number for pagination'),
|
|
347
|
+
page_size: z.number().optional().describe('Number of items per page (max 100)'),
|
|
348
|
+
}),
|
|
349
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
350
|
+
}, async (args) => {
|
|
351
|
+
try {
|
|
352
|
+
return jsonResult(await client.searchCustomers(args));
|
|
353
|
+
}
|
|
354
|
+
catch (e) {
|
|
355
|
+
return errorResult('siigo_search_customers', e);
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
359
|
+
// INVOICES (10 tools)
|
|
360
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
361
|
+
server.registerTool('siigo_get_invoices', {
|
|
362
|
+
title: 'Get Invoices',
|
|
363
|
+
description: 'Get list of invoices from Siigo',
|
|
364
|
+
inputSchema: z.object({
|
|
365
|
+
page: z.number().optional().describe('Page number'),
|
|
366
|
+
page_size: z.number().optional().describe('Number of items per page'),
|
|
367
|
+
created_start: z.string().optional().describe('Start date filter (YYYY-MM-DD)'),
|
|
368
|
+
created_end: z.string().optional().describe('End date filter (YYYY-MM-DD)'),
|
|
369
|
+
}),
|
|
370
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
371
|
+
}, async (args) => {
|
|
372
|
+
try {
|
|
373
|
+
return jsonResult(await client.getInvoices(args));
|
|
1135
374
|
}
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
375
|
+
catch (e) {
|
|
376
|
+
return errorResult('siigo_get_invoices', e);
|
|
1139
377
|
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
378
|
+
});
|
|
379
|
+
server.registerTool('siigo_get_invoice', {
|
|
380
|
+
title: 'Get Invoice',
|
|
381
|
+
description: 'Get a specific invoice by ID',
|
|
382
|
+
inputSchema: z.object({
|
|
383
|
+
id: z.string().describe('Invoice ID'),
|
|
384
|
+
}),
|
|
385
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
386
|
+
}, async ({ id }) => {
|
|
387
|
+
try {
|
|
388
|
+
return jsonResult(await client.getInvoice(id));
|
|
389
|
+
}
|
|
390
|
+
catch (e) {
|
|
391
|
+
return errorResult('siigo_get_invoice', e);
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
server.registerTool('siigo_create_invoice', {
|
|
395
|
+
title: 'Create Invoice',
|
|
396
|
+
description: 'Create a new sales invoice. Supports healthcare sector (healthcare_company) and cargo transportation (cargo_transportation) fields.',
|
|
397
|
+
inputSchema: z.object({
|
|
398
|
+
invoice: z.object({
|
|
399
|
+
document: z.object({ id: z.number().describe('Document type ID') }),
|
|
400
|
+
date: z.string().describe('Invoice date (YYYY-MM-DD)'),
|
|
401
|
+
customer: z.object({
|
|
402
|
+
identification: z.string().describe('Customer identification'),
|
|
403
|
+
branch_office: z.number().optional().describe('Branch office'),
|
|
404
|
+
}).describe('Customer reference'),
|
|
405
|
+
cost_center: z.number().optional().describe('Cost center ID'),
|
|
406
|
+
currency: z.object({
|
|
407
|
+
code: z.string().describe('Currency code'),
|
|
408
|
+
exchange_rate: z.number().describe('Exchange rate'),
|
|
409
|
+
}).optional().describe('Currency (omit for local currency)'),
|
|
410
|
+
seller: z.number().describe('Seller ID'),
|
|
411
|
+
observations: z.string().optional().describe('Observations'),
|
|
412
|
+
items: z.array(z.object({
|
|
413
|
+
code: z.string().describe('Product code'),
|
|
414
|
+
description: z.string().optional(),
|
|
415
|
+
quantity: z.number().describe('Quantity'),
|
|
416
|
+
price: z.number().describe('Unit price'),
|
|
417
|
+
discount: z.number().optional().describe('Discount'),
|
|
418
|
+
taxes: z.array(z.object({ id: z.number() })).optional(),
|
|
419
|
+
warehouse: z.number().optional().describe('Warehouse ID'),
|
|
420
|
+
})).describe('Invoice items'),
|
|
421
|
+
payments: z.array(z.object({
|
|
422
|
+
id: z.number().describe('Payment type ID'),
|
|
423
|
+
value: z.number().describe('Payment value'),
|
|
424
|
+
due_date: z.string().optional().describe('Due date (YYYY-MM-DD)'),
|
|
425
|
+
})).describe('Payment methods'),
|
|
426
|
+
stamp: z.object({ send: z.boolean() }).optional().describe('Send to DIAN electronically'),
|
|
427
|
+
mail: z.object({ send: z.boolean() }).optional().describe('Send by email'),
|
|
428
|
+
retentions: z.array(z.object({ id: z.number() })).optional().describe('Retention taxes'),
|
|
429
|
+
global_discounts: z.array(z.object({
|
|
430
|
+
id: z.number(),
|
|
431
|
+
percentage: z.number().optional(),
|
|
432
|
+
value: z.number().optional(),
|
|
433
|
+
})).optional().describe('Global discounts'),
|
|
434
|
+
healthcare_company: z.object({
|
|
435
|
+
operation_type: z.enum(['SS-CUFE', 'SS-SinAporte', 'SS-Recaudo']).describe('Healthcare operation type'),
|
|
436
|
+
period_start: z.string().optional().describe('Period start date'),
|
|
437
|
+
period_end: z.string().optional().describe('Period end date'),
|
|
438
|
+
payment_method: z.number().optional().describe('Payment method (01-05)'),
|
|
439
|
+
service_plan: z.number().optional().describe('Service plan (01-15)'),
|
|
440
|
+
policy_number: z.string().optional().describe('Policy number (max 50)'),
|
|
441
|
+
contract_number: z.string().optional().describe('Contract number (max 50)'),
|
|
442
|
+
copayment: z.number().optional().describe('Copayment amount'),
|
|
443
|
+
coinsurance: z.number().optional().describe('Coinsurance amount'),
|
|
444
|
+
cost_sharing: z.number().optional().describe('Cost sharing amount'),
|
|
445
|
+
recovery_charge: z.number().optional().describe('Recovery charge amount'),
|
|
446
|
+
}).optional().describe('Healthcare sector fields (required if document type is healthcare)'),
|
|
447
|
+
}).describe('Invoice data'),
|
|
448
|
+
}),
|
|
449
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
450
|
+
}, async ({ invoice }) => {
|
|
451
|
+
try {
|
|
452
|
+
return jsonResult(await client.createInvoice(invoice));
|
|
453
|
+
}
|
|
454
|
+
catch (e) {
|
|
455
|
+
return errorResult('siigo_create_invoice', e);
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
server.registerTool('siigo_update_invoice', {
|
|
459
|
+
title: 'Update Invoice',
|
|
460
|
+
description: 'Update an existing invoice',
|
|
461
|
+
inputSchema: z.object({
|
|
462
|
+
id: z.string().describe('Invoice ID'),
|
|
463
|
+
invoice: z.record(z.unknown()).describe('Invoice data to update (partial)'),
|
|
464
|
+
}),
|
|
465
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
466
|
+
}, async ({ id, invoice }) => {
|
|
467
|
+
try {
|
|
468
|
+
return jsonResult(await client.updateInvoice(id, invoice));
|
|
469
|
+
}
|
|
470
|
+
catch (e) {
|
|
471
|
+
return errorResult('siigo_update_invoice', e);
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
server.registerTool('siigo_delete_invoice', {
|
|
475
|
+
title: 'Delete Invoice',
|
|
476
|
+
description: 'Delete an invoice',
|
|
477
|
+
inputSchema: z.object({
|
|
478
|
+
id: z.string().describe('Invoice ID'),
|
|
479
|
+
}),
|
|
480
|
+
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
481
|
+
}, async ({ id }) => {
|
|
482
|
+
try {
|
|
483
|
+
return jsonResult(await client.deleteInvoice(id));
|
|
484
|
+
}
|
|
485
|
+
catch (e) {
|
|
486
|
+
return errorResult('siigo_delete_invoice', e);
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
server.registerTool('siigo_annul_invoice', {
|
|
490
|
+
title: 'Annul Invoice',
|
|
491
|
+
description: 'Annul (void) a sales invoice',
|
|
492
|
+
inputSchema: z.object({
|
|
493
|
+
id: z.string().describe('Invoice ID to annul'),
|
|
494
|
+
}),
|
|
495
|
+
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
496
|
+
}, async ({ id }) => {
|
|
497
|
+
try {
|
|
498
|
+
return jsonResult(await client.annulInvoice(id));
|
|
499
|
+
}
|
|
500
|
+
catch (e) {
|
|
501
|
+
return errorResult('siigo_annul_invoice', e);
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
server.registerTool('siigo_get_invoice_pdf', {
|
|
505
|
+
title: 'Get Invoice PDF',
|
|
506
|
+
description: 'Get invoice PDF as base64',
|
|
507
|
+
inputSchema: z.object({
|
|
508
|
+
id: z.string().describe('Invoice ID'),
|
|
509
|
+
}),
|
|
510
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
511
|
+
}, async ({ id }) => {
|
|
512
|
+
try {
|
|
513
|
+
return jsonResult(await client.getInvoicePdf(id));
|
|
514
|
+
}
|
|
515
|
+
catch (e) {
|
|
516
|
+
return errorResult('siigo_get_invoice_pdf', e);
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
server.registerTool('siigo_get_invoice_xml', {
|
|
520
|
+
title: 'Get Invoice XML',
|
|
521
|
+
description: 'Get invoice electronic XML as base64',
|
|
522
|
+
inputSchema: z.object({
|
|
523
|
+
id: z.string().describe('Invoice ID'),
|
|
524
|
+
}),
|
|
525
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
526
|
+
}, async ({ id }) => {
|
|
527
|
+
try {
|
|
528
|
+
return jsonResult(await client.getInvoiceXml(id));
|
|
529
|
+
}
|
|
530
|
+
catch (e) {
|
|
531
|
+
return errorResult('siigo_get_invoice_xml', e);
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
server.registerTool('siigo_get_invoice_stamp_errors', {
|
|
535
|
+
title: 'Get Invoice DIAN Errors',
|
|
536
|
+
description: 'Get DIAN rejection errors for an invoice that failed electronic stamping',
|
|
537
|
+
inputSchema: z.object({
|
|
538
|
+
id: z.string().describe('Invoice ID'),
|
|
539
|
+
}),
|
|
540
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
541
|
+
}, async ({ id }) => {
|
|
542
|
+
try {
|
|
543
|
+
return jsonResult(await client.getInvoiceStampErrors(id));
|
|
544
|
+
}
|
|
545
|
+
catch (e) {
|
|
546
|
+
return errorResult('siigo_get_invoice_stamp_errors', e);
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
server.registerTool('siigo_send_invoice_email', {
|
|
550
|
+
title: 'Send Invoice Email',
|
|
551
|
+
description: 'Send invoice by email (up to 5 addresses)',
|
|
552
|
+
inputSchema: z.object({
|
|
553
|
+
id: z.string().describe('Invoice ID'),
|
|
554
|
+
mail_to: z.string().describe('Recipient email'),
|
|
555
|
+
copy_to: z.string().optional().describe('CC emails (semicolon separated)'),
|
|
556
|
+
}),
|
|
557
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
558
|
+
}, async ({ id, mail_to, copy_to }) => {
|
|
559
|
+
try {
|
|
560
|
+
return jsonResult(await client.sendInvoiceByEmail(id, { mail_to, copy_to }));
|
|
561
|
+
}
|
|
562
|
+
catch (e) {
|
|
563
|
+
return errorResult('siigo_send_invoice_email', e);
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
// ─── Batch Invoices ────────────────────────────────────────────────────────
|
|
567
|
+
server.registerTool('siigo_create_invoice_batch', {
|
|
568
|
+
title: 'Create Invoice Batch',
|
|
569
|
+
description: 'Create invoices in batch asynchronously. Requires a notification_url (HTTPS webhook) that will receive the results when processing completes.',
|
|
570
|
+
inputSchema: z.object({
|
|
571
|
+
notification_url: z.string().describe('HTTPS URL for webhook notification when batch completes (max 2048 chars)'),
|
|
572
|
+
invoices: z.array(z.object({
|
|
573
|
+
idempotency_key: z.string().describe('Unique external identifier (alphanumeric, max 30 chars)'),
|
|
574
|
+
document: z.object({ id: z.number() }),
|
|
575
|
+
date: z.string().describe('Date (YYYY-MM-DD)'),
|
|
576
|
+
customer: z.object({
|
|
577
|
+
identification: z.string(),
|
|
578
|
+
branch_office: z.number().optional(),
|
|
579
|
+
}),
|
|
580
|
+
cost_center: z.number().optional(),
|
|
581
|
+
seller: z.number().describe('Seller ID'),
|
|
582
|
+
items: z.array(z.object({
|
|
583
|
+
code: z.string(),
|
|
584
|
+
description: z.string().optional(),
|
|
585
|
+
quantity: z.number(),
|
|
586
|
+
price: z.number(),
|
|
587
|
+
discount: z.number().optional(),
|
|
588
|
+
taxes: z.array(z.object({ id: z.number() })).optional(),
|
|
589
|
+
})),
|
|
590
|
+
payments: z.array(z.object({
|
|
591
|
+
id: z.number(),
|
|
592
|
+
value: z.number(),
|
|
593
|
+
due_date: z.string().optional(),
|
|
594
|
+
})),
|
|
595
|
+
stamp: z.object({ send: z.boolean() }).optional(),
|
|
596
|
+
mail: z.object({ send: z.boolean() }).optional(),
|
|
597
|
+
observations: z.string().optional(),
|
|
598
|
+
})).describe('Array of invoices to create'),
|
|
599
|
+
}),
|
|
600
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
601
|
+
}, async ({ notification_url, invoices }) => {
|
|
602
|
+
try {
|
|
603
|
+
return jsonResult(await client.createInvoiceBatch({ notification_url, invoices }));
|
|
604
|
+
}
|
|
605
|
+
catch (e) {
|
|
606
|
+
return errorResult('siigo_create_invoice_batch', e);
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
610
|
+
// QUOTATIONS (5 tools)
|
|
611
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
612
|
+
server.registerTool('siigo_get_quotations', {
|
|
613
|
+
title: 'Get Quotations',
|
|
614
|
+
description: 'Get list of quotations (cotizaciones) from Siigo',
|
|
615
|
+
inputSchema: z.object({
|
|
616
|
+
page: z.number().optional().describe('Page number'),
|
|
617
|
+
page_size: z.number().optional().describe('Number of items per page'),
|
|
618
|
+
created_start: z.string().optional().describe('Start date filter (YYYY-MM-DD)'),
|
|
619
|
+
created_end: z.string().optional().describe('End date filter (YYYY-MM-DD)'),
|
|
620
|
+
}),
|
|
621
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
622
|
+
}, async (args) => {
|
|
623
|
+
try {
|
|
624
|
+
return jsonResult(await client.getQuotations(args));
|
|
625
|
+
}
|
|
626
|
+
catch (e) {
|
|
627
|
+
return errorResult('siigo_get_quotations', e);
|
|
628
|
+
}
|
|
629
|
+
});
|
|
630
|
+
server.registerTool('siigo_get_quotation', {
|
|
631
|
+
title: 'Get Quotation',
|
|
632
|
+
description: 'Get a specific quotation by ID',
|
|
633
|
+
inputSchema: z.object({
|
|
634
|
+
id: z.string().describe('Quotation ID'),
|
|
635
|
+
}),
|
|
636
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
637
|
+
}, async ({ id }) => {
|
|
638
|
+
try {
|
|
639
|
+
return jsonResult(await client.getQuotation(id));
|
|
640
|
+
}
|
|
641
|
+
catch (e) {
|
|
642
|
+
return errorResult('siigo_get_quotation', e);
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
server.registerTool('siigo_create_quotation', {
|
|
646
|
+
title: 'Create Quotation',
|
|
647
|
+
description: 'Create a new quotation (cotizacion). Use document type C.',
|
|
648
|
+
inputSchema: z.object({
|
|
649
|
+
quotation: z.object({
|
|
650
|
+
document: z.object({ id: z.number().describe('Document type ID (type C)') }),
|
|
651
|
+
date: z.string().describe('Quotation date (YYYY-MM-DD)'),
|
|
652
|
+
customer: z.object({
|
|
653
|
+
identification: z.string().describe('Customer identification'),
|
|
654
|
+
branch_office: z.number().optional().describe('Branch office'),
|
|
655
|
+
}).describe('Customer reference'),
|
|
656
|
+
cost_center: z.number().optional().describe('Cost center ID'),
|
|
657
|
+
currency: z.object({
|
|
658
|
+
code: z.string().describe('Currency code'),
|
|
659
|
+
exchange_rate: z.number().describe('Exchange rate'),
|
|
660
|
+
}).optional().describe('Currency (omit for local currency)'),
|
|
661
|
+
seller: z.number().describe('Seller ID'),
|
|
662
|
+
observations: z.string().optional().describe('Observations'),
|
|
663
|
+
items: z.array(z.object({
|
|
664
|
+
code: z.string().describe('Product code'),
|
|
665
|
+
description: z.string().optional(),
|
|
666
|
+
quantity: z.number().describe('Quantity (max 9999999.99)'),
|
|
667
|
+
price: z.number().describe('Unit price (max 99999999999.99)'),
|
|
668
|
+
discount: z.number().optional().describe('Discount'),
|
|
669
|
+
taxes: z.array(z.object({ id: z.number() })).optional(),
|
|
670
|
+
})).describe('Quotation items'),
|
|
671
|
+
}).describe('Quotation data'),
|
|
672
|
+
}),
|
|
673
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
674
|
+
}, async ({ quotation }) => {
|
|
675
|
+
try {
|
|
676
|
+
return jsonResult(await client.createQuotation(quotation));
|
|
677
|
+
}
|
|
678
|
+
catch (e) {
|
|
679
|
+
return errorResult('siigo_create_quotation', e);
|
|
1143
680
|
}
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
681
|
+
});
|
|
682
|
+
server.registerTool('siigo_update_quotation', {
|
|
683
|
+
title: 'Update Quotation',
|
|
684
|
+
description: 'Update an existing quotation',
|
|
685
|
+
inputSchema: z.object({
|
|
686
|
+
id: z.string().describe('Quotation ID'),
|
|
687
|
+
quotation: z.record(z.unknown()).describe('Quotation data to update (partial)'),
|
|
688
|
+
}),
|
|
689
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
690
|
+
}, async ({ id, quotation }) => {
|
|
691
|
+
try {
|
|
692
|
+
return jsonResult(await client.updateQuotation(id, quotation));
|
|
693
|
+
}
|
|
694
|
+
catch (e) {
|
|
695
|
+
return errorResult('siigo_update_quotation', e);
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
server.registerTool('siigo_delete_quotation', {
|
|
699
|
+
title: 'Delete Quotation',
|
|
700
|
+
description: 'Delete a quotation',
|
|
701
|
+
inputSchema: z.object({
|
|
702
|
+
id: z.string().describe('Quotation ID'),
|
|
703
|
+
}),
|
|
704
|
+
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
705
|
+
}, async ({ id }) => {
|
|
706
|
+
try {
|
|
707
|
+
return jsonResult(await client.deleteQuotation(id));
|
|
708
|
+
}
|
|
709
|
+
catch (e) {
|
|
710
|
+
return errorResult('siigo_delete_quotation', e);
|
|
711
|
+
}
|
|
712
|
+
});
|
|
713
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
714
|
+
// CREDIT NOTES (4 tools)
|
|
715
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
716
|
+
server.registerTool('siigo_get_credit_notes', {
|
|
717
|
+
title: 'Get Credit Notes',
|
|
718
|
+
description: 'Get list of credit notes from Siigo',
|
|
719
|
+
inputSchema: z.object({
|
|
720
|
+
page: z.number().optional().describe('Page number'),
|
|
721
|
+
page_size: z.number().optional().describe('Number of items per page'),
|
|
722
|
+
}),
|
|
723
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
724
|
+
}, async (args) => {
|
|
725
|
+
try {
|
|
726
|
+
return jsonResult(await client.getCreditNotes(args));
|
|
727
|
+
}
|
|
728
|
+
catch (e) {
|
|
729
|
+
return errorResult('siigo_get_credit_notes', e);
|
|
730
|
+
}
|
|
731
|
+
});
|
|
732
|
+
server.registerTool('siigo_get_credit_note', {
|
|
733
|
+
title: 'Get Credit Note',
|
|
734
|
+
description: 'Get a specific credit note by ID',
|
|
735
|
+
inputSchema: z.object({
|
|
736
|
+
id: z.string().describe('Credit note ID'),
|
|
737
|
+
}),
|
|
738
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
739
|
+
}, async ({ id }) => {
|
|
740
|
+
try {
|
|
741
|
+
return jsonResult(await client.getCreditNote(id));
|
|
742
|
+
}
|
|
743
|
+
catch (e) {
|
|
744
|
+
return errorResult('siigo_get_credit_note', e);
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
server.registerTool('siigo_create_credit_note', {
|
|
748
|
+
title: 'Create Credit Note',
|
|
749
|
+
description: 'Create a new credit note. Supports healthcare sector fields via healthcare_company. Can reference an existing invoice or provide invoice_data for external invoices.',
|
|
750
|
+
inputSchema: z.object({
|
|
751
|
+
creditNote: z.object({
|
|
752
|
+
document: z.object({ id: z.number().describe('Document type ID (type NC)') }),
|
|
753
|
+
date: z.string().describe('Date (YYYY-MM-DD)'),
|
|
754
|
+
customer: z.object({
|
|
755
|
+
identification: z.string(),
|
|
756
|
+
branch_office: z.number().optional(),
|
|
757
|
+
}),
|
|
758
|
+
cost_center: z.number().optional(),
|
|
759
|
+
seller: z.number().optional().describe('Seller ID'),
|
|
760
|
+
items: z.array(z.object({
|
|
761
|
+
code: z.string(),
|
|
762
|
+
description: z.string().optional(),
|
|
763
|
+
quantity: z.number(),
|
|
764
|
+
price: z.number(),
|
|
765
|
+
discount: z.number().optional(),
|
|
766
|
+
taxes: z.array(z.object({ id: z.number() })).optional(),
|
|
767
|
+
})),
|
|
768
|
+
payments: z.array(z.object({
|
|
769
|
+
id: z.number(),
|
|
770
|
+
value: z.number(),
|
|
771
|
+
due_date: z.string().optional(),
|
|
772
|
+
})).optional(),
|
|
773
|
+
retentions: z.array(z.object({ id: z.number() })).optional(),
|
|
774
|
+
stamp: z.object({ send: z.boolean() }).optional(),
|
|
775
|
+
mail: z.object({ send: z.boolean() }).optional(),
|
|
776
|
+
observations: z.string().optional(),
|
|
777
|
+
invoice: z.string().optional().describe('Related invoice ID'),
|
|
778
|
+
invoice_data: z.object({
|
|
779
|
+
prefix: z.string().optional(),
|
|
780
|
+
number: z.number().optional(),
|
|
781
|
+
date: z.string().optional(),
|
|
782
|
+
cufe: z.string().optional(),
|
|
783
|
+
}).optional().describe('External invoice data (when invoice is not in Siigo)'),
|
|
784
|
+
reason: z.string().optional().describe('Credit note reason'),
|
|
785
|
+
healthcare_company: z.object({
|
|
786
|
+
operation_type: z.enum(['SS-CUFE', 'SS-SinAporte', 'SS-Recaudo']),
|
|
787
|
+
period_start: z.string().optional(),
|
|
788
|
+
period_end: z.string().optional(),
|
|
789
|
+
payment_method: z.number().optional(),
|
|
790
|
+
service_plan: z.number().optional(),
|
|
791
|
+
policy_number: z.string().optional(),
|
|
792
|
+
contract_number: z.string().optional(),
|
|
793
|
+
copayment: z.number().optional(),
|
|
794
|
+
coinsurance: z.number().optional(),
|
|
795
|
+
cost_sharing: z.number().optional(),
|
|
796
|
+
recovery_charge: z.number().optional(),
|
|
797
|
+
}).optional().describe('Healthcare sector fields'),
|
|
798
|
+
}).describe('Credit note data'),
|
|
799
|
+
}),
|
|
800
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
801
|
+
}, async ({ creditNote }) => {
|
|
802
|
+
try {
|
|
803
|
+
return jsonResult(await client.createCreditNote(creditNote));
|
|
804
|
+
}
|
|
805
|
+
catch (e) {
|
|
806
|
+
return errorResult('siigo_create_credit_note', e);
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
server.registerTool('siigo_get_credit_note_pdf', {
|
|
810
|
+
title: 'Get Credit Note PDF',
|
|
811
|
+
description: 'Get credit note PDF as base64',
|
|
812
|
+
inputSchema: z.object({
|
|
813
|
+
id: z.string().describe('Credit note ID'),
|
|
814
|
+
}),
|
|
815
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
816
|
+
}, async ({ id }) => {
|
|
817
|
+
try {
|
|
818
|
+
return jsonResult(await client.getCreditNotePdf(id));
|
|
819
|
+
}
|
|
820
|
+
catch (e) {
|
|
821
|
+
return errorResult('siigo_get_credit_note_pdf', e);
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
825
|
+
// VOUCHERS / CASH RECEIPTS - Recibos de Caja (3 tools)
|
|
826
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
827
|
+
server.registerTool('siigo_get_vouchers', {
|
|
828
|
+
title: 'Get Vouchers',
|
|
829
|
+
description: 'Get list of vouchers / cash receipts (recibos de caja) from Siigo',
|
|
830
|
+
inputSchema: z.object({
|
|
831
|
+
page: z.number().optional().describe('Page number'),
|
|
832
|
+
page_size: z.number().optional().describe('Number of items per page'),
|
|
833
|
+
}),
|
|
834
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
835
|
+
}, async (args) => {
|
|
836
|
+
try {
|
|
837
|
+
return jsonResult(await client.getVouchers(args));
|
|
1147
838
|
}
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
839
|
+
catch (e) {
|
|
840
|
+
return errorResult('siigo_get_vouchers', e);
|
|
1151
841
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
842
|
+
});
|
|
843
|
+
server.registerTool('siigo_get_voucher', {
|
|
844
|
+
title: 'Get Voucher',
|
|
845
|
+
description: 'Get a specific voucher / cash receipt by ID',
|
|
846
|
+
inputSchema: z.object({
|
|
847
|
+
id: z.string().describe('Voucher ID'),
|
|
848
|
+
}),
|
|
849
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
850
|
+
}, async ({ id }) => {
|
|
851
|
+
try {
|
|
852
|
+
return jsonResult(await client.getVoucher(id));
|
|
853
|
+
}
|
|
854
|
+
catch (e) {
|
|
855
|
+
return errorResult('siigo_get_voucher', e);
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
server.registerTool('siigo_create_voucher', {
|
|
859
|
+
title: 'Create Voucher',
|
|
860
|
+
description: 'Create a new voucher / cash receipt (recibo de caja). Supports DebtPayment, AdvancePayment, and Advanced types.',
|
|
861
|
+
inputSchema: z.object({
|
|
862
|
+
voucher: z.object({
|
|
863
|
+
document: z.object({ id: z.number().describe('Document type ID (type RC)') }),
|
|
864
|
+
date: z.string().describe('Date (YYYY-MM-DD)'),
|
|
865
|
+
type: z.enum(['DebtPayment', 'AdvancePayment', 'Advanced']).describe('Voucher type'),
|
|
866
|
+
customer: z.object({
|
|
867
|
+
identification: z.string(),
|
|
868
|
+
branch_office: z.number().optional(),
|
|
869
|
+
}),
|
|
870
|
+
cost_center: z.number().optional(),
|
|
871
|
+
currency: z.object({
|
|
872
|
+
code: z.string(),
|
|
873
|
+
exchange_rate: z.number(),
|
|
874
|
+
}).optional(),
|
|
875
|
+
items: z.array(z.record(z.unknown())).describe('Voucher items (structure varies by type)'),
|
|
876
|
+
payments: z.array(z.object({
|
|
877
|
+
id: z.number(),
|
|
878
|
+
value: z.number(),
|
|
879
|
+
due_date: z.string().optional(),
|
|
880
|
+
})).optional(),
|
|
881
|
+
observations: z.string().optional(),
|
|
882
|
+
}).describe('Voucher data'),
|
|
883
|
+
}),
|
|
884
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
885
|
+
}, async ({ voucher }) => {
|
|
886
|
+
try {
|
|
887
|
+
return jsonResult(await client.createVoucher(voucher));
|
|
888
|
+
}
|
|
889
|
+
catch (e) {
|
|
890
|
+
return errorResult('siigo_create_voucher', e);
|
|
1155
891
|
}
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
892
|
+
});
|
|
893
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
894
|
+
// PURCHASES - Facturas de Compra (5 tools)
|
|
895
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
896
|
+
server.registerTool('siigo_get_purchases', {
|
|
897
|
+
title: 'Get Purchases',
|
|
898
|
+
description: 'Get list of purchase invoices (facturas de compra) from Siigo',
|
|
899
|
+
inputSchema: z.object({
|
|
900
|
+
page: z.number().optional().describe('Page number'),
|
|
901
|
+
page_size: z.number().optional().describe('Number of items per page'),
|
|
902
|
+
}),
|
|
903
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
904
|
+
}, async (args) => {
|
|
905
|
+
try {
|
|
906
|
+
return jsonResult(await client.getPurchases(args));
|
|
1159
907
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
908
|
+
catch (e) {
|
|
909
|
+
return errorResult('siigo_get_purchases', e);
|
|
1163
910
|
}
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
911
|
+
});
|
|
912
|
+
server.registerTool('siigo_get_purchase', {
|
|
913
|
+
title: 'Get Purchase',
|
|
914
|
+
description: 'Get a specific purchase invoice by ID',
|
|
915
|
+
inputSchema: z.object({
|
|
916
|
+
id: z.string().describe('Purchase ID'),
|
|
917
|
+
}),
|
|
918
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
919
|
+
}, async ({ id }) => {
|
|
920
|
+
try {
|
|
921
|
+
return jsonResult(await client.getPurchase(id));
|
|
1167
922
|
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
923
|
+
catch (e) {
|
|
924
|
+
return errorResult('siigo_get_purchase', e);
|
|
1171
925
|
}
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
926
|
+
});
|
|
927
|
+
server.registerTool('siigo_create_purchase', {
|
|
928
|
+
title: 'Create Purchase',
|
|
929
|
+
description: 'Create a new purchase invoice (factura de compra). Use document type FC. If the document type has document_support=true, it creates a Documento Soporte.',
|
|
930
|
+
inputSchema: z.object({
|
|
931
|
+
purchase: z.record(z.unknown()).describe('Purchase data'),
|
|
932
|
+
}),
|
|
933
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
934
|
+
}, async ({ purchase }) => {
|
|
935
|
+
try {
|
|
936
|
+
return jsonResult(await client.createPurchase(purchase));
|
|
1175
937
|
}
|
|
938
|
+
catch (e) {
|
|
939
|
+
return errorResult('siigo_create_purchase', e);
|
|
940
|
+
}
|
|
941
|
+
});
|
|
942
|
+
server.registerTool('siigo_update_purchase', {
|
|
943
|
+
title: 'Update Purchase',
|
|
944
|
+
description: 'Update an existing purchase invoice',
|
|
945
|
+
inputSchema: z.object({
|
|
946
|
+
id: z.string().describe('Purchase ID'),
|
|
947
|
+
purchase: z.record(z.unknown()).describe('Purchase data to update (partial)'),
|
|
948
|
+
}),
|
|
949
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
950
|
+
}, async ({ id, purchase }) => {
|
|
951
|
+
try {
|
|
952
|
+
return jsonResult(await client.updatePurchase(id, purchase));
|
|
953
|
+
}
|
|
954
|
+
catch (e) {
|
|
955
|
+
return errorResult('siigo_update_purchase', e);
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
server.registerTool('siigo_delete_purchase', {
|
|
959
|
+
title: 'Delete Purchase',
|
|
960
|
+
description: 'Delete a purchase invoice',
|
|
961
|
+
inputSchema: z.object({
|
|
962
|
+
id: z.string().describe('Purchase ID'),
|
|
963
|
+
}),
|
|
964
|
+
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
965
|
+
}, async ({ id }) => {
|
|
966
|
+
try {
|
|
967
|
+
return jsonResult(await client.deletePurchase(id));
|
|
968
|
+
}
|
|
969
|
+
catch (e) {
|
|
970
|
+
return errorResult('siigo_delete_purchase', e);
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
974
|
+
// PAYMENT RECEIPTS - Recibos de Pago / Comprobantes de Egreso (5 tools)
|
|
975
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
976
|
+
server.registerTool('siigo_get_payment_receipts', {
|
|
977
|
+
title: 'Get Payment Receipts',
|
|
978
|
+
description: 'Get list of payment receipts / disbursements (recibos de pago / comprobantes de egreso) from Siigo',
|
|
979
|
+
inputSchema: z.object({
|
|
980
|
+
page: z.number().optional().describe('Page number'),
|
|
981
|
+
page_size: z.number().optional().describe('Number of items per page'),
|
|
982
|
+
}),
|
|
983
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
984
|
+
}, async (args) => {
|
|
985
|
+
try {
|
|
986
|
+
return jsonResult(await client.getPaymentReceipts(args));
|
|
987
|
+
}
|
|
988
|
+
catch (e) {
|
|
989
|
+
return errorResult('siigo_get_payment_receipts', e);
|
|
990
|
+
}
|
|
991
|
+
});
|
|
992
|
+
server.registerTool('siigo_get_payment_receipt', {
|
|
993
|
+
title: 'Get Payment Receipt',
|
|
994
|
+
description: 'Get a specific payment receipt by ID',
|
|
995
|
+
inputSchema: z.object({
|
|
996
|
+
id: z.string().describe('Payment receipt ID'),
|
|
997
|
+
}),
|
|
998
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
999
|
+
}, async ({ id }) => {
|
|
1000
|
+
try {
|
|
1001
|
+
return jsonResult(await client.getPaymentReceipt(id));
|
|
1002
|
+
}
|
|
1003
|
+
catch (e) {
|
|
1004
|
+
return errorResult('siigo_get_payment_receipt', e);
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
1007
|
+
server.registerTool('siigo_create_payment_receipt', {
|
|
1008
|
+
title: 'Create Payment Receipt',
|
|
1009
|
+
description: 'Create a new payment receipt / disbursement (recibo de pago / comprobante de egreso). Supports DebtPayment, AdvancePayment, and Advanced types.',
|
|
1010
|
+
inputSchema: z.object({
|
|
1011
|
+
paymentReceipt: z.object({
|
|
1012
|
+
document: z.object({ id: z.number().describe('Document type ID (type RP)') }),
|
|
1013
|
+
date: z.string().describe('Date (YYYY-MM-DD)'),
|
|
1014
|
+
type: z.enum(['DebtPayment', 'AdvancePayment', 'Advanced']).describe('Receipt type'),
|
|
1015
|
+
customer: z.object({
|
|
1016
|
+
identification: z.string(),
|
|
1017
|
+
branch_office: z.number().optional(),
|
|
1018
|
+
}),
|
|
1019
|
+
cost_center: z.number().optional(),
|
|
1020
|
+
currency: z.object({
|
|
1021
|
+
code: z.string(),
|
|
1022
|
+
exchange_rate: z.number(),
|
|
1023
|
+
}).optional(),
|
|
1024
|
+
items: z.array(z.record(z.unknown())).describe('Receipt items (structure varies by type)'),
|
|
1025
|
+
payments: z.array(z.object({
|
|
1026
|
+
id: z.number(),
|
|
1027
|
+
value: z.number(),
|
|
1028
|
+
due_date: z.string().optional(),
|
|
1029
|
+
})).optional(),
|
|
1030
|
+
observations: z.string().optional(),
|
|
1031
|
+
}).describe('Payment receipt data'),
|
|
1032
|
+
}),
|
|
1033
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
1034
|
+
}, async ({ paymentReceipt }) => {
|
|
1035
|
+
try {
|
|
1036
|
+
return jsonResult(await client.createPaymentReceipt(paymentReceipt));
|
|
1037
|
+
}
|
|
1038
|
+
catch (e) {
|
|
1039
|
+
return errorResult('siigo_create_payment_receipt', e);
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
server.registerTool('siigo_update_payment_receipt', {
|
|
1043
|
+
title: 'Update Payment Receipt',
|
|
1044
|
+
description: 'Update an existing payment receipt',
|
|
1045
|
+
inputSchema: z.object({
|
|
1046
|
+
id: z.string().describe('Payment receipt ID'),
|
|
1047
|
+
paymentReceipt: z.record(z.unknown()).describe('Payment receipt data to update (partial)'),
|
|
1048
|
+
}),
|
|
1049
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
1050
|
+
}, async ({ id, paymentReceipt }) => {
|
|
1051
|
+
try {
|
|
1052
|
+
return jsonResult(await client.updatePaymentReceipt(id, paymentReceipt));
|
|
1053
|
+
}
|
|
1054
|
+
catch (e) {
|
|
1055
|
+
return errorResult('siigo_update_payment_receipt', e);
|
|
1056
|
+
}
|
|
1057
|
+
});
|
|
1058
|
+
server.registerTool('siigo_delete_payment_receipt', {
|
|
1059
|
+
title: 'Delete Payment Receipt',
|
|
1060
|
+
description: 'Delete a payment receipt',
|
|
1061
|
+
inputSchema: z.object({
|
|
1062
|
+
id: z.string().describe('Payment receipt ID'),
|
|
1063
|
+
}),
|
|
1064
|
+
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
1065
|
+
}, async ({ id }) => {
|
|
1066
|
+
try {
|
|
1067
|
+
return jsonResult(await client.deletePaymentReceipt(id));
|
|
1068
|
+
}
|
|
1069
|
+
catch (e) {
|
|
1070
|
+
return errorResult('siigo_delete_payment_receipt', e);
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1074
|
+
// JOURNALS - Comprobantes Contables (3 tools)
|
|
1075
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1076
|
+
server.registerTool('siigo_get_journals', {
|
|
1077
|
+
title: 'Get Journals',
|
|
1078
|
+
description: 'Get list of accounting journals (comprobantes contables) from Siigo',
|
|
1079
|
+
inputSchema: z.object({
|
|
1080
|
+
page: z.number().optional().describe('Page number'),
|
|
1081
|
+
page_size: z.number().optional().describe('Number of items per page'),
|
|
1082
|
+
}),
|
|
1083
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1084
|
+
}, async (args) => {
|
|
1085
|
+
try {
|
|
1086
|
+
return jsonResult(await client.getJournals(args));
|
|
1087
|
+
}
|
|
1088
|
+
catch (e) {
|
|
1089
|
+
return errorResult('siigo_get_journals', e);
|
|
1090
|
+
}
|
|
1091
|
+
});
|
|
1092
|
+
server.registerTool('siigo_get_journal', {
|
|
1093
|
+
title: 'Get Journal',
|
|
1094
|
+
description: 'Get a specific accounting journal by ID',
|
|
1095
|
+
inputSchema: z.object({
|
|
1096
|
+
id: z.string().describe('Journal ID'),
|
|
1097
|
+
}),
|
|
1098
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1099
|
+
}, async ({ id }) => {
|
|
1100
|
+
try {
|
|
1101
|
+
return jsonResult(await client.getJournal(id));
|
|
1102
|
+
}
|
|
1103
|
+
catch (e) {
|
|
1104
|
+
return errorResult('siigo_get_journal', e);
|
|
1105
|
+
}
|
|
1106
|
+
});
|
|
1107
|
+
server.registerTool('siigo_create_journal', {
|
|
1108
|
+
title: 'Create Journal',
|
|
1109
|
+
description: 'Create a new accounting journal entry (comprobante contable)',
|
|
1110
|
+
inputSchema: z.object({
|
|
1111
|
+
journal: z.object({
|
|
1112
|
+
document: z.object({ id: z.number().describe('Document type ID (type CC)') }),
|
|
1113
|
+
date: z.string().describe('Date (YYYY-MM-DD)'),
|
|
1114
|
+
items: z.array(z.object({
|
|
1115
|
+
account: z.object({
|
|
1116
|
+
code: z.string().describe('Account code'),
|
|
1117
|
+
movement: z.enum(['Debit', 'Credit']).describe('Movement type'),
|
|
1118
|
+
}),
|
|
1119
|
+
customer: z.object({
|
|
1120
|
+
identification: z.string(),
|
|
1121
|
+
branch_office: z.number().optional(),
|
|
1122
|
+
}).optional().describe('Third party reference'),
|
|
1123
|
+
description: z.string().optional(),
|
|
1124
|
+
value: z.number().describe('Value'),
|
|
1125
|
+
cost_center: z.number().optional(),
|
|
1126
|
+
})).describe('Journal items (debits must equal credits)'),
|
|
1127
|
+
observations: z.string().optional(),
|
|
1128
|
+
}).describe('Journal data'),
|
|
1129
|
+
}),
|
|
1130
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
1131
|
+
}, async ({ journal }) => {
|
|
1132
|
+
try {
|
|
1133
|
+
return jsonResult(await client.createJournal(journal));
|
|
1134
|
+
}
|
|
1135
|
+
catch (e) {
|
|
1136
|
+
return errorResult('siigo_create_journal', e);
|
|
1137
|
+
}
|
|
1138
|
+
});
|
|
1139
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1140
|
+
// WEBHOOKS (4 tools)
|
|
1141
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1142
|
+
server.registerTool('siigo_get_webhooks', {
|
|
1143
|
+
title: 'Get Webhooks',
|
|
1144
|
+
description: 'Get list of webhook subscriptions',
|
|
1145
|
+
inputSchema: z.object({}),
|
|
1146
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1147
|
+
}, async () => {
|
|
1148
|
+
try {
|
|
1149
|
+
return jsonResult(await client.getWebhooks());
|
|
1150
|
+
}
|
|
1151
|
+
catch (e) {
|
|
1152
|
+
return errorResult('siigo_get_webhooks', e);
|
|
1153
|
+
}
|
|
1154
|
+
});
|
|
1155
|
+
server.registerTool('siigo_create_webhook', {
|
|
1156
|
+
title: 'Create Webhook',
|
|
1157
|
+
description: 'Subscribe to a webhook event',
|
|
1158
|
+
inputSchema: z.object({
|
|
1159
|
+
event: z.string().describe('Event to subscribe to'),
|
|
1160
|
+
url: z.string().describe('Webhook URL (HTTPS)'),
|
|
1161
|
+
secret: z.string().optional().describe('Webhook secret for signature verification'),
|
|
1162
|
+
}),
|
|
1163
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
1164
|
+
}, async (args) => {
|
|
1165
|
+
try {
|
|
1166
|
+
return jsonResult(await client.createWebhook(args));
|
|
1167
|
+
}
|
|
1168
|
+
catch (e) {
|
|
1169
|
+
return errorResult('siigo_create_webhook', e);
|
|
1170
|
+
}
|
|
1171
|
+
});
|
|
1172
|
+
server.registerTool('siigo_update_webhook', {
|
|
1173
|
+
title: 'Update Webhook',
|
|
1174
|
+
description: 'Update an existing webhook subscription',
|
|
1175
|
+
inputSchema: z.object({
|
|
1176
|
+
id: z.string().describe('Webhook ID'),
|
|
1177
|
+
event: z.string().optional().describe('Event to subscribe to'),
|
|
1178
|
+
url: z.string().optional().describe('Webhook URL (HTTPS)'),
|
|
1179
|
+
secret: z.string().optional().describe('Webhook secret'),
|
|
1180
|
+
active: z.boolean().optional().describe('Active status'),
|
|
1181
|
+
}),
|
|
1182
|
+
annotations: { readOnlyHint: false, destructiveHint: false },
|
|
1183
|
+
}, async ({ id, ...webhook }) => {
|
|
1184
|
+
try {
|
|
1185
|
+
return jsonResult(await client.updateWebhook(id, webhook));
|
|
1186
|
+
}
|
|
1187
|
+
catch (e) {
|
|
1188
|
+
return errorResult('siigo_update_webhook', e);
|
|
1189
|
+
}
|
|
1190
|
+
});
|
|
1191
|
+
server.registerTool('siigo_delete_webhook', {
|
|
1192
|
+
title: 'Delete Webhook',
|
|
1193
|
+
description: 'Delete a webhook subscription',
|
|
1194
|
+
inputSchema: z.object({
|
|
1195
|
+
id: z.string().describe('Webhook ID'),
|
|
1196
|
+
}),
|
|
1197
|
+
annotations: { readOnlyHint: false, destructiveHint: true },
|
|
1198
|
+
}, async ({ id }) => {
|
|
1199
|
+
try {
|
|
1200
|
+
return jsonResult(await client.deleteWebhook(id));
|
|
1201
|
+
}
|
|
1202
|
+
catch (e) {
|
|
1203
|
+
return errorResult('siigo_delete_webhook', e);
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1207
|
+
// CATALOGS (12 tools)
|
|
1208
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1209
|
+
server.registerTool('siigo_get_document_types', {
|
|
1210
|
+
title: 'Get Document Types',
|
|
1211
|
+
description: 'Get document types catalog. Filter by type: FV (sales invoice), RC (cash receipt), NC (credit note), FC (purchase invoice), CC (journal), RP (payment receipt), C (quotation).',
|
|
1212
|
+
inputSchema: z.object({
|
|
1213
|
+
type: z.enum(['FV', 'RC', 'NC', 'FC', 'CC', 'RP', 'C']).optional().describe('Document type filter'),
|
|
1214
|
+
}),
|
|
1215
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1216
|
+
}, async ({ type }) => {
|
|
1217
|
+
try {
|
|
1218
|
+
return jsonResult(await client.getDocumentTypes(type));
|
|
1219
|
+
}
|
|
1220
|
+
catch (e) {
|
|
1221
|
+
return errorResult('siigo_get_document_types', e);
|
|
1222
|
+
}
|
|
1223
|
+
});
|
|
1224
|
+
server.registerTool('siigo_get_taxes', {
|
|
1225
|
+
title: 'Get Taxes',
|
|
1226
|
+
description: 'Get taxes catalog (IVA, Retefuente, ReteIVA, ReteICA, Impoconsumo, AdValorem, Autorretencion)',
|
|
1227
|
+
inputSchema: z.object({}),
|
|
1228
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1229
|
+
}, async () => {
|
|
1230
|
+
try {
|
|
1231
|
+
return jsonResult(await client.getTaxes());
|
|
1232
|
+
}
|
|
1233
|
+
catch (e) {
|
|
1234
|
+
return errorResult('siigo_get_taxes', e);
|
|
1235
|
+
}
|
|
1236
|
+
});
|
|
1237
|
+
server.registerTool('siigo_get_payment_types', {
|
|
1238
|
+
title: 'Get Payment Types',
|
|
1239
|
+
description: 'Get payment types catalog. Filter by document_type to get applicable payment methods.',
|
|
1240
|
+
inputSchema: z.object({
|
|
1241
|
+
document_type: z.string().optional().describe('Document type filter (FV, NC, RC, etc.)'),
|
|
1242
|
+
}),
|
|
1243
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1244
|
+
}, async ({ document_type }) => {
|
|
1245
|
+
try {
|
|
1246
|
+
return jsonResult(await client.getPaymentTypes(document_type));
|
|
1247
|
+
}
|
|
1248
|
+
catch (e) {
|
|
1249
|
+
return errorResult('siigo_get_payment_types', e);
|
|
1250
|
+
}
|
|
1251
|
+
});
|
|
1252
|
+
server.registerTool('siigo_get_cost_centers', {
|
|
1253
|
+
title: 'Get Cost Centers',
|
|
1254
|
+
description: 'Get cost centers catalog',
|
|
1255
|
+
inputSchema: z.object({}),
|
|
1256
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1257
|
+
}, async () => {
|
|
1258
|
+
try {
|
|
1259
|
+
return jsonResult(await client.getCostCenters());
|
|
1260
|
+
}
|
|
1261
|
+
catch (e) {
|
|
1262
|
+
return errorResult('siigo_get_cost_centers', e);
|
|
1263
|
+
}
|
|
1264
|
+
});
|
|
1265
|
+
server.registerTool('siigo_get_users', {
|
|
1266
|
+
title: 'Get Users',
|
|
1267
|
+
description: 'Get users/sellers catalog',
|
|
1268
|
+
inputSchema: z.object({}),
|
|
1269
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1270
|
+
}, async () => {
|
|
1271
|
+
try {
|
|
1272
|
+
return jsonResult(await client.getUsers());
|
|
1273
|
+
}
|
|
1274
|
+
catch (e) {
|
|
1275
|
+
return errorResult('siigo_get_users', e);
|
|
1276
|
+
}
|
|
1277
|
+
});
|
|
1278
|
+
server.registerTool('siigo_get_warehouses', {
|
|
1279
|
+
title: 'Get Warehouses',
|
|
1280
|
+
description: 'Get warehouses catalog',
|
|
1281
|
+
inputSchema: z.object({}),
|
|
1282
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1283
|
+
}, async () => {
|
|
1284
|
+
try {
|
|
1285
|
+
return jsonResult(await client.getWarehouses());
|
|
1286
|
+
}
|
|
1287
|
+
catch (e) {
|
|
1288
|
+
return errorResult('siigo_get_warehouses', e);
|
|
1289
|
+
}
|
|
1290
|
+
});
|
|
1291
|
+
server.registerTool('siigo_get_price_lists', {
|
|
1292
|
+
title: 'Get Price Lists',
|
|
1293
|
+
description: 'Get price lists catalog (up to 12 price lists)',
|
|
1294
|
+
inputSchema: z.object({}),
|
|
1295
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1296
|
+
}, async () => {
|
|
1297
|
+
try {
|
|
1298
|
+
return jsonResult(await client.getPriceLists());
|
|
1299
|
+
}
|
|
1300
|
+
catch (e) {
|
|
1301
|
+
return errorResult('siigo_get_price_lists', e);
|
|
1302
|
+
}
|
|
1303
|
+
});
|
|
1304
|
+
server.registerTool('siigo_get_cities', {
|
|
1305
|
+
title: 'Get Cities',
|
|
1306
|
+
description: 'Get cities catalog (Colombian cities with country/state/city codes)',
|
|
1307
|
+
inputSchema: z.object({}),
|
|
1308
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1309
|
+
}, async () => {
|
|
1310
|
+
try {
|
|
1311
|
+
return jsonResult(await client.getCities());
|
|
1312
|
+
}
|
|
1313
|
+
catch (e) {
|
|
1314
|
+
return errorResult('siigo_get_cities', e);
|
|
1315
|
+
}
|
|
1316
|
+
});
|
|
1317
|
+
server.registerTool('siigo_get_id_types', {
|
|
1318
|
+
title: 'Get ID Types',
|
|
1319
|
+
description: 'Get identification types catalog',
|
|
1320
|
+
inputSchema: z.object({}),
|
|
1321
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1322
|
+
}, async () => {
|
|
1323
|
+
try {
|
|
1324
|
+
return jsonResult(await client.getIdTypes());
|
|
1325
|
+
}
|
|
1326
|
+
catch (e) {
|
|
1327
|
+
return errorResult('siigo_get_id_types', e);
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1330
|
+
server.registerTool('siigo_get_fiscal_responsibilities', {
|
|
1331
|
+
title: 'Get Fiscal Responsibilities',
|
|
1332
|
+
description: 'Get fiscal responsibilities catalog',
|
|
1333
|
+
inputSchema: z.object({}),
|
|
1334
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1335
|
+
}, async () => {
|
|
1336
|
+
try {
|
|
1337
|
+
return jsonResult(await client.getFiscalResponsibilities());
|
|
1338
|
+
}
|
|
1339
|
+
catch (e) {
|
|
1340
|
+
return errorResult('siigo_get_fiscal_responsibilities', e);
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1343
|
+
server.registerTool('siigo_get_fixed_assets', {
|
|
1344
|
+
title: 'Get Fixed Assets',
|
|
1345
|
+
description: 'Get fixed assets catalog',
|
|
1346
|
+
inputSchema: z.object({}),
|
|
1347
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1348
|
+
}, async () => {
|
|
1349
|
+
try {
|
|
1350
|
+
return jsonResult(await client.getFixedAssets());
|
|
1351
|
+
}
|
|
1352
|
+
catch (e) {
|
|
1353
|
+
return errorResult('siigo_get_fixed_assets', e);
|
|
1354
|
+
}
|
|
1355
|
+
});
|
|
1356
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1357
|
+
// REPORTS (3 tools)
|
|
1358
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1359
|
+
server.registerTool('siigo_get_trial_balance', {
|
|
1360
|
+
title: 'Get Trial Balance',
|
|
1361
|
+
description: 'Generate trial balance report (Excel). Uses POST as per Siigo API spec.',
|
|
1362
|
+
inputSchema: z.object({
|
|
1363
|
+
account_start: z.string().optional().describe('Starting account code'),
|
|
1364
|
+
account_end: z.string().optional().describe('Ending account code'),
|
|
1365
|
+
year: z.number().describe('Year'),
|
|
1366
|
+
month_start: z.number().describe('Starting month (1-13)'),
|
|
1367
|
+
month_end: z.number().describe('Ending month (1-13)'),
|
|
1368
|
+
includes_tax_difference: z.boolean().describe('Include tax differences'),
|
|
1369
|
+
}),
|
|
1370
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1371
|
+
}, async (args) => {
|
|
1372
|
+
try {
|
|
1373
|
+
return jsonResult(await client.getTrialBalance(args));
|
|
1374
|
+
}
|
|
1375
|
+
catch (e) {
|
|
1376
|
+
return errorResult('siigo_get_trial_balance', e);
|
|
1377
|
+
}
|
|
1378
|
+
});
|
|
1379
|
+
server.registerTool('siigo_get_trial_balance_by_third', {
|
|
1380
|
+
title: 'Get Trial Balance by Third',
|
|
1381
|
+
description: 'Generate trial balance by third party report (Excel). Uses POST as per Siigo API spec.',
|
|
1382
|
+
inputSchema: z.object({
|
|
1383
|
+
account_start: z.string().optional().describe('Starting account code'),
|
|
1384
|
+
account_end: z.string().optional().describe('Ending account code'),
|
|
1385
|
+
year: z.number().describe('Year'),
|
|
1386
|
+
month_start: z.number().describe('Starting month (1-13)'),
|
|
1387
|
+
month_end: z.number().describe('Ending month (1-13)'),
|
|
1388
|
+
includes_tax_difference: z.boolean().describe('Include tax differences'),
|
|
1389
|
+
customer: z.object({
|
|
1390
|
+
identification: z.string(),
|
|
1391
|
+
branch_office: z.number().optional(),
|
|
1392
|
+
}).optional().describe('Customer filter'),
|
|
1393
|
+
}),
|
|
1394
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1395
|
+
}, async (args) => {
|
|
1396
|
+
try {
|
|
1397
|
+
return jsonResult(await client.getTrialBalanceByThird(args));
|
|
1398
|
+
}
|
|
1399
|
+
catch (e) {
|
|
1400
|
+
return errorResult('siigo_get_trial_balance_by_third', e);
|
|
1401
|
+
}
|
|
1402
|
+
});
|
|
1403
|
+
server.registerTool('siigo_get_accounts_payable', {
|
|
1404
|
+
title: 'Get Accounts Payable',
|
|
1405
|
+
description: 'Get accounts payable report',
|
|
1406
|
+
inputSchema: z.object({
|
|
1407
|
+
page: z.number().optional().describe('Page number'),
|
|
1408
|
+
page_size: z.number().optional().describe('Number of items per page'),
|
|
1409
|
+
}),
|
|
1410
|
+
annotations: { readOnlyHint: true, destructiveHint: false },
|
|
1411
|
+
}, async (args) => {
|
|
1412
|
+
try {
|
|
1413
|
+
return jsonResult(await client.getAccountsPayable(args));
|
|
1414
|
+
}
|
|
1415
|
+
catch (e) {
|
|
1416
|
+
return errorResult('siigo_get_accounts_payable', e);
|
|
1417
|
+
}
|
|
1418
|
+
});
|
|
1419
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1420
|
+
// START SERVER
|
|
1421
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
1422
|
+
async function main() {
|
|
1423
|
+
const transport = new StdioServerTransport();
|
|
1424
|
+
await server.connect(transport);
|
|
1176
1425
|
}
|
|
1177
|
-
|
|
1178
|
-
server.run().catch(console.error);
|
|
1426
|
+
main().catch(console.error);
|
|
1179
1427
|
//# sourceMappingURL=index.js.map
|