@powerhousedao/reactor-mcp 6.0.0-dev.25 → 6.0.0-dev.250

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 (71) hide show
  1. package/dist/cli.d.mts +1 -0
  2. package/dist/cli.mjs +138 -0
  3. package/dist/cli.mjs.map +1 -0
  4. package/dist/index.d.mts +637 -0
  5. package/dist/index.d.mts.map +1 -0
  6. package/dist/index.mjs +46 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/dist/server-B68G2N1-.mjs +391 -0
  9. package/dist/server-B68G2N1-.mjs.map +1 -0
  10. package/package.json +23 -21
  11. package/dist/src/cli.d.ts +0 -2
  12. package/dist/src/cli.d.ts.map +0 -1
  13. package/dist/src/cli.js +0 -10
  14. package/dist/src/cli.js.map +0 -1
  15. package/dist/src/express.d.ts +0 -5
  16. package/dist/src/express.d.ts.map +0 -1
  17. package/dist/src/express.js +0 -59
  18. package/dist/src/express.js.map +0 -1
  19. package/dist/src/feature-flags.d.ts +0 -2
  20. package/dist/src/feature-flags.d.ts.map +0 -1
  21. package/dist/src/feature-flags.js +0 -9
  22. package/dist/src/feature-flags.js.map +0 -1
  23. package/dist/src/index.d.ts +0 -5
  24. package/dist/src/index.d.ts.map +0 -1
  25. package/dist/src/index.js +0 -5
  26. package/dist/src/index.js.map +0 -1
  27. package/dist/src/logger.d.ts +0 -3
  28. package/dist/src/logger.d.ts.map +0 -1
  29. package/dist/src/logger.js +0 -3
  30. package/dist/src/logger.js.map +0 -1
  31. package/dist/src/sdk/chat.d.ts +0 -19
  32. package/dist/src/sdk/chat.d.ts.map +0 -1
  33. package/dist/src/sdk/chat.js +0 -60
  34. package/dist/src/sdk/chat.js.map +0 -1
  35. package/dist/src/server.d.ts +0 -5
  36. package/dist/src/server.d.ts.map +0 -1
  37. package/dist/src/server.js +0 -56
  38. package/dist/src/server.js.map +0 -1
  39. package/dist/src/stdio/index.d.ts +0 -7
  40. package/dist/src/stdio/index.d.ts.map +0 -1
  41. package/dist/src/stdio/index.js +0 -93
  42. package/dist/src/stdio/index.js.map +0 -1
  43. package/dist/src/stdio/loader.d.ts +0 -18
  44. package/dist/src/stdio/loader.d.ts.map +0 -1
  45. package/dist/src/stdio/loader.js +0 -89
  46. package/dist/src/stdio/loader.js.map +0 -1
  47. package/dist/src/tools/index.d.ts +0 -3
  48. package/dist/src/tools/index.d.ts.map +0 -1
  49. package/dist/src/tools/index.js +0 -3
  50. package/dist/src/tools/index.js.map +0 -1
  51. package/dist/src/tools/reactor.d.ts +0 -847
  52. package/dist/src/tools/reactor.d.ts.map +0 -1
  53. package/dist/src/tools/reactor.js +0 -461
  54. package/dist/src/tools/reactor.js.map +0 -1
  55. package/dist/src/tools/types.d.ts +0 -24
  56. package/dist/src/tools/types.d.ts.map +0 -1
  57. package/dist/src/tools/types.js +0 -2
  58. package/dist/src/tools/types.js.map +0 -1
  59. package/dist/src/tools/utils.d.ts +0 -23
  60. package/dist/src/tools/utils.d.ts.map +0 -1
  61. package/dist/src/tools/utils.js +0 -99
  62. package/dist/src/tools/utils.js.map +0 -1
  63. package/dist/test/reactor.test.d.ts +0 -2
  64. package/dist/test/reactor.test.d.ts.map +0 -1
  65. package/dist/test/reactor.test.js +0 -501
  66. package/dist/test/reactor.test.js.map +0 -1
  67. package/dist/tsconfig.tsbuildinfo +0 -1
  68. package/dist/vitest.config.d.ts +0 -3
  69. package/dist/vitest.config.d.ts.map +0 -1
  70. package/dist/vitest.config.js +0 -9
  71. package/dist/vitest.config.js.map +0 -1
@@ -0,0 +1,637 @@
1
+ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
2
+ import { McpServer, ToolCallback } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { IReactorClient, ISyncManager } from "@powerhousedao/reactor";
4
+ import { Action, DocumentModelModule } from "@powerhousedao/shared/document-model";
5
+ import { ZodRawShape, z } from "zod";
6
+ import { IncomingMessage, ServerResponse } from "node:http";
7
+ import * as _modelcontextprotocol_sdk_types0 from "@modelcontextprotocol/sdk/types";
8
+ import { CallToolResult, Prompt, Resource, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
9
+
10
+ //#region src/mcp-routes.d.ts
11
+ /** Minimal interface for an HTTP adapter that supports Node.js-style route handlers. */
12
+ interface NodeRouteAdapter {
13
+ mountNodeRoute(method: "DELETE" | "GET" | "POST", path: string, handler: (req: IncomingMessage, res: ServerResponse, body?: unknown) => void | Promise<void>): void;
14
+ }
15
+ interface SetupMcpServerOptions {
16
+ client: IReactorClient;
17
+ syncManager?: ISyncManager;
18
+ }
19
+ /** @internal Injected in tests to avoid relying on constructor mock semantics. */
20
+ type TransportFactory = (opts: {
21
+ sessionIdGenerator: undefined;
22
+ }) => InstanceType<typeof StreamableHTTPServerTransport>;
23
+ declare function setupMcpServer(options: SetupMcpServerOptions, httpAdapter: NodeRouteAdapter, createTransport?: TransportFactory): Promise<void>;
24
+ //#endregion
25
+ //#region src/server.d.ts
26
+ interface CreateServerOptions {
27
+ client: IReactorClient;
28
+ syncManager?: ISyncManager;
29
+ }
30
+ declare function createServer(options: CreateServerOptions): Promise<McpServer>;
31
+ //#endregion
32
+ //#region src/tools/types.d.ts
33
+ type ExtractCallbackFromTool<T extends ToolSchema> = T extends {
34
+ inputSchema: infer S;
35
+ } ? ToolCallback<S extends ZodRawShape ? S : undefined> : ToolCallback;
36
+ type ToolWithCallback<T extends ToolSchema = ToolSchema> = T & {
37
+ callback: ExtractCallbackFromTool<T>;
38
+ };
39
+ type ToolSchema<InputArgs extends ZodRawShape = ZodRawShape, OutputArgs extends ZodRawShape = ZodRawShape> = {
40
+ name: string;
41
+ title?: string;
42
+ description?: string;
43
+ inputSchema?: InputArgs;
44
+ outputSchema?: OutputArgs;
45
+ annotations?: ToolAnnotations;
46
+ };
47
+ type ResolveZodSchema<T> = T extends z.ZodRawShape ? z.infer<z.ZodObject<T>> : T;
48
+ interface IMcpProvider<T extends ToolWithCallback = ToolWithCallback, R extends Resource = Resource, P extends Prompt = Prompt> {
49
+ tools: Record<T["name"], ToolWithCallback<T>>;
50
+ resources: Record<R["name"], R>;
51
+ prompts: Record<P["name"], P>;
52
+ }
53
+ //#endregion
54
+ //#region src/tools/reactor.d.ts
55
+ type ReactorMcpProviderOptions = {
56
+ client: IReactorClient;
57
+ syncManager?: ISyncManager;
58
+ };
59
+ declare const createDocumentTool: {
60
+ readonly name: "createDocument";
61
+ readonly description: "Create a new document.\n Unless the user specifies otherwise, and a drive named \"vetra\" is available, add the document to that drive by providing the drive's ID in the \"driveId\" parameter.\n When \"driveId\" is provided, the document is created and added to the drive atomically — no separate \"addActions\" call with \"ADD_FILE\" is needed.";
62
+ readonly inputSchema: {
63
+ readonly documentType: z.ZodString;
64
+ readonly name: z.ZodOptional<z.ZodString>;
65
+ readonly driveId: z.ZodOptional<z.ZodString>;
66
+ readonly parentFolder: z.ZodOptional<z.ZodString>;
67
+ };
68
+ readonly outputSchema: {
69
+ readonly documentId: z.ZodString;
70
+ };
71
+ };
72
+ declare const getDocumentTool: {
73
+ readonly name: "getDocument";
74
+ readonly description: "Retrieve a document by its ID";
75
+ readonly inputSchema: {
76
+ readonly id: z.ZodString;
77
+ };
78
+ readonly outputSchema: {
79
+ readonly document: z.ZodUnknown;
80
+ };
81
+ };
82
+ declare const getDocumentsTool: {
83
+ readonly name: "getDocuments";
84
+ readonly description: "List documents in a drive";
85
+ readonly inputSchema: {
86
+ readonly parentId: z.ZodString;
87
+ };
88
+ readonly outputSchema: {
89
+ readonly documentIds: z.ZodArray<z.ZodString>;
90
+ };
91
+ };
92
+ declare const deleteDocumentTool: {
93
+ readonly name: "deleteDocument";
94
+ readonly description: "Delete a document";
95
+ readonly inputSchema: {
96
+ readonly documentId: z.ZodString;
97
+ };
98
+ readonly outputSchema: {
99
+ readonly success: z.ZodBoolean;
100
+ };
101
+ };
102
+ declare const addActionsTool: {
103
+ readonly name: "addActions";
104
+ readonly description: "Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps.";
105
+ readonly inputSchema: {
106
+ readonly documentId: z.ZodString;
107
+ readonly actions: z.ZodArray<z.ZodObject<{
108
+ type: z.ZodString;
109
+ input: z.ZodUnknown;
110
+ scope: z.ZodString;
111
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
112
+ }, z.core.$strict>>;
113
+ };
114
+ readonly outputSchema: {
115
+ readonly success: z.ZodBoolean;
116
+ };
117
+ };
118
+ declare const getDrivesTool: {
119
+ readonly name: "getDrives";
120
+ readonly description: "List all drives";
121
+ readonly inputSchema: {};
122
+ readonly outputSchema: {
123
+ readonly driveIds: z.ZodArray<z.ZodString>;
124
+ };
125
+ };
126
+ declare const addDriveTool: {
127
+ readonly name: "addDrive";
128
+ readonly description: "Create a new drive";
129
+ readonly inputSchema: {
130
+ readonly driveInput: z.ZodObject<{
131
+ global: z.ZodObject<{
132
+ name: z.ZodString;
133
+ icon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
134
+ }, z.core.$strip>;
135
+ id: z.ZodOptional<z.ZodString>;
136
+ slug: z.ZodOptional<z.ZodString>;
137
+ preferredEditor: z.ZodOptional<z.ZodString>;
138
+ local: z.ZodOptional<z.ZodObject<{
139
+ availableOffline: z.ZodOptional<z.ZodBoolean>;
140
+ sharingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
141
+ }, z.core.$strip>>;
142
+ }, z.core.$strip>;
143
+ };
144
+ readonly outputSchema: {
145
+ readonly driveId: z.ZodString;
146
+ };
147
+ };
148
+ declare const getDriveTool: {
149
+ readonly name: "getDrive";
150
+ readonly description: "Get a specific drive";
151
+ readonly inputSchema: {
152
+ readonly driveId: z.ZodString;
153
+ readonly options: z.ZodOptional<z.ZodObject<{
154
+ revisions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
155
+ checkHashes: z.ZodOptional<z.ZodBoolean>;
156
+ }, z.core.$strip>>;
157
+ };
158
+ readonly outputSchema: {
159
+ readonly drive: z.ZodUnknown;
160
+ };
161
+ };
162
+ declare const deleteDriveTool: {
163
+ readonly name: "deleteDrive";
164
+ readonly description: "Delete a drive";
165
+ readonly inputSchema: {
166
+ readonly driveId: z.ZodString;
167
+ };
168
+ readonly outputSchema: {
169
+ readonly success: z.ZodBoolean;
170
+ };
171
+ };
172
+ declare const addRemoteDriveTool: {
173
+ readonly name: "addRemoteDrive";
174
+ readonly description: "Connect to a remote drive";
175
+ readonly inputSchema: {
176
+ readonly url: z.ZodString;
177
+ readonly options: z.ZodObject<{
178
+ availableOffline: z.ZodBoolean;
179
+ sharingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
180
+ pullFilter: z.ZodOptional<z.ZodObject<{
181
+ branch: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
182
+ documentId: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
183
+ documentType: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
184
+ scope: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
185
+ }, z.core.$strip>>;
186
+ pullInterval: z.ZodOptional<z.ZodNumber>;
187
+ }, z.core.$strip>;
188
+ };
189
+ readonly outputSchema: {
190
+ readonly driveId: z.ZodString;
191
+ };
192
+ };
193
+ declare const getDocumentModelSchemaTool: {
194
+ readonly name: "getDocumentModelSchema";
195
+ readonly description: "Get the schema of a document model";
196
+ readonly inputSchema: {
197
+ readonly type: z.ZodString;
198
+ };
199
+ readonly outputSchema: {
200
+ readonly schema: z.ZodUnknown;
201
+ };
202
+ };
203
+ declare const getDocumentModelsTool: {
204
+ readonly name: "getDocumentModels";
205
+ readonly description: "Get the list of document models";
206
+ readonly inputSchema: {};
207
+ readonly outputSchema: {
208
+ readonly documentModels: z.ZodArray<z.ZodObject<{
209
+ name: z.ZodString;
210
+ type: z.ZodString;
211
+ description: z.ZodString;
212
+ extension: z.ZodString;
213
+ authorName: z.ZodString;
214
+ authorWebsite: z.ZodString;
215
+ }, z.core.$strip>>;
216
+ };
217
+ };
218
+ type ToolRecord<T extends readonly ToolSchema[]> = { [K in T[number]["name"]]: ToolWithCallback<Extract<T[number], {
219
+ name: K;
220
+ }>> };
221
+ declare const allTools: readonly [{
222
+ readonly name: "getDocument";
223
+ readonly description: "Retrieve a document by its ID";
224
+ readonly inputSchema: {
225
+ readonly id: z.ZodString;
226
+ };
227
+ readonly outputSchema: {
228
+ readonly document: z.ZodUnknown;
229
+ };
230
+ }, {
231
+ readonly name: "createDocument";
232
+ readonly description: "Create a new document.\n Unless the user specifies otherwise, and a drive named \"vetra\" is available, add the document to that drive by providing the drive's ID in the \"driveId\" parameter.\n When \"driveId\" is provided, the document is created and added to the drive atomically — no separate \"addActions\" call with \"ADD_FILE\" is needed.";
233
+ readonly inputSchema: {
234
+ readonly documentType: z.ZodString;
235
+ readonly name: z.ZodOptional<z.ZodString>;
236
+ readonly driveId: z.ZodOptional<z.ZodString>;
237
+ readonly parentFolder: z.ZodOptional<z.ZodString>;
238
+ };
239
+ readonly outputSchema: {
240
+ readonly documentId: z.ZodString;
241
+ };
242
+ }, {
243
+ readonly name: "getDocuments";
244
+ readonly description: "List documents in a drive";
245
+ readonly inputSchema: {
246
+ readonly parentId: z.ZodString;
247
+ };
248
+ readonly outputSchema: {
249
+ readonly documentIds: z.ZodArray<z.ZodString>;
250
+ };
251
+ }, {
252
+ readonly name: "deleteDocument";
253
+ readonly description: "Delete a document";
254
+ readonly inputSchema: {
255
+ readonly documentId: z.ZodString;
256
+ };
257
+ readonly outputSchema: {
258
+ readonly success: z.ZodBoolean;
259
+ };
260
+ }, {
261
+ readonly name: "addActions";
262
+ readonly description: "Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps.";
263
+ readonly inputSchema: {
264
+ readonly documentId: z.ZodString;
265
+ readonly actions: z.ZodArray<z.ZodObject<{
266
+ type: z.ZodString;
267
+ input: z.ZodUnknown;
268
+ scope: z.ZodString;
269
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
270
+ }, z.core.$strict>>;
271
+ };
272
+ readonly outputSchema: {
273
+ readonly success: z.ZodBoolean;
274
+ };
275
+ }, {
276
+ readonly name: "getDrives";
277
+ readonly description: "List all drives";
278
+ readonly inputSchema: {};
279
+ readonly outputSchema: {
280
+ readonly driveIds: z.ZodArray<z.ZodString>;
281
+ };
282
+ }, {
283
+ readonly name: "addDrive";
284
+ readonly description: "Create a new drive";
285
+ readonly inputSchema: {
286
+ readonly driveInput: z.ZodObject<{
287
+ global: z.ZodObject<{
288
+ name: z.ZodString;
289
+ icon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
290
+ }, z.core.$strip>;
291
+ id: z.ZodOptional<z.ZodString>;
292
+ slug: z.ZodOptional<z.ZodString>;
293
+ preferredEditor: z.ZodOptional<z.ZodString>;
294
+ local: z.ZodOptional<z.ZodObject<{
295
+ availableOffline: z.ZodOptional<z.ZodBoolean>;
296
+ sharingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
297
+ }, z.core.$strip>>;
298
+ }, z.core.$strip>;
299
+ };
300
+ readonly outputSchema: {
301
+ readonly driveId: z.ZodString;
302
+ };
303
+ }, {
304
+ readonly name: "getDrive";
305
+ readonly description: "Get a specific drive";
306
+ readonly inputSchema: {
307
+ readonly driveId: z.ZodString;
308
+ readonly options: z.ZodOptional<z.ZodObject<{
309
+ revisions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
310
+ checkHashes: z.ZodOptional<z.ZodBoolean>;
311
+ }, z.core.$strip>>;
312
+ };
313
+ readonly outputSchema: {
314
+ readonly drive: z.ZodUnknown;
315
+ };
316
+ }, {
317
+ readonly name: "deleteDrive";
318
+ readonly description: "Delete a drive";
319
+ readonly inputSchema: {
320
+ readonly driveId: z.ZodString;
321
+ };
322
+ readonly outputSchema: {
323
+ readonly success: z.ZodBoolean;
324
+ };
325
+ }, {
326
+ readonly name: "addRemoteDrive";
327
+ readonly description: "Connect to a remote drive";
328
+ readonly inputSchema: {
329
+ readonly url: z.ZodString;
330
+ readonly options: z.ZodObject<{
331
+ availableOffline: z.ZodBoolean;
332
+ sharingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
333
+ pullFilter: z.ZodOptional<z.ZodObject<{
334
+ branch: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
335
+ documentId: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
336
+ documentType: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
337
+ scope: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
338
+ }, z.core.$strip>>;
339
+ pullInterval: z.ZodOptional<z.ZodNumber>;
340
+ }, z.core.$strip>;
341
+ };
342
+ readonly outputSchema: {
343
+ readonly driveId: z.ZodString;
344
+ };
345
+ }, {
346
+ readonly name: "getDocumentModelSchema";
347
+ readonly description: "Get the schema of a document model";
348
+ readonly inputSchema: {
349
+ readonly type: z.ZodString;
350
+ };
351
+ readonly outputSchema: {
352
+ readonly schema: z.ZodUnknown;
353
+ };
354
+ }, {
355
+ readonly name: "getDocumentModels";
356
+ readonly description: "Get the list of document models";
357
+ readonly inputSchema: {};
358
+ readonly outputSchema: {
359
+ readonly documentModels: z.ZodArray<z.ZodObject<{
360
+ name: z.ZodString;
361
+ type: z.ZodString;
362
+ description: z.ZodString;
363
+ extension: z.ZodString;
364
+ authorName: z.ZodString;
365
+ authorWebsite: z.ZodString;
366
+ }, z.core.$strip>>;
367
+ };
368
+ }];
369
+ type ReactorMcpTools = ToolRecord<typeof allTools>;
370
+ declare function createReactorMcpProvider(options: ReactorMcpProviderOptions): Promise<{
371
+ readonly tools: {
372
+ readonly getDocument: {
373
+ readonly name: "getDocument";
374
+ readonly description: "Retrieve a document by its ID";
375
+ readonly inputSchema: {
376
+ readonly id: z.ZodString;
377
+ };
378
+ readonly outputSchema: {
379
+ readonly document: z.ZodUnknown;
380
+ };
381
+ } & {
382
+ callback: (args: {
383
+ id: string;
384
+ }) => Promise<_modelcontextprotocol_sdk_types0.CallToolResult>;
385
+ };
386
+ readonly createDocument: {
387
+ readonly name: "createDocument";
388
+ readonly description: "Create a new document.\n Unless the user specifies otherwise, and a drive named \"vetra\" is available, add the document to that drive by providing the drive's ID in the \"driveId\" parameter.\n When \"driveId\" is provided, the document is created and added to the drive atomically — no separate \"addActions\" call with \"ADD_FILE\" is needed.";
389
+ readonly inputSchema: {
390
+ readonly documentType: z.ZodString;
391
+ readonly name: z.ZodOptional<z.ZodString>;
392
+ readonly driveId: z.ZodOptional<z.ZodString>;
393
+ readonly parentFolder: z.ZodOptional<z.ZodString>;
394
+ };
395
+ readonly outputSchema: {
396
+ readonly documentId: z.ZodString;
397
+ };
398
+ } & {
399
+ callback: (args: {
400
+ documentType: string;
401
+ name?: string | undefined;
402
+ driveId?: string | undefined;
403
+ parentFolder?: string | undefined;
404
+ }) => Promise<_modelcontextprotocol_sdk_types0.CallToolResult>;
405
+ };
406
+ readonly getDocuments: {
407
+ readonly name: "getDocuments";
408
+ readonly description: "List documents in a drive";
409
+ readonly inputSchema: {
410
+ readonly parentId: z.ZodString;
411
+ };
412
+ readonly outputSchema: {
413
+ readonly documentIds: z.ZodArray<z.ZodString>;
414
+ };
415
+ } & {
416
+ callback: (args: {
417
+ parentId: string;
418
+ }) => Promise<_modelcontextprotocol_sdk_types0.CallToolResult>;
419
+ };
420
+ readonly deleteDocument: {
421
+ readonly name: "deleteDocument";
422
+ readonly description: "Delete a document";
423
+ readonly inputSchema: {
424
+ readonly documentId: z.ZodString;
425
+ };
426
+ readonly outputSchema: {
427
+ readonly success: z.ZodBoolean;
428
+ };
429
+ } & {
430
+ callback: (args: {
431
+ documentId: string;
432
+ }) => Promise<_modelcontextprotocol_sdk_types0.CallToolResult>;
433
+ };
434
+ readonly addActions: {
435
+ readonly name: "addActions";
436
+ readonly description: "Adds actions to a document. Prefer adding multiples actions at once to reduce the number of steps.";
437
+ readonly inputSchema: {
438
+ readonly documentId: z.ZodString;
439
+ readonly actions: z.ZodArray<z.ZodObject<{
440
+ type: z.ZodString;
441
+ input: z.ZodUnknown;
442
+ scope: z.ZodString;
443
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
444
+ }, z.core.$strict>>;
445
+ };
446
+ readonly outputSchema: {
447
+ readonly success: z.ZodBoolean;
448
+ };
449
+ } & {
450
+ callback: (args: {
451
+ documentId: string;
452
+ actions: {
453
+ type: string;
454
+ input: unknown;
455
+ scope: string;
456
+ context?: Record<string, unknown> | undefined;
457
+ }[];
458
+ }) => Promise<_modelcontextprotocol_sdk_types0.CallToolResult>;
459
+ };
460
+ readonly getDrives: {
461
+ readonly name: "getDrives";
462
+ readonly description: "List all drives";
463
+ readonly inputSchema: {};
464
+ readonly outputSchema: {
465
+ readonly driveIds: z.ZodArray<z.ZodString>;
466
+ };
467
+ } & {
468
+ callback: (args: Record<string, never>) => Promise<_modelcontextprotocol_sdk_types0.CallToolResult>;
469
+ };
470
+ readonly addDrive: {
471
+ readonly name: "addDrive";
472
+ readonly description: "Create a new drive";
473
+ readonly inputSchema: {
474
+ readonly driveInput: z.ZodObject<{
475
+ global: z.ZodObject<{
476
+ name: z.ZodString;
477
+ icon: z.ZodOptional<z.ZodNullable<z.ZodString>>;
478
+ }, z.core.$strip>;
479
+ id: z.ZodOptional<z.ZodString>;
480
+ slug: z.ZodOptional<z.ZodString>;
481
+ preferredEditor: z.ZodOptional<z.ZodString>;
482
+ local: z.ZodOptional<z.ZodObject<{
483
+ availableOffline: z.ZodOptional<z.ZodBoolean>;
484
+ sharingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
485
+ }, z.core.$strip>>;
486
+ }, z.core.$strip>;
487
+ };
488
+ readonly outputSchema: {
489
+ readonly driveId: z.ZodString;
490
+ };
491
+ } & {
492
+ callback: (args: {
493
+ driveInput: {
494
+ global: {
495
+ name: string;
496
+ icon?: string | null | undefined;
497
+ };
498
+ id?: string | undefined;
499
+ slug?: string | undefined;
500
+ preferredEditor?: string | undefined;
501
+ local?: {
502
+ availableOffline?: boolean | undefined;
503
+ sharingType?: string | null | undefined;
504
+ } | undefined;
505
+ };
506
+ }) => Promise<_modelcontextprotocol_sdk_types0.CallToolResult>;
507
+ };
508
+ readonly getDrive: {
509
+ readonly name: "getDrive";
510
+ readonly description: "Get a specific drive";
511
+ readonly inputSchema: {
512
+ readonly driveId: z.ZodString;
513
+ readonly options: z.ZodOptional<z.ZodObject<{
514
+ revisions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
515
+ checkHashes: z.ZodOptional<z.ZodBoolean>;
516
+ }, z.core.$strip>>;
517
+ };
518
+ readonly outputSchema: {
519
+ readonly drive: z.ZodUnknown;
520
+ };
521
+ } & {
522
+ callback: (args: {
523
+ driveId: string;
524
+ options?: {
525
+ revisions?: Record<string, number> | undefined;
526
+ checkHashes?: boolean | undefined;
527
+ } | undefined;
528
+ }) => Promise<_modelcontextprotocol_sdk_types0.CallToolResult>;
529
+ };
530
+ readonly deleteDrive: {
531
+ readonly name: "deleteDrive";
532
+ readonly description: "Delete a drive";
533
+ readonly inputSchema: {
534
+ readonly driveId: z.ZodString;
535
+ };
536
+ readonly outputSchema: {
537
+ readonly success: z.ZodBoolean;
538
+ };
539
+ } & {
540
+ callback: (args: {
541
+ driveId: string;
542
+ }) => Promise<_modelcontextprotocol_sdk_types0.CallToolResult>;
543
+ };
544
+ readonly addRemoteDrive: {
545
+ readonly name: "addRemoteDrive";
546
+ readonly description: "Connect to a remote drive";
547
+ readonly inputSchema: {
548
+ readonly url: z.ZodString;
549
+ readonly options: z.ZodObject<{
550
+ availableOffline: z.ZodBoolean;
551
+ sharingType: z.ZodOptional<z.ZodNullable<z.ZodString>>;
552
+ pullFilter: z.ZodOptional<z.ZodObject<{
553
+ branch: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
554
+ documentId: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
555
+ documentType: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
556
+ scope: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
557
+ }, z.core.$strip>>;
558
+ pullInterval: z.ZodOptional<z.ZodNumber>;
559
+ }, z.core.$strip>;
560
+ };
561
+ readonly outputSchema: {
562
+ readonly driveId: z.ZodString;
563
+ };
564
+ } & {
565
+ callback: (args: {
566
+ url: string;
567
+ options: {
568
+ availableOffline: boolean;
569
+ sharingType?: string | null | undefined;
570
+ pullFilter?: {
571
+ branch?: string[] | null | undefined;
572
+ documentId?: string[] | null | undefined;
573
+ documentType?: string[] | null | undefined;
574
+ scope?: string[] | null | undefined;
575
+ } | undefined;
576
+ pullInterval?: number | undefined;
577
+ };
578
+ }) => Promise<_modelcontextprotocol_sdk_types0.CallToolResult>;
579
+ };
580
+ readonly getDocumentModels: {
581
+ readonly name: "getDocumentModels";
582
+ readonly description: "Get the list of document models";
583
+ readonly inputSchema: {};
584
+ readonly outputSchema: {
585
+ readonly documentModels: z.ZodArray<z.ZodObject<{
586
+ name: z.ZodString;
587
+ type: z.ZodString;
588
+ description: z.ZodString;
589
+ extension: z.ZodString;
590
+ authorName: z.ZodString;
591
+ authorWebsite: z.ZodString;
592
+ }, z.core.$strip>>;
593
+ };
594
+ } & {
595
+ callback: (args: Record<string, never>) => Promise<_modelcontextprotocol_sdk_types0.CallToolResult>;
596
+ };
597
+ readonly getDocumentModelSchema: {
598
+ readonly name: "getDocumentModelSchema";
599
+ readonly description: "Get the schema of a document model";
600
+ readonly inputSchema: {
601
+ readonly type: z.ZodString;
602
+ };
603
+ readonly outputSchema: {
604
+ readonly schema: z.ZodUnknown;
605
+ };
606
+ } & {
607
+ callback: (args: {
608
+ type: string;
609
+ }) => Promise<_modelcontextprotocol_sdk_types0.CallToolResult>;
610
+ };
611
+ };
612
+ readonly resources: {};
613
+ readonly prompts: {};
614
+ }>;
615
+ //#endregion
616
+ //#region src/tools/utils.d.ts
617
+ declare class InvalidToolOutputError extends Error {
618
+ constructor(zodError: z.ZodError);
619
+ }
620
+ /**
621
+ * Creates a tool with a callback function that handles the tool execution,
622
+ * ensuring the output is valid and errors are handled and returned correctly.
623
+ * @param tool The tool schema to wrap.
624
+ * @param toolCallback The callback function to execute when the tool is called.
625
+ * @returns A CallToolResult with structuredContent if OutputSchema is defined or content if undefined. If the
626
+ * callback throws an error, the result will have isError set to true and the error message in the content.
627
+ */
628
+ declare function toolWithCallback<T extends ToolSchema>(tool: T, toolCallback: (args: ResolveZodSchema<T["inputSchema"]>) => ResolveZodSchema<T["outputSchema"]> | Promise<ResolveZodSchema<T["outputSchema"]>>): T & {
629
+ callback: (args: ResolveZodSchema<T["inputSchema"]>) => Promise<CallToolResult>;
630
+ };
631
+ declare function validateDocumentModelAction(documentModelModule: DocumentModelModule, action: Action): {
632
+ isValid: boolean;
633
+ errors: string[];
634
+ };
635
+ //#endregion
636
+ export { type CreateServerOptions, ExtractCallbackFromTool, IMcpProvider, InvalidToolOutputError, ReactorMcpProviderOptions, ReactorMcpTools, ResolveZodSchema, type SetupMcpServerOptions, ToolSchema, ToolWithCallback, addActionsTool, addDriveTool, addRemoteDriveTool, createDocumentTool, createReactorMcpProvider, createServer, deleteDocumentTool, deleteDriveTool, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, setupMcpServer, toolWithCallback, validateDocumentModelAction };
637
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/mcp-routes.ts","../src/server.ts","../src/tools/types.ts","../src/tools/reactor.ts","../src/tools/utils.ts"],"mappings":";;;;;;;;;;;UAKU,gBAAA;EACR,cAAA,CACE,MAAA,6BACA,IAAA,UACA,OAAA,GACE,GAAA,EAAK,eAAA,EACL,GAAA,EAAK,cAAA,EACL,IAAA,sBACU,OAAA;AAAA;AAAA,UAMC,qBAAA;EACf,MAAA,EAAQ,cAAA;EACR,WAAA,GAAc,YAAA;AAAA;;KA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCrVvB,sBAAA,SAA+B,KAAA;cAC9B,QAAA,EAAU,CAAA,CAAE,QAAA;AAAA;;;;AJTuC;;;;;iBIwBjD,gBAAA,WAA2B,UAAA,CAAA,CACzC,IAAA,EAAM,CAAA,EACN,YAAA,GACE,IAAA,EAAM,gBAAA,CAAiB,CAAA,qBAErB,gBAAA,CAAiB,CAAA,oBACjB,OAAA,CAAQ,gBAAA,CAAiB,CAAA,qBAAmB,CAAA;mBAGxC,gBAAA,CAAiB,CAAA,qBACtB,OAAA,CAAQ,cAAA;AAAA;AAAA,iBAgCG,2BAAA,CACd,mBAAA,EAAqB,mBAAA,EACrB,MAAA,EAAQ,MAAA;EACL,OAAA;EAAkB,MAAA;AAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1,46 @@
1
+ import { _ as validateDocumentModelAction, a as createDocumentTool, c as deleteDriveTool, d as getDocumentTool, f as getDocumentsTool, g as toolWithCallback, h as InvalidToolOutputError, i as addRemoteDriveTool, l as getDocumentModelSchemaTool, m as getDrivesTool, n as addActionsTool, o as createReactorMcpProvider, p as getDriveTool, r as addDriveTool, s as deleteDocumentTool, t as createServer, u as getDocumentModelsTool, v as logger } from "./server-B68G2N1-.mjs";
2
+ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
3
+ //#region src/mcp-routes.ts
4
+ const METHOD_NOT_ALLOWED = JSON.stringify({
5
+ jsonrpc: "2.0",
6
+ error: {
7
+ code: -32e3,
8
+ message: "Method not allowed."
9
+ },
10
+ id: null
11
+ });
12
+ const INTERNAL_SERVER_ERROR = JSON.stringify({
13
+ jsonrpc: "2.0",
14
+ error: {
15
+ code: -32603,
16
+ message: "Internal server error"
17
+ },
18
+ id: null
19
+ });
20
+ async function setupMcpServer(options, httpAdapter, createTransport = (opts) => new StreamableHTTPServerTransport(opts)) {
21
+ httpAdapter.mountNodeRoute("POST", "/mcp", async (req, res, body) => {
22
+ try {
23
+ const server = await createServer(options);
24
+ const transport = createTransport({ sessionIdGenerator: void 0 });
25
+ res.on("close", () => {
26
+ transport.close();
27
+ server.close();
28
+ });
29
+ await server.connect(transport);
30
+ await transport.handleRequest(req, res, body);
31
+ } catch (error) {
32
+ logger.error("Error handling MCP request:", error);
33
+ if (!res.headersSent) res.writeHead(500, { "Content-Type": "application/json" }).end(INTERNAL_SERVER_ERROR);
34
+ }
35
+ });
36
+ httpAdapter.mountNodeRoute("GET", "/mcp", (_req, res) => {
37
+ res.writeHead(405).end(METHOD_NOT_ALLOWED);
38
+ });
39
+ httpAdapter.mountNodeRoute("DELETE", "/mcp", (_req, res) => {
40
+ res.writeHead(405).end(METHOD_NOT_ALLOWED);
41
+ });
42
+ }
43
+ //#endregion
44
+ export { InvalidToolOutputError, addActionsTool, addDriveTool, addRemoteDriveTool, createDocumentTool, createReactorMcpProvider, createServer, deleteDocumentTool, deleteDriveTool, getDocumentModelSchemaTool, getDocumentModelsTool, getDocumentTool, getDocumentsTool, getDriveTool, getDrivesTool, setupMcpServer, toolWithCallback, validateDocumentModelAction };
45
+
46
+ //# sourceMappingURL=index.mjs.map