@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
package/README.md ADDED
@@ -0,0 +1,223 @@
1
+ # @dannychirkov/salesdrive-mcp-server
2
+
3
+ MCP (Model Context Protocol) server for SalesDrive CRM. Enables AI assistants like Claude to manage orders, products, and payments in SalesDrive.
4
+
5
+ ## Installation
6
+
7
+ ### With npx (recommended)
8
+
9
+ No installation needed! Just configure your AI assistant:
10
+
11
+ ```json
12
+ {
13
+ "mcpServers": {
14
+ "salesdrive": {
15
+ "command": "npx",
16
+ "args": ["-y", "@dannychirkov/salesdrive-mcp-server"],
17
+ "env": {
18
+ "SALESDRIVE_API_KEY": "your-api-key",
19
+ "SALESDRIVE_BASE_URL": "https://your-account.salesdrive.me"
20
+ }
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ ### Global installation
27
+
28
+ ```bash
29
+ npm install -g @dannychirkov/salesdrive-mcp-server
30
+ ```
31
+
32
+ Then configure:
33
+
34
+ ```json
35
+ {
36
+ "mcpServers": {
37
+ "salesdrive": {
38
+ "command": "salesdrive-mcp",
39
+ "env": {
40
+ "SALESDRIVE_API_KEY": "your-api-key",
41
+ "SALESDRIVE_BASE_URL": "https://your-account.salesdrive.me"
42
+ }
43
+ }
44
+ }
45
+ }
46
+ ```
47
+
48
+ ## Configuration
49
+
50
+ | Environment Variable | Description | Required |
51
+ | ---------------------- | --------------------------------------------------- | ------------------- |
52
+ | `SALESDRIVE_API_KEY` | Your SalesDrive API key | Yes |
53
+ | `SALESDRIVE_BASE_URL` | Your account URL (e.g., https://demo.salesdrive.me) | Yes |
54
+ | `SALESDRIVE_READ_ONLY` | Set to `true` to disable write operations | No (default: false) |
55
+ | `LOG_LEVEL` | Logging level (debug, info, warn, error) | No (default: info) |
56
+
57
+ ### Read-Only Mode
58
+
59
+ For safety, you can run the server in read-only mode. This disables all write operations:
60
+
61
+ ```json
62
+ {
63
+ "mcpServers": {
64
+ "salesdrive": {
65
+ "command": "npx",
66
+ "args": ["-y", "@dannychirkov/salesdrive-mcp-server"],
67
+ "env": {
68
+ "SALESDRIVE_API_KEY": "your-api-key",
69
+ "SALESDRIVE_BASE_URL": "https://your-account.salesdrive.me",
70
+ "SALESDRIVE_READ_ONLY": "true"
71
+ }
72
+ }
73
+ }
74
+ }
75
+ ```
76
+
77
+ In read-only mode, the following tools are disabled:
78
+
79
+ - `order_create`, `order_update`
80
+ - `product_update`, `product_delete`
81
+ - `payment_add`
82
+ - `currency_update`
83
+ - `category_update`, `category_delete`
84
+
85
+ ### Getting Your API Key
86
+
87
+ 1. Log in to your SalesDrive account
88
+ 2. Go to **Settings** → **General Settings and Integrations** → **Other Services** → **API**
89
+ 3. Generate or copy your API key
90
+
91
+ ## Available Tools
92
+
93
+ ### Order Tools
94
+
95
+ | Tool | Description |
96
+ | -------------- | ------------------------ |
97
+ | `order_list` | List orders with filters |
98
+ | `order_create` | Create a new order |
99
+ | `order_update` | Update an existing order |
100
+
101
+ ### Product Tools
102
+
103
+ | Tool | Description |
104
+ | ---------------- | ------------------------------ |
105
+ | `product_update` | Add or update products (batch) |
106
+ | `product_delete` | Delete products by ID |
107
+
108
+ ### Category Tools
109
+
110
+ | Tool | Description |
111
+ | ----------------- | ------------------------ |
112
+ | `category_update` | Add or update categories |
113
+ | `category_delete` | Delete categories by ID |
114
+
115
+ ### Payment Tools
116
+
117
+ | Tool | Description |
118
+ | -------------- | ------------------ |
119
+ | `payment_add` | Register a payment |
120
+ | `payment_list` | List payments |
121
+
122
+ ### Reference Tools
123
+
124
+ | Tool | Description |
125
+ | -------------------------------- | -------------------- |
126
+ | `reference_get_payment_methods` | Get payment methods |
127
+ | `reference_get_delivery_methods` | Get delivery methods |
128
+ | `reference_get_statuses` | Get order statuses |
129
+
130
+ ### Currency Tools
131
+
132
+ | Tool | Description |
133
+ | ----------------- | --------------------- |
134
+ | `currency_get` | Get currency rates |
135
+ | `currency_update` | Update currency rates |
136
+
137
+ ### Document Tools
138
+
139
+ | Tool | Description |
140
+ | -------------------- | --------------------- |
141
+ | `invoice_list` | List invoices |
142
+ | `sales_invoice_list` | List sales invoices |
143
+ | `cash_order_list` | List cash orders |
144
+ | `contract_list` | List contracts |
145
+ | `check_list` | List fiscal receipts |
146
+ | `act_list` | List acts |
147
+ | `arrival_list` | List product arrivals |
148
+
149
+ ## Example Prompts
150
+
151
+ Once configured, you can ask your AI assistant:
152
+
153
+ - "Show me the last 10 orders from SalesDrive"
154
+ - "Create a new order for customer with phone 0501234567"
155
+ - "Update order #123 status to completed"
156
+ - "What payment methods are available?"
157
+ - "Add a payment of 500 UAH to order #456"
158
+ - "Update the USD exchange rate to 42 UAH"
159
+ - "Show me all invoices for this month"
160
+ - "List all contracts"
161
+ - "Show product arrivals from last week"
162
+
163
+ ## Claude Desktop Setup
164
+
165
+ ### macOS
166
+
167
+ Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:
168
+
169
+ ```json
170
+ {
171
+ "mcpServers": {
172
+ "salesdrive": {
173
+ "command": "npx",
174
+ "args": ["-y", "@dannychirkov/salesdrive-mcp-server"],
175
+ "env": {
176
+ "SALESDRIVE_API_KEY": "your-api-key",
177
+ "SALESDRIVE_BASE_URL": "https://your-account.salesdrive.me"
178
+ }
179
+ }
180
+ }
181
+ }
182
+ ```
183
+
184
+ ### Windows
185
+
186
+ Edit `%APPDATA%\Claude\claude_desktop_config.json`:
187
+
188
+ ```json
189
+ {
190
+ "mcpServers": {
191
+ "salesdrive": {
192
+ "command": "npx",
193
+ "args": ["-y", "@dannychirkov/salesdrive-mcp-server"],
194
+ "env": {
195
+ "SALESDRIVE_API_KEY": "your-api-key",
196
+ "SALESDRIVE_BASE_URL": "https://your-account.salesdrive.me"
197
+ }
198
+ }
199
+ }
200
+ }
201
+ ```
202
+
203
+ ## Troubleshooting
204
+
205
+ ### "API key is required"
206
+
207
+ Make sure `SALESDRIVE_API_KEY` is set in the environment configuration.
208
+
209
+ ### "Base URL is required"
210
+
211
+ Make sure `SALESDRIVE_BASE_URL` is set. It should be your account's URL, like `https://mycompany.salesdrive.me`.
212
+
213
+ ### Rate Limiting
214
+
215
+ SalesDrive has rate limits (10/min, 100/hr, 1000/day for list operations). If you hit limits, wait and try again.
216
+
217
+ ### Debug Mode
218
+
219
+ Set `LOG_LEVEL=debug` to see detailed logs in stderr.
220
+
221
+ ## License
222
+
223
+ [Apache License 2.0](../../LICENSE)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * SalesDrive MCP Server CLI Entry Point
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AACA;;GAEG"}
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**
4
+ * SalesDrive MCP Server CLI Entry Point
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const server_js_1 = require("../server.js");
8
+ (0, server_js_1.runServer)().catch((error) => {
9
+ console.error('Fatal error:', error);
10
+ process.exit(1);
11
+ });
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;AACA;;GAEG;;AAEH,4CAAyC;AAEzC,IAAA,qBAAS,GAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC1B,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * MCP Server Configuration
3
+ */
4
+ /**
5
+ * Server configuration interface
6
+ */
7
+ export interface ServerConfig {
8
+ /**
9
+ * SalesDrive API key
10
+ */
11
+ apiKey: string;
12
+ /**
13
+ * Base URL for the API (e.g., https://demo.salesdrive.me)
14
+ */
15
+ baseUrl: string;
16
+ /**
17
+ * Log level
18
+ */
19
+ logLevel: 'debug' | 'info' | 'warn' | 'error';
20
+ /**
21
+ * Read-only mode - disables all write operations
22
+ * When true, only list/get tools are available
23
+ */
24
+ readOnly: boolean;
25
+ }
26
+ /**
27
+ * Load configuration from environment variables
28
+ */
29
+ export declare function loadConfig(): ServerConfig;
30
+ /**
31
+ * Validate configuration
32
+ */
33
+ export declare function validateConfig(config: ServerConfig): void;
34
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAE9C;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,YAAY,CAqBzC;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAczD"}
package/dist/config.js ADDED
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ /**
3
+ * MCP Server Configuration
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.loadConfig = loadConfig;
7
+ exports.validateConfig = validateConfig;
8
+ /**
9
+ * Load configuration from environment variables
10
+ */
11
+ function loadConfig() {
12
+ const apiKey = process.env.SALESDRIVE_API_KEY;
13
+ const baseUrl = process.env.SALESDRIVE_BASE_URL;
14
+ const logLevel = (process.env.LOG_LEVEL || 'info');
15
+ const readOnly = process.env.SALESDRIVE_READ_ONLY === 'true' || process.env.SALESDRIVE_READ_ONLY === '1';
16
+ if (!apiKey) {
17
+ throw new Error('SALESDRIVE_API_KEY environment variable is required');
18
+ }
19
+ if (!baseUrl) {
20
+ throw new Error('SALESDRIVE_BASE_URL environment variable is required');
21
+ }
22
+ return {
23
+ apiKey,
24
+ baseUrl,
25
+ logLevel,
26
+ readOnly,
27
+ };
28
+ }
29
+ /**
30
+ * Validate configuration
31
+ */
32
+ function validateConfig(config) {
33
+ if (!config.apiKey || config.apiKey.trim() === '') {
34
+ throw new Error('API key cannot be empty');
35
+ }
36
+ if (!config.baseUrl || config.baseUrl.trim() === '') {
37
+ throw new Error('Base URL cannot be empty');
38
+ }
39
+ try {
40
+ new URL(config.baseUrl);
41
+ }
42
+ catch {
43
+ throw new Error(`Invalid base URL: ${config.baseUrl}`);
44
+ }
45
+ }
46
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;GAEG;;AA+BH,gCAqBC;AAKD,wCAcC;AA3CD;;GAEG;AACH,SAAgB,UAAU;IACxB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IAC9C,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IAChD,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,MAAM,CAA6B,CAAC;IAC/E,MAAM,QAAQ,GACZ,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,KAAK,GAAG,CAAC;IAE1F,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO;QACL,MAAM;QACN,OAAO;QACP,QAAQ;QACR,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,MAAoB;IACjD,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,CAAC;QACH,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,qBAAqB,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IACzD,CAAC;AACH,CAAC"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * SalesDrive MCP Server
3
+ */
4
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
5
+ import { type ServerConfig } from './config.js';
6
+ /**
7
+ * Create the SalesDrive MCP Server
8
+ */
9
+ export declare function createServer(config: ServerConfig): Server<{
10
+ method: string;
11
+ params?: {
12
+ [x: string]: unknown;
13
+ _meta?: {
14
+ [x: string]: unknown;
15
+ progressToken?: string | number | undefined;
16
+ "io.modelcontextprotocol/related-task"?: {
17
+ taskId: string;
18
+ } | undefined;
19
+ } | undefined;
20
+ } | undefined;
21
+ }, {
22
+ method: string;
23
+ params?: {
24
+ [x: string]: unknown;
25
+ _meta?: {
26
+ [x: string]: unknown;
27
+ progressToken?: string | number | undefined;
28
+ "io.modelcontextprotocol/related-task"?: {
29
+ taskId: string;
30
+ } | undefined;
31
+ } | undefined;
32
+ } | undefined;
33
+ }, {
34
+ [x: string]: unknown;
35
+ _meta?: {
36
+ [x: string]: unknown;
37
+ progressToken?: string | number | undefined;
38
+ "io.modelcontextprotocol/related-task"?: {
39
+ taskId: string;
40
+ } | undefined;
41
+ } | undefined;
42
+ }>;
43
+ /**
44
+ * Run the server with stdio transport
45
+ */
46
+ export declare function runServer(): Promise<void>;
47
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAqBnE,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AA0E5E;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6IhD;AAED;;GAEG;AACH,wBAAsB,SAAS,kBAmB9B"}
package/dist/server.js ADDED
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ /**
3
+ * SalesDrive MCP Server
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createServer = createServer;
7
+ exports.runServer = runServer;
8
+ const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
9
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
10
+ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
11
+ const salesdrive_api_client_1 = require("@dannychirkov/salesdrive-api-client");
12
+ const salesdrive_transport_fetch_1 = require("@dannychirkov/salesdrive-transport-fetch");
13
+ const config_js_1 = require("./config.js");
14
+ const logger_js_1 = require("./utils/logger.js");
15
+ const index_js_2 = require("./tools/index.js");
16
+ /**
17
+ * Write tool names that should be filtered out in read-only mode
18
+ */
19
+ const WRITE_TOOLS = new Set([
20
+ 'order_create',
21
+ 'order_update',
22
+ 'product_update',
23
+ 'product_delete',
24
+ 'payment_add',
25
+ 'currency_update',
26
+ 'category_update',
27
+ 'category_delete',
28
+ ]);
29
+ /**
30
+ * All available tools
31
+ */
32
+ const ALL_TOOLS = [
33
+ ...index_js_2.orderTools,
34
+ ...index_js_2.productTools,
35
+ ...index_js_2.paymentTools,
36
+ ...index_js_2.referenceTools,
37
+ ...index_js_2.currencyTools,
38
+ ...index_js_2.categoryTools,
39
+ ...index_js_2.invoiceTools,
40
+ ...index_js_2.salesInvoiceTools,
41
+ ...index_js_2.cashOrderTools,
42
+ ...index_js_2.contractTools,
43
+ ...index_js_2.checkTools,
44
+ ...index_js_2.actTools,
45
+ ...index_js_2.arrivalTools,
46
+ ];
47
+ /**
48
+ * Get tools filtered by read-only mode
49
+ */
50
+ function getAvailableTools(readOnly) {
51
+ if (!readOnly) {
52
+ return ALL_TOOLS;
53
+ }
54
+ return ALL_TOOLS.filter((tool) => !WRITE_TOOLS.has(tool.name));
55
+ }
56
+ /**
57
+ * Create the SalesDrive MCP Server
58
+ */
59
+ function createServer(config) {
60
+ // Validate configuration
61
+ (0, config_js_1.validateConfig)(config);
62
+ // Set log level
63
+ (0, logger_js_1.setLogLevel)(config.logLevel);
64
+ // Get available tools based on read-only mode
65
+ const availableTools = getAvailableTools(config.readOnly);
66
+ if (config.readOnly) {
67
+ logger_js_1.logger.info('Running in READ-ONLY mode - write operations disabled');
68
+ }
69
+ // Create transport and client
70
+ const transport = (0, salesdrive_transport_fetch_1.createFetchTransport)({
71
+ apiKey: config.apiKey,
72
+ baseUrl: config.baseUrl,
73
+ });
74
+ const client = (0, salesdrive_api_client_1.createClient)({
75
+ transport,
76
+ apiKey: config.apiKey,
77
+ baseUrl: config.baseUrl,
78
+ })
79
+ .extend(salesdrive_api_client_1.orderService)
80
+ .extend(salesdrive_api_client_1.productService)
81
+ .extend(salesdrive_api_client_1.paymentService)
82
+ .extend(salesdrive_api_client_1.referenceService)
83
+ .extend(salesdrive_api_client_1.currencyService)
84
+ .extend(salesdrive_api_client_1.categoryService)
85
+ .extend(salesdrive_api_client_1.invoiceService)
86
+ .extend(salesdrive_api_client_1.salesInvoiceService)
87
+ .extend(salesdrive_api_client_1.cashOrderService)
88
+ .extend(salesdrive_api_client_1.contractService)
89
+ .extend(salesdrive_api_client_1.checkService)
90
+ .extend(salesdrive_api_client_1.actService)
91
+ .extend(salesdrive_api_client_1.arrivalService);
92
+ // Create MCP server
93
+ const server = new index_js_1.Server({
94
+ name: 'salesdrive-mcp-server',
95
+ version: '0.1.0',
96
+ }, {
97
+ capabilities: {
98
+ tools: {},
99
+ },
100
+ });
101
+ // Handle list tools request
102
+ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
103
+ logger_js_1.logger.debug('Listing tools');
104
+ return { tools: availableTools };
105
+ });
106
+ // Handle tool calls
107
+ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
108
+ const { name, arguments: args = {} } = request.params;
109
+ logger_js_1.logger.info(`Tool called: ${name}`, args);
110
+ // Block write tools in read-only mode
111
+ if (config.readOnly && WRITE_TOOLS.has(name)) {
112
+ return {
113
+ isError: true,
114
+ content: [
115
+ {
116
+ type: 'text',
117
+ text: `Tool "${name}" is not available in read-only mode. Set SALESDRIVE_READ_ONLY=false to enable write operations.`,
118
+ },
119
+ ],
120
+ };
121
+ }
122
+ // Route to appropriate handler
123
+ if (name.startsWith('order_')) {
124
+ return (0, index_js_2.handleOrderTool)(name, args, client);
125
+ }
126
+ if (name.startsWith('product_')) {
127
+ return (0, index_js_2.handleProductTool)(name, args, client);
128
+ }
129
+ if (name.startsWith('payment_')) {
130
+ return (0, index_js_2.handlePaymentTool)(name, args, client);
131
+ }
132
+ if (name.startsWith('reference_')) {
133
+ return (0, index_js_2.handleReferenceTool)(name, args, client);
134
+ }
135
+ if (name.startsWith('currency_')) {
136
+ return (0, index_js_2.handleCurrencyTool)(name, args, client);
137
+ }
138
+ if (name.startsWith('category_')) {
139
+ return (0, index_js_2.handleCategoryTool)(name, args, client);
140
+ }
141
+ if (name.startsWith('invoice_')) {
142
+ return (0, index_js_2.handleInvoiceTool)(name, args, client);
143
+ }
144
+ if (name.startsWith('sales_invoice_')) {
145
+ return (0, index_js_2.handleSalesInvoiceTool)(name, args, client);
146
+ }
147
+ if (name.startsWith('cash_order_')) {
148
+ return (0, index_js_2.handleCashOrderTool)(name, args, client);
149
+ }
150
+ if (name.startsWith('contract_')) {
151
+ return (0, index_js_2.handleContractTool)(name, args, client);
152
+ }
153
+ if (name.startsWith('check_')) {
154
+ return (0, index_js_2.handleCheckTool)(name, args, client);
155
+ }
156
+ if (name.startsWith('act_')) {
157
+ return (0, index_js_2.handleActTool)(name, args, client);
158
+ }
159
+ if (name.startsWith('arrival_')) {
160
+ return (0, index_js_2.handleArrivalTool)(name, args, client);
161
+ }
162
+ return {
163
+ isError: true,
164
+ content: [
165
+ {
166
+ type: 'text',
167
+ text: `Unknown tool: ${name}`,
168
+ },
169
+ ],
170
+ };
171
+ });
172
+ return server;
173
+ }
174
+ /**
175
+ * Run the server with stdio transport
176
+ */
177
+ async function runServer() {
178
+ try {
179
+ const config = (0, config_js_1.loadConfig)();
180
+ const server = createServer(config);
181
+ const transport = new stdio_js_1.StdioServerTransport();
182
+ logger_js_1.logger.info('Starting SalesDrive MCP Server...');
183
+ logger_js_1.logger.info(`Base URL: ${config.baseUrl}`);
184
+ if (config.readOnly) {
185
+ logger_js_1.logger.info('Mode: READ-ONLY');
186
+ }
187
+ await server.connect(transport);
188
+ logger_js_1.logger.info('Server connected and ready');
189
+ }
190
+ catch (error) {
191
+ logger_js_1.logger.error('Failed to start server', error);
192
+ process.exit(1);
193
+ }
194
+ }
195
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAoGH,oCA6IC;AAKD,8BAmBC;AAvQD,wEAAmE;AACnE,wEAAiF;AACjF,iEAAmG;AAEnG,+EAe6C;AAC7C,yFAAgF;AAChF,2CAA4E;AAC5E,iDAAwD;AACxD,+CA2B0B;AAE1B;;GAEG;AACH,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,cAAc;IACd,cAAc;IACd,gBAAgB;IAChB,gBAAgB;IAChB,aAAa;IACb,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;CAClB,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,SAAS,GAAW;IACxB,GAAG,qBAAU;IACb,GAAG,uBAAY;IACf,GAAG,uBAAY;IACf,GAAG,yBAAc;IACjB,GAAG,wBAAa;IAChB,GAAG,w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B,kBAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACjC,CAAC;QAED,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAEhC,kBAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,kBAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Act Tools for MCP Server (Акти)
3
+ */
4
+ import type { Tool } from '@modelcontextprotocol/sdk/types.js';
5
+ /**
6
+ * Act tool definitions
7
+ */
8
+ export declare const actTools: Tool[];
9
+ type AnyClient = any;
10
+ /**
11
+ * Handle act tool calls
12
+ */
13
+ export declare function handleActTool(toolName: string, args: Record<string, unknown>, client: AnyClient): Promise<{
14
+ content: Array<{
15
+ type: "text";
16
+ text: string;
17
+ }>;
18
+ }>;
19
+ export {};
20
+ //# sourceMappingURL=act.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"act.d.ts","sourceRoot":"","sources":["../../src/tools/act.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAI/D;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,IAAI,EAkC1B,CAAC;AAGF,KAAK,SAAS,GAAG,GAAG,CAAC;AAErB;;GAEG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,MAAM,EAAE,SAAS;;;;;GAyBlB"}