@dannychirkov/salesdrive-mcp-server 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +223 -0
  2. package/dist/cli/index.d.ts +6 -0
  3. package/dist/cli/index.d.ts.map +1 -0
  4. package/dist/cli/index.js +12 -0
  5. package/dist/cli/index.js.map +1 -0
  6. package/dist/config.d.ts +34 -0
  7. package/dist/config.d.ts.map +1 -0
  8. package/dist/config.js +46 -0
  9. package/dist/config.js.map +1 -0
  10. package/dist/server.d.ts +47 -0
  11. package/dist/server.d.ts.map +1 -0
  12. package/dist/server.js +195 -0
  13. package/dist/server.js.map +1 -0
  14. package/dist/tools/act.d.ts +20 -0
  15. package/dist/tools/act.d.ts.map +1 -0
  16. package/dist/tools/act.js +80 -0
  17. package/dist/tools/act.js.map +1 -0
  18. package/dist/tools/arrival.d.ts +20 -0
  19. package/dist/tools/arrival.d.ts.map +1 -0
  20. package/dist/tools/arrival.js +74 -0
  21. package/dist/tools/arrival.js.map +1 -0
  22. package/dist/tools/cashOrder.d.ts +20 -0
  23. package/dist/tools/cashOrder.d.ts.map +1 -0
  24. package/dist/tools/cashOrder.js +75 -0
  25. package/dist/tools/cashOrder.js.map +1 -0
  26. package/dist/tools/category.d.ts +20 -0
  27. package/dist/tools/category.d.ts.map +1 -0
  28. package/dist/tools/category.js +93 -0
  29. package/dist/tools/category.js.map +1 -0
  30. package/dist/tools/check.d.ts +20 -0
  31. package/dist/tools/check.d.ts.map +1 -0
  32. package/dist/tools/check.js +74 -0
  33. package/dist/tools/check.js.map +1 -0
  34. package/dist/tools/contract.d.ts +20 -0
  35. package/dist/tools/contract.d.ts.map +1 -0
  36. package/dist/tools/contract.js +74 -0
  37. package/dist/tools/contract.js.map +1 -0
  38. package/dist/tools/currency.d.ts +20 -0
  39. package/dist/tools/currency.d.ts.map +1 -0
  40. package/dist/tools/currency.js +75 -0
  41. package/dist/tools/currency.js.map +1 -0
  42. package/dist/tools/index.d.ts +17 -0
  43. package/dist/tools/index.d.ts.map +1 -0
  44. package/dist/tools/index.js +46 -0
  45. package/dist/tools/index.js.map +1 -0
  46. package/dist/tools/invoice.d.ts +20 -0
  47. package/dist/tools/invoice.d.ts.map +1 -0
  48. package/dist/tools/invoice.js +80 -0
  49. package/dist/tools/invoice.js.map +1 -0
  50. package/dist/tools/order.d.ts +20 -0
  51. package/dist/tools/order.d.ts.map +1 -0
  52. package/dist/tools/order.js +194 -0
  53. package/dist/tools/order.js.map +1 -0
  54. package/dist/tools/payment.d.ts +20 -0
  55. package/dist/tools/payment.d.ts.map +1 -0
  56. package/dist/tools/payment.js +119 -0
  57. package/dist/tools/payment.js.map +1 -0
  58. package/dist/tools/product.d.ts +20 -0
  59. package/dist/tools/product.d.ts.map +1 -0
  60. package/dist/tools/product.js +94 -0
  61. package/dist/tools/product.js.map +1 -0
  62. package/dist/tools/reference.d.ts +20 -0
  63. package/dist/tools/reference.d.ts.map +1 -0
  64. package/dist/tools/reference.js +105 -0
  65. package/dist/tools/reference.js.map +1 -0
  66. package/dist/tools/salesInvoice.d.ts +20 -0
  67. package/dist/tools/salesInvoice.d.ts.map +1 -0
  68. package/dist/tools/salesInvoice.js +80 -0
  69. package/dist/tools/salesInvoice.js.map +1 -0
  70. package/dist/utils/error-handler.d.ts +23 -0
  71. package/dist/utils/error-handler.d.ts.map +1 -0
  72. package/dist/utils/error-handler.js +50 -0
  73. package/dist/utils/error-handler.js.map +1 -0
  74. package/dist/utils/logger.d.ts +15 -0
  75. package/dist/utils/logger.d.ts.map +1 -0
  76. package/dist/utils/logger.js +44 -0
  77. package/dist/utils/logger.js.map +1 -0
  78. package/package.json +57 -0
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Product Tools for MCP Server
3
+ */
4
+ import type { Tool } from '@modelcontextprotocol/sdk/types.js';
5
+ /**
6
+ * Product tool definitions
7
+ */
8
+ export declare const productTools: Tool[];
9
+ type AnyClient = any;
10
+ /**
11
+ * Handle product tool calls
12
+ */
13
+ export declare function handleProductTool(toolName: string, args: Record<string, unknown>, client: AnyClient): Promise<{
14
+ content: Array<{
15
+ type: "text";
16
+ text: string;
17
+ }>;
18
+ }>;
19
+ export {};
20
+ //# sourceMappingURL=product.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product.d.ts","sourceRoot":"","sources":["../../src/tools/product.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAI/D;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,IAAI,EA+C9B,CAAC;AAGF,KAAK,SAAS,GAAG,GAAG,CAAC;AAErB;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,SAAS;;;;;GAyClB"}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ /**
3
+ * Product Tools for MCP Server
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.productTools = void 0;
7
+ exports.handleProductTool = handleProductTool;
8
+ const error_handler_js_1 = require("../utils/error-handler.js");
9
+ const logger_js_1 = require("../utils/logger.js");
10
+ /**
11
+ * Product tool definitions
12
+ */
13
+ exports.productTools = [
14
+ {
15
+ name: 'product_update',
16
+ description: 'Add or update products in SalesDrive (batch operation, up to 100 products)',
17
+ inputSchema: {
18
+ type: 'object',
19
+ properties: {
20
+ products: {
21
+ type: 'array',
22
+ description: 'Products to add/update',
23
+ items: {
24
+ type: 'object',
25
+ properties: {
26
+ id: { type: 'string', description: 'Product ID' },
27
+ name: { type: 'string', description: 'Product name' },
28
+ price: { type: 'number', description: 'Product price' },
29
+ sku: { type: 'string', description: 'SKU code' },
30
+ stockBalance: { type: 'number', description: 'Stock quantity' },
31
+ description: { type: 'string', description: 'Product description' },
32
+ },
33
+ required: ['id'],
34
+ },
35
+ },
36
+ dontUpdateFields: {
37
+ type: 'array',
38
+ description: 'Fields to skip during update (e.g., ["price", "description"])',
39
+ items: { type: 'string' },
40
+ },
41
+ },
42
+ required: ['products'],
43
+ },
44
+ },
45
+ {
46
+ name: 'product_delete',
47
+ description: 'Delete products from SalesDrive by ID',
48
+ inputSchema: {
49
+ type: 'object',
50
+ properties: {
51
+ productIds: {
52
+ type: 'array',
53
+ description: 'Product IDs to delete',
54
+ items: { type: 'string' },
55
+ },
56
+ },
57
+ required: ['productIds'],
58
+ },
59
+ },
60
+ ];
61
+ /**
62
+ * Handle product tool calls
63
+ */
64
+ async function handleProductTool(toolName, args, client) {
65
+ logger_js_1.logger.debug(`Handling tool: ${toolName}`, args);
66
+ try {
67
+ switch (toolName) {
68
+ case 'product_update': {
69
+ const products = args.products.map((p) => ({
70
+ id: p.id,
71
+ name: p.name,
72
+ costPerItem: p.price,
73
+ sku: p.sku,
74
+ stockBalance: p.stockBalance,
75
+ description: p.description,
76
+ }));
77
+ const result = await client.products.update(products, {
78
+ dontUpdateFields: args.dontUpdateFields,
79
+ });
80
+ return (0, error_handler_js_1.formatSuccess)(result);
81
+ }
82
+ case 'product_delete': {
83
+ const result = await client.products.delete(args.productIds);
84
+ return (0, error_handler_js_1.formatSuccess)(result);
85
+ }
86
+ default:
87
+ return (0, error_handler_js_1.formatError)(new Error(`Unknown product tool: ${toolName}`));
88
+ }
89
+ }
90
+ catch (error) {
91
+ return (0, error_handler_js_1.formatError)(error);
92
+ }
93
+ }
94
+ //# sourceMappingURL=product.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product.js","sourceRoot":"","sources":["../../src/tools/product.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAgEH,8CA4CC;AAzGD,gEAAuE;AACvE,kDAA4C;AAE5C;;GAEG;AACU,QAAA,YAAY,GAAW;IAClC;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EAAE,4EAA4E;QACzF,WAAW,EAAE;YACX,IAAI,EAAE,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ol/sdk/types.js';
5
+ /**
6
+ * Reference tool definitions
7
+ */
8
+ export declare const referenceTools: Tool[];
9
+ type AnyClient = any;
10
+ /**
11
+ * Handle reference tool calls
12
+ */
13
+ export declare function handleReferenceTool(toolName: string, args: Record<string, unknown>, client: AnyClient): Promise<{
14
+ content: Array<{
15
+ type: "text";
16
+ text: string;
17
+ }>;
18
+ }>;
19
+ export {};
20
+ //# sourceMappingURL=reference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../src/tools/reference.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAI/D;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,IAAI,EAuDhC,CAAC;AAGF,KAAK,SAAS,GAAG,GAAG,CAAC;AAErB;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,SAAS;;;;;GAsClB"}
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ /**
3
+ * Reference Tools for MCP Server
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.referenceTools = void 0;
7
+ exports.handleReferenceTool = handleReferenceTool;
8
+ const error_handler_js_1 = require("../utils/error-handler.js");
9
+ const logger_js_1 = require("../utils/logger.js");
10
+ /**
11
+ * Reference tool definitions
12
+ */
13
+ exports.referenceTools = [
14
+ {
15
+ name: 'reference_get_payment_methods',
16
+ description: 'Get available payment methods from SalesDrive',
17
+ inputSchema: {
18
+ type: 'object',
19
+ properties: {},
20
+ },
21
+ },
22
+ {
23
+ name: 'reference_get_delivery_methods',
24
+ description: 'Get available delivery methods from SalesDrive',
25
+ inputSchema: {
26
+ type: 'object',
27
+ properties: {},
28
+ },
29
+ },
30
+ {
31
+ name: 'reference_get_statuses',
32
+ description: 'Get order statuses from SalesDrive',
33
+ inputSchema: {
34
+ type: 'object',
35
+ properties: {},
36
+ },
37
+ },
38
+ {
39
+ name: 'currency_get',
40
+ description: 'Get current currency exchange rates from SalesDrive',
41
+ inputSchema: {
42
+ type: 'object',
43
+ properties: {},
44
+ },
45
+ },
46
+ {
47
+ name: 'currency_update',
48
+ description: 'Update currency exchange rates in SalesDrive',
49
+ inputSchema: {
50
+ type: 'object',
51
+ properties: {
52
+ currencies: {
53
+ type: 'array',
54
+ description: 'Currency rates to update',
55
+ items: {
56
+ type: 'object',
57
+ properties: {
58
+ code: { type: 'string', description: 'Currency code (e.g., USD, EUR)' },
59
+ rate: { type: 'number', description: 'Exchange rate' },
60
+ },
61
+ required: ['code', 'rate'],
62
+ },
63
+ },
64
+ },
65
+ required: ['currencies'],
66
+ },
67
+ },
68
+ ];
69
+ /**
70
+ * Handle reference tool calls
71
+ */
72
+ async function handleReferenceTool(toolName, args, client) {
73
+ logger_js_1.logger.debug(`Handling tool: ${toolName}`, args);
74
+ try {
75
+ switch (toolName) {
76
+ case 'reference_get_payment_methods': {
77
+ const result = await client.reference.getPaymentMethods();
78
+ return (0, error_handler_js_1.formatSuccess)(result.data);
79
+ }
80
+ case 'reference_get_delivery_methods': {
81
+ const result = await client.reference.getDeliveryMethods();
82
+ return (0, error_handler_js_1.formatSuccess)(result.data);
83
+ }
84
+ case 'reference_get_statuses': {
85
+ const result = await client.reference.getStatuses();
86
+ return (0, error_handler_js_1.formatSuccess)(result.data);
87
+ }
88
+ case 'currency_get': {
89
+ const result = await client.currencies.get();
90
+ return (0, error_handler_js_1.formatSuccess)(result);
91
+ }
92
+ case 'currency_update': {
93
+ const currencies = args.currencies;
94
+ const result = await client.currencies.update({ currencies });
95
+ return (0, error_handler_js_1.formatSuccess)(result);
96
+ }
97
+ default:
98
+ return (0, error_handler_js_1.formatError)(new Error(`Unknown reference tool: ${toolName}`));
99
+ }
100
+ }
101
+ catch (error) {
102
+ return (0, error_handler_js_1.formatError)(error);
103
+ }
104
+ }
105
+ //# sourceMappingURL=reference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference.js","sourceRoot":"","sources":["../../src/tools/reference.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAwEH,kDAyCC;AA9GD,gEAAuE;AACvE,kDAA4C;AAE5C;;GAEG;AACU,QAAA,cAAc,GAAW;IACpC;QACE,IAAI,EAAE,+BAA+B;QACrC,WAAW,EAAE,+CAA+C;QAC5D,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE;SACf;KACF;IACD;QACE,IAAI,EAAE,gCAAgC;QACtC,WAAW,EAAE,gDAAgD;QAC7D,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE;SACf;KACF;IACD;QACE,IAAI,EAAE,wBAAwB;QAC9B,WAAW,EAAE,oCAAoC;QACjD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE;SACf;KACF;IACD;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,qDAAqD;QAClE,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE;SACf;KACF;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,8CAA8C;QAC3D,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,UAAU,EAAE;oBACV,IAAI,EAAE,OAAO;oBACb,WAAW,EAAE,0BAA0B;oBACvC,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,UAAU,EAAE;4BACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,gCAAgC,EAAE;4BACvE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE;yBACvD;wBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;qBAC3B;iBACF;aACF;YACD,QAA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C;YAC/B,CAAC;YAED;gBACE,OAAO,IAAA,8BAAW,EAAC,IAAI,KAAK,CAAC,2BAA2B,QAAQ,EAAE,CAAC,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAA,8BAAW,EAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Sales Invoice Tools for MCP Server (Видаткові накладні)
3
+ */
4
+ import type { Tool } from '@modelcontextprotocol/sdk/types.js';
5
+ /**
6
+ * Sales Invoice tool definitions
7
+ */
8
+ export declare const salesInvoiceTools: Tool[];
9
+ type AnyClient = any;
10
+ /**
11
+ * Handle sales invoice tool calls
12
+ */
13
+ export declare function handleSalesInvoiceTool(toolName: string, args: Record<string, unknown>, client: AnyClient): Promise<{
14
+ content: Array<{
15
+ type: "text";
16
+ text: string;
17
+ }>;
18
+ }>;
19
+ export {};
20
+ //# sourceMappingURL=salesInvoice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"salesInvoice.d.ts","sourceRoot":"","sources":["../../src/tools/salesInvoice.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAI/D;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,IAAI,EAkCnC,CAAC;AAGF,KAAK,SAAS,GAAG,GAAG,CAAC;AAErB;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,SAAS;;;;;GAyBlB"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ /**
3
+ * Sales Invoice Tools for MCP Server (Видаткові накладні)
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.salesInvoiceTools = void 0;
7
+ exports.handleSalesInvoiceTool = handleSalesInvoiceTool;
8
+ const error_handler_js_1 = require("../utils/error-handler.js");
9
+ const logger_js_1 = require("../utils/logger.js");
10
+ /**
11
+ * Sales Invoice tool definitions
12
+ */
13
+ exports.salesInvoiceTools = [
14
+ {
15
+ name: 'sales_invoice_list',
16
+ description: 'List sales invoices (Видаткові накладні) from SalesDrive',
17
+ inputSchema: {
18
+ type: 'object',
19
+ properties: {
20
+ page: {
21
+ type: 'number',
22
+ description: 'Page number (default: 1)',
23
+ },
24
+ limit: {
25
+ type: 'number',
26
+ description: 'Results per page (default: 50, max: 100)',
27
+ },
28
+ orderId: {
29
+ type: 'number',
30
+ description: 'Filter by order ID',
31
+ },
32
+ contactId: {
33
+ type: 'number',
34
+ description: 'Filter by contact ID',
35
+ },
36
+ dateFrom: {
37
+ type: 'string',
38
+ description: 'Filter from date (YYYY-MM-DD)',
39
+ },
40
+ dateTo: {
41
+ type: 'string',
42
+ description: 'Filter to date (YYYY-MM-DD)',
43
+ },
44
+ },
45
+ },
46
+ },
47
+ ];
48
+ /**
49
+ * Handle sales invoice tool calls
50
+ */
51
+ async function handleSalesInvoiceTool(toolName, args, client) {
52
+ logger_js_1.logger.debug(`Handling tool: ${toolName}`, args);
53
+ try {
54
+ switch (toolName) {
55
+ case 'sales_invoice_list': {
56
+ const params = {};
57
+ if (args.page)
58
+ params.page = args.page;
59
+ if (args.limit)
60
+ params.limit = args.limit;
61
+ if (args.orderId)
62
+ params['filter[orderId]'] = args.orderId;
63
+ if (args.contactId)
64
+ params['filter[contactId]'] = args.contactId;
65
+ if (args.dateFrom)
66
+ params['filter[date][from]'] = args.dateFrom;
67
+ if (args.dateTo)
68
+ params['filter[date][to]'] = args.dateTo;
69
+ const result = await client.salesInvoices.list(params);
70
+ return (0, error_handler_js_1.formatSuccess)(result);
71
+ }
72
+ default:
73
+ return (0, error_handler_js_1.formatError)(new Error(`Unknown sales invoice tool: ${toolName}`));
74
+ }
75
+ }
76
+ catch (error) {
77
+ return (0, error_handler_js_1.formatError)(error);
78
+ }
79
+ }
80
+ //# sourceMappingURL=salesInvoice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"salesInvoice.js","sourceRoot":"","sources":["../../src/tools/salesInvoice.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAmDH,wDA4BC;AA5ED,gEAAuE;AACvE,kDAA4C;AAE5C;;GAEG;AACU,QAAA,iBAAiB,GAAW;IACvC;QACE,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EAAE,0DAA0D;QACvE,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,0BAA0B;iBACxC;gBACD,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,0CAA0C;iBACxD;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,oBAAoB;iBAClC;gBACD,SAAS,EAAE;oBACT,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,sBAAsB;iBACpC;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,+BAA+B;iBAC7C;gBACD,MAAM,EAAE;oBACN,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,6BAA6B;iBAC3C;aACF;SACF;KACF;CACF,CAAC;AAKF;;GAEG;AACI,KAAK,UAAU,sBAAsB,CAC1C,QAAgB,EAChB,IAA6B,EAC7B,MAAiB;IAEjB,kBAAM,CAAC,KAAK,CAAC,kBAAkB,QAAQ,EAAE,EAAE,IAAI,CAAC,CAAC;IAEjD,IAAI,CAAC;QACH,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,oBAAoB,CAAC,CAAC,CAAC;gBAC1B,MAAM,MAAM,GAA4B,EAAE,CAAC;gBAC3C,IAAI,IAAI,CAAC,IAAI;oBAAE,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;gBACvC,IAAI,IAAI,CAAC,KAAK;oBAAE,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;gBAC1C,IAAI,IAAI,CAAC,OAAO;oBAAE,MAAM,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;gBAC3D,IAAI,IAAI,CAAC,SAAS;oBAAE,MAAM,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;gBACjE,IAAI,IAAI,CAAC,QAAQ;oBAAE,MAAM,CAAC,oBAAoB,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;gBAChE,IAAI,IAAI,CAAC,MAAM;oBAAE,MAAM,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;gBAE1D,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACvD,OAAO,IAAA,gCAAa,EAAC,MAAM,CAAC,CAAC;YAC/B,CAAC;YAED;gBACE,OAAO,IAAA,8BAAW,EAAC,IAAI,KAAK,CAAC,+BAA+B,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAA,8BAAW,EAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Error Handler Utility
3
+ */
4
+ /**
5
+ * Format error for MCP response
6
+ */
7
+ export declare function formatError(error: unknown): {
8
+ isError: true;
9
+ content: Array<{
10
+ type: 'text';
11
+ text: string;
12
+ }>;
13
+ };
14
+ /**
15
+ * Format success response for MCP
16
+ */
17
+ export declare function formatSuccess(data: unknown): {
18
+ content: Array<{
19
+ type: 'text';
20
+ text: string;
21
+ }>;
22
+ };
23
+ //# sourceMappingURL=error-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG;IAC3C,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChD,CA0BA;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG;IAC5C,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChD,CASA"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /**
3
+ * Error Handler Utility
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.formatError = formatError;
7
+ exports.formatSuccess = formatSuccess;
8
+ const logger_js_1 = require("./logger.js");
9
+ /**
10
+ * Format error for MCP response
11
+ */
12
+ function formatError(error) {
13
+ let message;
14
+ if (error instanceof Error) {
15
+ message = error.message;
16
+ // Log the full error for debugging
17
+ logger_js_1.logger.error('Tool error', {
18
+ name: error.name,
19
+ message: error.message,
20
+ stack: error.stack,
21
+ });
22
+ }
23
+ else {
24
+ message = String(error);
25
+ logger_js_1.logger.error('Unknown error', { error });
26
+ }
27
+ return {
28
+ isError: true,
29
+ content: [
30
+ {
31
+ type: 'text',
32
+ text: `Error: ${message}`,
33
+ },
34
+ ],
35
+ };
36
+ }
37
+ /**
38
+ * Format success response for MCP
39
+ */
40
+ function formatSuccess(data) {
41
+ return {
42
+ content: [
43
+ {
44
+ type: 'text',
45
+ text: JSON.stringify(data, null, 2),
46
+ },
47
+ ],
48
+ };
49
+ }
50
+ //# sourceMappingURL=error-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/utils/error-handler.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAOH,kCA6BC;AAKD,sCAWC;AAlDD,2CAAqC;AAErC;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAc;IAIxC,IAAI,OAAe,CAAC;IAEpB,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAExB,mCAAmC;QACnC,kBAAM,CAAC,KAAK,CAAC,YAAY,EAAE;YACzB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QACxB,kBAAM,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,UAAU,OAAO,EAAE;aAC1B;SACF;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,IAAa;IAGzC,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;aACpC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Logger utility
3
+ */
4
+ export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
5
+ /**
6
+ * Set the log level
7
+ */
8
+ export declare function setLogLevel(level: LogLevel): void;
9
+ export declare const logger: {
10
+ debug: (message: string, data?: unknown) => void;
11
+ info: (message: string, data?: unknown) => void;
12
+ warn: (message: string, data?: unknown) => void;
13
+ error: (message: string, data?: unknown) => void;
14
+ };
15
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAW3D;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAEjD;AAoBD,eAAO,MAAM,MAAM;qBACA,MAAM,SAAS,OAAO;oBACvB,MAAM,SAAS,OAAO;oBACtB,MAAM,SAAS,OAAO;qBACrB,MAAM,SAAS,OAAO;CACxC,CAAC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /**
3
+ * Logger utility
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.logger = void 0;
7
+ exports.setLogLevel = setLogLevel;
8
+ const LOG_LEVELS = {
9
+ debug: 0,
10
+ info: 1,
11
+ warn: 2,
12
+ error: 3,
13
+ };
14
+ let currentLevel = 'info';
15
+ /**
16
+ * Set the log level
17
+ */
18
+ function setLogLevel(level) {
19
+ currentLevel = level;
20
+ }
21
+ /**
22
+ * Log a message at the specified level
23
+ */
24
+ function log(level, message, data) {
25
+ if (LOG_LEVELS[level] >= LOG_LEVELS[currentLevel]) {
26
+ const timestamp = new Date().toISOString();
27
+ const logMessage = `[${timestamp}] [${level.toUpperCase()}] ${message}`;
28
+ if (data !== undefined) {
29
+ // eslint-disable-next-line no-console
30
+ console.error(logMessage, JSON.stringify(data, null, 2));
31
+ }
32
+ else {
33
+ // eslint-disable-next-line no-console
34
+ console.error(logMessage);
35
+ }
36
+ }
37
+ }
38
+ exports.logger = {
39
+ debug: (message, data) => log('debug', message, data),
40
+ info: (message, data) => log('info', message, data),
41
+ warn: (message, data) => log('warn', message, data),
42
+ error: (message, data) => log('error', message, data),
43
+ };
44
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","s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AE,OAAO,EAAE,IAAI,CAAC;IACrE,KAAK,EAAE,CAAC,OAAe,EAAE,IAAc,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;CACxE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@dannychirkov/salesdrive-mcp-server",
3
+ "version": "0.1.0",
4
+ "description": "MCP server for SalesDrive CRM API - enables AI assistants to manage orders, products, and payments",
5
+ "main": "dist/server.js",
6
+ "types": "dist/server.d.ts",
7
+ "bin": {
8
+ "salesdrive-mcp": "./dist/cli/index.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "license": "Apache-2.0",
14
+ "author": "Danny Chirkov",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/dannychirkov/salesdrive-api",
18
+ "directory": "packages/salesdrive-mcp-server"
19
+ },
20
+ "homepage": "https://github.com/dannychirkov/salesdrive-api#readme",
21
+ "bugs": {
22
+ "url": "https://github.com/dannychirkov/salesdrive-api/issues"
23
+ },
24
+ "keywords": [
25
+ "salesdrive",
26
+ "mcp",
27
+ "model-context-protocol",
28
+ "ai",
29
+ "claude",
30
+ "crm"
31
+ ],
32
+ "scripts": {
33
+ "build": "tsc",
34
+ "start": "node dist/cli/index.js",
35
+ "dev": "ts-node src/cli/index.ts",
36
+ "test": "jest",
37
+ "type-check": "tsc --noEmit",
38
+ "clean": "rimraf dist"
39
+ },
40
+ "dependencies": {
41
+ "@modelcontextprotocol/sdk": "^1.0.0",
42
+ "@dannychirkov/salesdrive-api-client": "*",
43
+ "@dannychirkov/salesdrive-transport-fetch": "*"
44
+ },
45
+ "devDependencies": {
46
+ "typescript": "^5.3.0",
47
+ "@types/node": "^20.10.0",
48
+ "jest": "^29.7.0",
49
+ "@types/jest": "^29.5.11",
50
+ "ts-jest": "^29.1.1",
51
+ "ts-node": "^10.9.2",
52
+ "rimraf": "^5.0.5"
53
+ },
54
+ "engines": {
55
+ "node": ">=18.0.0"
56
+ }
57
+ }