@carbonvoice/cv-mcp-server 2.7.0 → 2.8.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/env.js +152 -2
- package/dist/config/env.js.map +1 -1
- package/dist/cv-api.js +15 -0
- package/dist/cv-api.js.map +1 -1
- package/dist/interfaces/index.js +1 -0
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/user-info.interface.js +3 -0
- package/dist/interfaces/user-info.interface.js.map +1 -0
- package/dist/server.js +582 -554
- package/dist/server.js.map +1 -1
- package/dist/transports/http/diagnostics/transport-send-diagnostics.js +115 -0
- package/dist/transports/http/diagnostics/transport-send-diagnostics.js.map +1 -0
- package/dist/transports/http/middleware/add-request-id.middlware.js +2 -2
- package/dist/transports/http/middleware/add-request-id.middlware.js.map +1 -1
- package/dist/transports/http/middleware/index.js +1 -0
- package/dist/transports/http/middleware/index.js.map +1 -1
- package/dist/transports/http/middleware/log-request.middlware.js +62 -11
- package/dist/transports/http/middleware/log-request.middlware.js.map +1 -1
- package/dist/transports/http/middleware/require-bearer-auth-with-absolute-metadata.middleware.js +72 -0
- package/dist/transports/http/middleware/require-bearer-auth-with-absolute-metadata.middleware.js.map +1 -0
- package/dist/transports/http/session/index.js +4 -1
- package/dist/transports/http/session/index.js.map +1 -1
- package/dist/transports/http/session/session.config.js +10 -5
- package/dist/transports/http/session/session.config.js.map +1 -1
- package/dist/transports/http/session/session.logger.js +22 -0
- package/dist/transports/http/session/session.logger.js.map +1 -1
- package/dist/transports/http/session/session.service.js +55 -22
- package/dist/transports/http/session/session.service.js.map +1 -1
- package/dist/transports/http/session/session.types.js.map +1 -1
- package/dist/transports/http/session/tool-call-queue.service.js +73 -0
- package/dist/transports/http/session/tool-call-queue.service.js.map +1 -0
- package/dist/transports/http/streamable-stateless.js +288 -0
- package/dist/transports/http/streamable-stateless.js.map +1 -0
- package/dist/transports/http/streamable.js +387 -37
- package/dist/transports/http/streamable.js.map +1 -1
- package/dist/transports/http/utils/request-context.js +3 -2
- package/dist/transports/http/utils/request-context.js.map +1 -1
- package/dist/utils/axios-instance.js +12 -0
- package/dist/utils/axios-instance.js.map +1 -1
- package/dist/utils/format-bytes-human.js +18 -0
- package/dist/utils/format-bytes-human.js.map +1 -0
- package/dist/utils/format-to-mcp-tool-response.js +46 -10
- package/dist/utils/format-to-mcp-tool-response.js.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/logger.js +6 -19
- package/dist/utils/logger.js.map +1 -1
- package/package.json +13 -5
package/dist/server.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMcpServer = createMcpServer;
|
|
3
4
|
const zod_1 = require("zod");
|
|
4
5
|
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
5
6
|
const auth_1 = require("./auth");
|
|
@@ -9,561 +10,588 @@ const generated_1 = require("./generated");
|
|
|
9
10
|
const CarbonVoiceSimplifiedAPI_zod_1 = require("./generated/carbon-voice-api/CarbonVoiceSimplifiedAPI.zod");
|
|
10
11
|
const schemas_1 = require("./schemas");
|
|
11
12
|
const utils_1 = require("./utils");
|
|
12
|
-
// Create server instance
|
|
13
|
-
const server = new mcp_js_1.McpServer({
|
|
14
|
-
name: constants_1.SERVICE_NAME,
|
|
15
|
-
version: constants_1.SERVICE_VERSION,
|
|
16
|
-
capabilities: {
|
|
17
|
-
resources: {},
|
|
18
|
-
tools: {},
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
13
|
const simplifiedApi = (0, generated_1.getCarbonVoiceSimplifiedAPI)();
|
|
22
14
|
const cvApi = (0, cv_api_1.getCarbonVoiceAPI)();
|
|
23
|
-
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
server
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
'
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
});
|
|
190
|
-
server.registerTool('
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}, async (args, { authInfo }) => {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
});
|
|
208
|
-
server.registerTool('
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
'
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}, async (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
//
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
//
|
|
322
|
-
//
|
|
323
|
-
//
|
|
324
|
-
//
|
|
325
|
-
//
|
|
326
|
-
//
|
|
327
|
-
//
|
|
328
|
-
//
|
|
329
|
-
//
|
|
330
|
-
//
|
|
331
|
-
//
|
|
332
|
-
//
|
|
333
|
-
//
|
|
334
|
-
//
|
|
335
|
-
//
|
|
336
|
-
//
|
|
337
|
-
//
|
|
338
|
-
//
|
|
339
|
-
//
|
|
340
|
-
//
|
|
341
|
-
//
|
|
342
|
-
// return formatToMCPToolResponse(
|
|
343
|
-
//
|
|
344
|
-
// );
|
|
345
|
-
//
|
|
346
|
-
//
|
|
347
|
-
//
|
|
348
|
-
//
|
|
349
|
-
//
|
|
350
|
-
//
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
catch (error) {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
},
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
},
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
server.registerTool('
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
},
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
'
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
},
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
server.registerTool('
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
},
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
'
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
},
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
}
|
|
15
|
+
/**
|
|
16
|
+
* Registers all Carbon Voice tools on an MCP server instance.
|
|
17
|
+
* Streamable HTTP stateless mode must use a fresh McpServer per request when
|
|
18
|
+
* handling concurrent clients: the SDK binds a single transport on the protocol
|
|
19
|
+
* object, so sharing one server across parallel `connect()` calls mis-routes
|
|
20
|
+
* JSON-RPC responses and surfaces as client timeouts (-32001) under load.
|
|
21
|
+
*/
|
|
22
|
+
function registerCarbonVoiceTools(server) {
|
|
23
|
+
/**********************
|
|
24
|
+
* Tools
|
|
25
|
+
*********************/
|
|
26
|
+
// Messages
|
|
27
|
+
server.registerTool('list_messages', {
|
|
28
|
+
description: 'List Messages. By default returns latest 20 messages. The maximum allowed range between dates is 183 days (6 months). ' +
|
|
29
|
+
'All presigned URLs returned by this tool are ready to use. ' +
|
|
30
|
+
'Do not parse, modify, or re-encode them—always present or use the URLs exactly as received.' +
|
|
31
|
+
'If you want to get messages from a specific date range, you can use the "start_date" and "end_date" parameters. ' +
|
|
32
|
+
'If you want to get messages from a specific date, you can use the "date" parameter. ' +
|
|
33
|
+
'If you want to get messages from a specific user, you can use the "user_ids" parameter. ' +
|
|
34
|
+
'If you want to get messages from a specific conversation, you can use the "conversation_id" parameter. ' +
|
|
35
|
+
'If you want to get messages from a specific folder, you can use the "folder_id" parameter. ' +
|
|
36
|
+
'If you want to get messages from a specific workspace, you can use the "workspace_id" parameter. ' +
|
|
37
|
+
'If you want to get messages for a particular language, you can use the "language" parameter. ',
|
|
38
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.listMessagesQueryParams.shape,
|
|
39
|
+
annotations: {
|
|
40
|
+
readOnlyHint: true,
|
|
41
|
+
destructiveHint: false,
|
|
42
|
+
},
|
|
43
|
+
}, async (params, { authInfo }) => {
|
|
44
|
+
try {
|
|
45
|
+
// Fallback to regular API
|
|
46
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.listMessages(params, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
utils_1.logger.error('Error listing messages:', { params, error });
|
|
50
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
server.registerTool('get_message', {
|
|
54
|
+
description: 'Get a message by its ID.',
|
|
55
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.getMessageByIdParams.merge(CarbonVoiceSimplifiedAPI_zod_1.getMessageByIdQueryParams).shape,
|
|
56
|
+
annotations: {
|
|
57
|
+
readOnlyHint: true,
|
|
58
|
+
destructiveHint: false,
|
|
59
|
+
},
|
|
60
|
+
}, async (args, { authInfo }) => {
|
|
61
|
+
try {
|
|
62
|
+
const { id, ...queryParams } = args;
|
|
63
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.getMessageById(id, queryParams, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
utils_1.logger.error('Error getting message by id:', { args, error });
|
|
67
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
server.registerTool('get_recent_messages', {
|
|
71
|
+
description: 'Get most recent messages, including their associated Conversation, Creator, and Labels information. ' +
|
|
72
|
+
'Returns a maximum of 10 messages.',
|
|
73
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.getTenRecentMessagesResponseQueryParams.shape,
|
|
74
|
+
annotations: {
|
|
75
|
+
readOnlyHint: true,
|
|
76
|
+
destructiveHint: false,
|
|
77
|
+
},
|
|
78
|
+
}, async (args, { authInfo }) => {
|
|
79
|
+
try {
|
|
80
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.getTenRecentMessagesResponse(args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
utils_1.logger.error('Error getting recent messages:', { args, error });
|
|
84
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
server.registerTool('create_conversation_message', {
|
|
88
|
+
description: 'Sends a message to an existing conversation or any type with a conversation_id. ' +
|
|
89
|
+
'To reply as a thread, included a message_id for "parent_id". You must provide a transcript or attachment.',
|
|
90
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.createConversationMessageParams.merge(CarbonVoiceSimplifiedAPI_zod_1.createConversationMessageBody).shape,
|
|
91
|
+
annotations: {
|
|
92
|
+
readOnlyHint: false,
|
|
93
|
+
destructiveHint: false,
|
|
94
|
+
},
|
|
95
|
+
}, async (args, { authInfo }) => {
|
|
96
|
+
try {
|
|
97
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.createConversationMessage(args.id, args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
utils_1.logger.error('Error creating conversation message:', { args, error });
|
|
101
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
server.registerTool('create_direct_message', {
|
|
105
|
+
description: 'Send a Direct Message (DM) to a User or a Group of Users. ' +
|
|
106
|
+
'In order to create a Direct Message, you must provide transcript or link attachments.',
|
|
107
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.sendDirectMessageBody.shape,
|
|
108
|
+
annotations: {
|
|
109
|
+
readOnlyHint: false,
|
|
110
|
+
destructiveHint: false,
|
|
111
|
+
},
|
|
112
|
+
}, async (args, { authInfo }) => {
|
|
113
|
+
try {
|
|
114
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.sendDirectMessage(args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
utils_1.logger.error('Error creating direct message:', { args, error });
|
|
118
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
server.registerTool('create_voicememo_message', {
|
|
122
|
+
description: 'Create a VoiceMemo Message. In order to create a VoiceMemo Message, you must provide a transcript or link attachments.',
|
|
123
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.createVoiceMemoMessageBody.shape,
|
|
124
|
+
annotations: {
|
|
125
|
+
readOnlyHint: false,
|
|
126
|
+
destructiveHint: false,
|
|
127
|
+
},
|
|
128
|
+
}, async (args, { authInfo }) => {
|
|
129
|
+
try {
|
|
130
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.createVoiceMemoMessage(args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
utils_1.logger.error('Error creating voicememo message:', { args, error });
|
|
134
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
server.registerTool('add_attachments_to_message', {
|
|
138
|
+
description: 'Add attachments to a message. In order to add attachments to a message, you must provide a message id and the attachments.',
|
|
139
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.addLinkAttachmentsToMessageParams.merge(CarbonVoiceSimplifiedAPI_zod_1.addLinkAttachmentsToMessageBody).shape,
|
|
140
|
+
annotations: {
|
|
141
|
+
readOnlyHint: false,
|
|
142
|
+
destructiveHint: false,
|
|
143
|
+
},
|
|
144
|
+
}, async (args, { authInfo }) => {
|
|
145
|
+
try {
|
|
146
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.addLinkAttachmentsToMessage(args.id, {
|
|
147
|
+
links: args.links,
|
|
148
|
+
}, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
utils_1.logger.error('Error adding attachments to message:', { args, error });
|
|
152
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
// Users
|
|
156
|
+
server.registerTool('get_user', {
|
|
157
|
+
description: 'Get detailed information about a specific user by their ID. ' +
|
|
158
|
+
'Returns the full user profile — name, languages, voice settings, ' +
|
|
159
|
+
'workspace memberships and roles, notification preferences, and timestamps. ' +
|
|
160
|
+
'This is richer than `search_user` (which only finds users by phone, email, or name). ' +
|
|
161
|
+
'Use this when you already have a user ID and need their complete information.',
|
|
162
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.getUserByIdParams.shape,
|
|
163
|
+
annotations: {
|
|
164
|
+
readOnlyHint: true,
|
|
165
|
+
destructiveHint: false,
|
|
166
|
+
},
|
|
167
|
+
}, async (args, { authInfo }) => {
|
|
168
|
+
var _a;
|
|
169
|
+
try {
|
|
170
|
+
const contacts = await cvApi.getContacts([args.id], (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token));
|
|
171
|
+
if (contacts.length === 0) {
|
|
172
|
+
throw new Error('user not found');
|
|
173
|
+
}
|
|
174
|
+
const userInfo = (_a = contacts.find((c) => c.id === args.id)) !== null && _a !== void 0 ? _a : contacts[0];
|
|
175
|
+
return (0, utils_1.formatToMCPToolResponse)(userInfo);
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
utils_1.logger.error('Error getting user by id:', { args, error });
|
|
179
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
server.registerTool('search_user', {
|
|
183
|
+
description: 'Search for a User by their phone number, email address, id or name. ' +
|
|
184
|
+
'(In order to search for a User, you must provide a phone number, email address, id or name.)' +
|
|
185
|
+
'When searching by name, only users that are part of your contacts will be returned',
|
|
186
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.searchUserQueryParams.shape,
|
|
187
|
+
annotations: {
|
|
188
|
+
readOnlyHint: true,
|
|
189
|
+
destructiveHint: false,
|
|
190
|
+
},
|
|
191
|
+
}, async (args, { authInfo }) => {
|
|
192
|
+
try {
|
|
193
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.searchUser(args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
utils_1.logger.error('Error searching for user:', { args, error });
|
|
197
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
server.registerTool('search_users', {
|
|
201
|
+
description: 'Search multiple Users by their phone numbers, email addresses, ids or names. ' +
|
|
202
|
+
'(In order to search Users, you must provide phone numbers, email addresses, ids or names.)' +
|
|
203
|
+
'When searching by name, only users that are part of your contacts will be returned',
|
|
204
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.searchUsersBody.shape,
|
|
205
|
+
annotations: {
|
|
206
|
+
readOnlyHint: true,
|
|
207
|
+
destructiveHint: false,
|
|
208
|
+
},
|
|
209
|
+
}, async (args, { authInfo }) => {
|
|
210
|
+
try {
|
|
211
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.searchUsers(args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
utils_1.logger.error('Error searching users:', { args, error });
|
|
215
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
server.registerTool('get_current_user', {
|
|
219
|
+
description: 'Get the current user information. ',
|
|
220
|
+
inputSchema: zod_1.z.object({}).shape, // Needed in order to have access to authInfo
|
|
221
|
+
annotations: {
|
|
222
|
+
readOnlyHint: true,
|
|
223
|
+
destructiveHint: false,
|
|
224
|
+
},
|
|
225
|
+
}, async (params, { authInfo }) => {
|
|
226
|
+
try {
|
|
227
|
+
return (0, utils_1.formatToMCPToolResponse)(await cvApi.getWhoAmI((0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
utils_1.logger.error('Error searching users:', { params, error });
|
|
231
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
// Conversations
|
|
235
|
+
server.registerTool('list_conversations', {
|
|
236
|
+
description: 'List all conversations. ' +
|
|
237
|
+
'Returns a simplified view of user conversations that have had messages sent or received within the last 6 months.',
|
|
238
|
+
inputSchema: zod_1.z.object({}).shape,
|
|
239
|
+
annotations: {
|
|
240
|
+
readOnlyHint: true,
|
|
241
|
+
destructiveHint: false,
|
|
242
|
+
},
|
|
243
|
+
}, async (args, { authInfo }) => {
|
|
244
|
+
try {
|
|
245
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.getAllConversations((0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
utils_1.logger.error('Error listing conversations:', { error });
|
|
249
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
server.registerTool('get_conversation', {
|
|
253
|
+
description: 'Get a conversation by its ID.',
|
|
254
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.getConversationByIdParams.shape,
|
|
255
|
+
annotations: {
|
|
256
|
+
readOnlyHint: true,
|
|
257
|
+
destructiveHint: false,
|
|
258
|
+
},
|
|
259
|
+
}, async (args, { authInfo }) => {
|
|
260
|
+
try {
|
|
261
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.getConversationById(args.id, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
262
|
+
}
|
|
263
|
+
catch (error) {
|
|
264
|
+
utils_1.logger.error('Error getting conversation by id:', { error });
|
|
265
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
server.registerTool('get_conversation_users', {
|
|
269
|
+
description: 'Get users in a conversation.',
|
|
270
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.getConversationByIdParams.shape,
|
|
271
|
+
annotations: {
|
|
272
|
+
readOnlyHint: true,
|
|
273
|
+
destructiveHint: false,
|
|
274
|
+
},
|
|
275
|
+
}, async (args, { authInfo }) => {
|
|
276
|
+
try {
|
|
277
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.getConversationUsers(args.id, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
utils_1.logger.error('Error getting conversation users:', { error });
|
|
281
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
server.registerTool('summarize_conversation', {
|
|
285
|
+
description: 'Summarize a conversation.',
|
|
286
|
+
inputSchema: schemas_1.summarizeConversationParams.shape,
|
|
287
|
+
annotations: {
|
|
288
|
+
readOnlyHint: false,
|
|
289
|
+
destructiveHint: false,
|
|
290
|
+
},
|
|
291
|
+
}, async (args, { authInfo }) => {
|
|
292
|
+
var _a;
|
|
293
|
+
try {
|
|
294
|
+
let message_ids = args.message_ids || [];
|
|
295
|
+
// If no message ids are provided, get couple of messages from the conversation
|
|
296
|
+
if (!args.message_ids) {
|
|
297
|
+
const messages = await simplifiedApi.listMessages(args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token));
|
|
298
|
+
message_ids = ((_a = messages.results) === null || _a === void 0 ? void 0 : _a.map((message) => message.id)) || [];
|
|
299
|
+
}
|
|
300
|
+
const aiResponse = await simplifiedApi.aIResponseControllerCreateResponse({
|
|
301
|
+
prompt_id: args.prompt_id,
|
|
302
|
+
message_ids: message_ids,
|
|
303
|
+
channel_id: args.conversation_id,
|
|
304
|
+
language: args.language,
|
|
305
|
+
}, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token));
|
|
306
|
+
return (0, utils_1.formatToMCPToolResponse)(aiResponse);
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
utils_1.logger.error('Error summarizing conversation:', { error });
|
|
310
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
// TODO: First we need to implement List messages filtered by unread messages
|
|
314
|
+
// server.registerTool(
|
|
315
|
+
// 'catch_up_conversation',
|
|
316
|
+
// {
|
|
317
|
+
// description: 'Catch up a conversation.',
|
|
318
|
+
// inputSchema: catchUpConversationParams.shape,
|
|
319
|
+
// },
|
|
320
|
+
// async (args: CatchUpConversationParams): Promise<McpToolResponse> => {
|
|
321
|
+
// try {
|
|
322
|
+
// let message_ids: string[] = args.message_ids || [];
|
|
323
|
+
// // If no message ids are provided, get couple of messages from the conversation
|
|
324
|
+
// if (!args.message_ids?.length) {
|
|
325
|
+
// const messages = await api.listMessages(args);
|
|
326
|
+
// message_ids = messages.results?.map((message) => message.id) || [];
|
|
327
|
+
// }
|
|
328
|
+
// const aiResponse = await api.aIResponseControllerCreateResponse({
|
|
329
|
+
// prompt_id: args.prompt_id,
|
|
330
|
+
// message_ids: message_ids,
|
|
331
|
+
// channel_id: args.conversation_id,
|
|
332
|
+
// language: args.language,
|
|
333
|
+
// });
|
|
334
|
+
// return formatToMCPToolResponse(aiResponse);
|
|
335
|
+
// } catch (error) {
|
|
336
|
+
// logger.error('Error catching up conversation:', { error });
|
|
337
|
+
// return formatToMCPToolResponse(error);
|
|
338
|
+
// }
|
|
339
|
+
// },
|
|
340
|
+
// );
|
|
341
|
+
// Folders
|
|
342
|
+
// server.registerTool(
|
|
343
|
+
// 'get_workspace_folders_and_message_counts',
|
|
344
|
+
// {
|
|
345
|
+
// description:
|
|
346
|
+
// 'Returns, for each workspace, the total number of folders and messages, as well as a breakdown of folders, ' +
|
|
347
|
+
// 'messages, and messages not in any folder.(Required to inform message type:voicememo,prerecorded)',
|
|
348
|
+
// inputSchema: getCountsGroupedByWorkspaceQueryParams.shape,
|
|
349
|
+
// },
|
|
350
|
+
// async (args: GetCountsGroupedByWorkspaceParams): Promise<McpToolResponse> => {
|
|
351
|
+
// try {
|
|
352
|
+
// return formatToMCPToolResponse(
|
|
353
|
+
// await api.getCountsGroupedByWorkspace(args),
|
|
354
|
+
// );
|
|
355
|
+
// } catch (error) {
|
|
356
|
+
// logger.error('Error listing workspace folders:', { error });
|
|
357
|
+
// return formatToMCPToolResponse(error);
|
|
358
|
+
// }
|
|
359
|
+
// },
|
|
360
|
+
// );
|
|
361
|
+
server.registerTool('get_root_folders', {
|
|
362
|
+
description: 'Lists all root folders for a given workspace, including their names, IDs, and basic structure, ' +
|
|
363
|
+
'but does not provide aggregate counts.(Required to inform message type:voicememo,prerecorded)',
|
|
364
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.getAllRootFoldersQueryParams.shape,
|
|
365
|
+
annotations: {
|
|
366
|
+
readOnlyHint: true,
|
|
367
|
+
destructiveHint: false,
|
|
368
|
+
},
|
|
369
|
+
}, async (args, { authInfo }) => {
|
|
370
|
+
try {
|
|
371
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.getAllRootFolders(args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
372
|
+
}
|
|
373
|
+
catch (error) {
|
|
374
|
+
utils_1.logger.error('Error listing root folders:', { error });
|
|
375
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
server.registerTool('create_folder', {
|
|
379
|
+
description: 'Create a new folder.',
|
|
380
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.createFolderBody.shape,
|
|
381
|
+
annotations: {
|
|
382
|
+
readOnlyHint: false,
|
|
383
|
+
destructiveHint: false,
|
|
384
|
+
},
|
|
385
|
+
}, async (args, { authInfo }) => {
|
|
386
|
+
try {
|
|
387
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.createFolder(args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
388
|
+
}
|
|
389
|
+
catch (error) {
|
|
390
|
+
utils_1.logger.error('Error creating folder:', { error });
|
|
391
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
server.registerTool('get_folder', {
|
|
395
|
+
description: 'Get a folder by its ID.',
|
|
396
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.getFolderByIdParams.merge(CarbonVoiceSimplifiedAPI_zod_1.getFolderByIdQueryParams).shape,
|
|
397
|
+
annotations: {
|
|
398
|
+
readOnlyHint: true,
|
|
399
|
+
destructiveHint: false,
|
|
400
|
+
},
|
|
401
|
+
}, async (args, { authInfo }) => {
|
|
402
|
+
try {
|
|
403
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.getFolderById(args.id, args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
404
|
+
}
|
|
405
|
+
catch (error) {
|
|
406
|
+
utils_1.logger.error('Error getting folder by id:', { error });
|
|
407
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
server.registerTool('get_folder_with_messages', {
|
|
411
|
+
description: 'Get a folder including its messages by its ID. (Only messages at folder level are returned.)',
|
|
412
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.getFolderMessagesParams.shape,
|
|
413
|
+
annotations: {
|
|
414
|
+
readOnlyHint: true,
|
|
415
|
+
destructiveHint: false,
|
|
416
|
+
},
|
|
417
|
+
}, async (args, { authInfo }) => {
|
|
418
|
+
try {
|
|
419
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.getFolderMessages(args.id, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
420
|
+
}
|
|
421
|
+
catch (error) {
|
|
422
|
+
utils_1.logger.error('Error getting folder with messages:', { error });
|
|
423
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
server.registerTool('update_folder_name', {
|
|
427
|
+
description: 'Update a folder name by its ID.',
|
|
428
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.updateFolderNameParams.merge(CarbonVoiceSimplifiedAPI_zod_1.updateFolderNameBody).shape,
|
|
429
|
+
annotations: {
|
|
430
|
+
readOnlyHint: false,
|
|
431
|
+
destructiveHint: false,
|
|
432
|
+
},
|
|
433
|
+
}, async (args, { authInfo }) => {
|
|
434
|
+
try {
|
|
435
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.updateFolderName(args.id, args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
436
|
+
}
|
|
437
|
+
catch (error) {
|
|
438
|
+
utils_1.logger.error('Error updating folder name:', { error });
|
|
439
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
server.registerTool('delete_folder', {
|
|
443
|
+
description: 'Delete a folder by its ID. Deleting a folder will also delete nested folders and all the messages in referenced folders. ' +
|
|
444
|
+
'(This is a destructive action and cannot be undone, so please be careful.)',
|
|
445
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.deleteFolderParams.shape,
|
|
446
|
+
annotations: {
|
|
447
|
+
readOnlyHint: false,
|
|
448
|
+
destructiveHint: true,
|
|
449
|
+
},
|
|
450
|
+
}, async (args, { authInfo }) => {
|
|
451
|
+
try {
|
|
452
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.deleteFolder(args.id, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
453
|
+
}
|
|
454
|
+
catch (error) {
|
|
455
|
+
utils_1.logger.error('Error deleting folder:', { error });
|
|
456
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
server.registerTool('move_folder', {
|
|
460
|
+
description: 'Move a folder by its ID. Move a Folder into another Folder or into a Workspace.',
|
|
461
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.moveFolderParams.merge(CarbonVoiceSimplifiedAPI_zod_1.moveFolderBody).shape,
|
|
462
|
+
annotations: {
|
|
463
|
+
readOnlyHint: false,
|
|
464
|
+
destructiveHint: false,
|
|
465
|
+
},
|
|
466
|
+
}, async (args, { authInfo }) => {
|
|
467
|
+
try {
|
|
468
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.moveFolder(args.id, args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
utils_1.logger.error('Error moving folder:', { error });
|
|
472
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
server.registerTool('move_message_to_folder', {
|
|
476
|
+
description: 'Move a message to a folder by its ID. Move a Message into another Folder or into a Workspace. ' +
|
|
477
|
+
'Only allowed to move messages of type: voicememo,prerecorded.',
|
|
478
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.addMessageToFolderOrWorkspaceBody.shape,
|
|
479
|
+
annotations: {
|
|
480
|
+
readOnlyHint: false,
|
|
481
|
+
destructiveHint: false,
|
|
482
|
+
},
|
|
483
|
+
}, async (args, { authInfo }) => {
|
|
484
|
+
try {
|
|
485
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.addMessageToFolderOrWorkspace(args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
486
|
+
}
|
|
487
|
+
catch (error) {
|
|
488
|
+
utils_1.logger.error('Error moving message to folder:', { error });
|
|
489
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
// Workspace
|
|
493
|
+
server.registerTool('get_workspaces_basic_info', {
|
|
494
|
+
description: 'Get basic information about a workspace.',
|
|
495
|
+
inputSchema: zod_1.z.object({}).shape,
|
|
496
|
+
annotations: {
|
|
497
|
+
readOnlyHint: true,
|
|
498
|
+
destructiveHint: false,
|
|
499
|
+
},
|
|
500
|
+
}, async (params, { authInfo }) => {
|
|
501
|
+
try {
|
|
502
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.getAllWorkspacesWithBasicInfo((0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
503
|
+
}
|
|
504
|
+
catch (error) {
|
|
505
|
+
utils_1.logger.error('Error getting workspaces basic info:', { error });
|
|
506
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
// AI Magic
|
|
510
|
+
server.registerTool('list_ai_actions', {
|
|
511
|
+
description: 'List AI Actions (Prompts). Optionally, you can filter by owner type and workspace id. ' +
|
|
512
|
+
'Filtering by owner type, Possible values: "user", "workspace", "system". ' +
|
|
513
|
+
'Do not use unless the user explicitly requests it.',
|
|
514
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.aIPromptControllerGetPromptsQueryParams.shape,
|
|
515
|
+
annotations: {
|
|
516
|
+
readOnlyHint: true,
|
|
517
|
+
destructiveHint: false,
|
|
518
|
+
},
|
|
519
|
+
}, async (args, { authInfo }) => {
|
|
520
|
+
try {
|
|
521
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.aIPromptControllerGetPrompts(args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
522
|
+
}
|
|
523
|
+
catch (error) {
|
|
524
|
+
utils_1.logger.error('Error listing ai actions:', { error });
|
|
525
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
server.registerTool('run_ai_action', {
|
|
529
|
+
description: 'Run an AI Action (Prompt) for a message. You can run an AI Action for a message by its ID or a list of message IDs.',
|
|
530
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.aIResponseControllerCreateResponseBody.shape,
|
|
531
|
+
annotations: {
|
|
532
|
+
readOnlyHint: false,
|
|
533
|
+
destructiveHint: false,
|
|
534
|
+
},
|
|
535
|
+
}, async (args, { authInfo }) => {
|
|
536
|
+
try {
|
|
537
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.aIResponseControllerCreateResponse(args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
538
|
+
}
|
|
539
|
+
catch (error) {
|
|
540
|
+
utils_1.logger.error('Error running ai action:', { error });
|
|
541
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
server.registerTool('run_ai_action_for_shared_link', {
|
|
545
|
+
description: 'Run an AI Action (Prompt) for a shared link. You can run an AI Action for a shared link by its ID or a list of shared link IDs. ' +
|
|
546
|
+
'You can also provide the language of the response.',
|
|
547
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.createShareLinkAIResponseBody.shape,
|
|
548
|
+
annotations: {
|
|
549
|
+
readOnlyHint: false,
|
|
550
|
+
destructiveHint: false,
|
|
551
|
+
},
|
|
552
|
+
}, async (args, { authInfo }) => {
|
|
553
|
+
try {
|
|
554
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.createShareLinkAIResponse(args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
555
|
+
}
|
|
556
|
+
catch (error) {
|
|
557
|
+
utils_1.logger.error('Error running ai action for shared link:', { error });
|
|
558
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
server.registerTool('get_ai_action_responses', {
|
|
562
|
+
description: 'Retrieve previously generated AI Action (Prompt) responses by filtering for a specific prompt, message, or conversation ID. ' +
|
|
563
|
+
'Combine filters to narrow results and view all AI-generated responses related to a particular prompt, message, or conversation.',
|
|
564
|
+
inputSchema: CarbonVoiceSimplifiedAPI_zod_1.aIResponseControllerGetAllResponsesQueryParams.shape,
|
|
565
|
+
annotations: {
|
|
566
|
+
readOnlyHint: true,
|
|
567
|
+
destructiveHint: false,
|
|
568
|
+
},
|
|
569
|
+
}, async (args, { authInfo }) => {
|
|
570
|
+
try {
|
|
571
|
+
return (0, utils_1.formatToMCPToolResponse)(await simplifiedApi.aIResponseControllerGetAllResponses(args, (0, auth_1.setCarbonVoiceAuthHeader)(authInfo === null || authInfo === void 0 ? void 0 : authInfo.token)));
|
|
572
|
+
}
|
|
573
|
+
catch (error) {
|
|
574
|
+
utils_1.logger.error('Error getting ai action responses:', { error });
|
|
575
|
+
return (0, utils_1.formatToMCPToolResponse)(error);
|
|
576
|
+
}
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Builds a new MCP server with all tools registered. Use one instance per
|
|
581
|
+
* stateless HTTP request when handling concurrent clients.
|
|
582
|
+
*/
|
|
583
|
+
function createMcpServer() {
|
|
584
|
+
const server = new mcp_js_1.McpServer({
|
|
585
|
+
name: constants_1.SERVICE_NAME,
|
|
586
|
+
version: constants_1.SERVICE_VERSION,
|
|
587
|
+
capabilities: {
|
|
588
|
+
resources: {},
|
|
589
|
+
tools: {},
|
|
590
|
+
},
|
|
591
|
+
});
|
|
592
|
+
registerCarbonVoiceTools(server);
|
|
593
|
+
return server;
|
|
594
|
+
}
|
|
595
|
+
const server = createMcpServer();
|
|
568
596
|
exports.default = server;
|
|
569
597
|
//# sourceMappingURL=server.js.map
|