@eraserlabs/eraser-mcp 0.1.1 → 0.3.1-next.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 (37) hide show
  1. package/dist/descriptions/bpmn.d.ts +2 -0
  2. package/dist/descriptions/bpmn.d.ts.map +1 -0
  3. package/dist/descriptions/bpmn.js +42 -0
  4. package/dist/descriptions/cloudArchitecture.d.ts +2 -0
  5. package/dist/descriptions/cloudArchitecture.d.ts.map +1 -0
  6. package/dist/descriptions/cloudArchitecture.js +39 -0
  7. package/dist/descriptions/erd.d.ts +2 -0
  8. package/dist/descriptions/erd.d.ts.map +1 -0
  9. package/dist/descriptions/erd.js +44 -0
  10. package/dist/descriptions/flowchart.d.ts +2 -0
  11. package/dist/descriptions/flowchart.d.ts.map +1 -0
  12. package/dist/descriptions/flowchart.js +37 -0
  13. package/dist/descriptions/sequenceDiagram.d.ts +2 -0
  14. package/dist/descriptions/sequenceDiagram.d.ts.map +1 -0
  15. package/dist/descriptions/sequenceDiagram.js +26 -0
  16. package/dist/descriptions/tools.d.ts +4 -0
  17. package/dist/descriptions/tools.d.ts.map +1 -0
  18. package/dist/descriptions/tools.js +6 -0
  19. package/dist/schemas/createFile.d.ts +39 -0
  20. package/dist/schemas/createFile.d.ts.map +1 -0
  21. package/dist/schemas/createFile.js +21 -0
  22. package/dist/schemas/renderElements.d.ts +124 -0
  23. package/dist/schemas/renderElements.d.ts.map +1 -0
  24. package/dist/schemas/renderElements.js +10 -0
  25. package/dist/schemas/renderPrompt.d.ts +115 -0
  26. package/dist/schemas/renderPrompt.d.ts.map +1 -0
  27. package/dist/schemas/renderPrompt.js +16 -0
  28. package/dist/schemas/shared.d.ts +128 -0
  29. package/dist/schemas/shared.d.ts.map +1 -0
  30. package/dist/schemas/shared.js +68 -0
  31. package/dist/schemas/singleDiagram.d.ts +70 -0
  32. package/dist/schemas/singleDiagram.d.ts.map +1 -0
  33. package/dist/schemas/singleDiagram.js +8 -0
  34. package/dist/tools.d.ts +10 -293
  35. package/dist/tools.d.ts.map +1 -1
  36. package/dist/tools.js +47 -394
  37. package/package.json +3 -2
package/dist/tools.js CHANGED
@@ -1,415 +1,68 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isSingleDiagramTool = exports.singleDiagramTools = exports.mcpToolMap = exports.isMcpToolName = exports.mcpTools = exports.DiagramTypes = exports.directionSettings = exports.typefaceSettings = exports.styleModeSettings = exports.colorModeSettings = void 0;
4
- const zod_1 = require("zod");
5
- /**
6
- * Settings duplicated from @eraserlabs/shared/modules/diagram-parser/settings
7
- * We avoid importing to keep eraser-mcp buildable independently.
8
- */
9
- exports.colorModeSettings = ['pastel', 'bold', 'outline'];
10
- exports.styleModeSettings = ['plain', 'shadow', 'watercolor'];
11
- exports.typefaceSettings = ['rough', 'clean', 'mono'];
12
- exports.directionSettings = ['up', 'down', 'left', 'right'];
13
- /**
14
- * The diagram types supported by the MCP tools.
15
- * Duplicated from DiagramTypes enum, excluding 'custom-diagram'.
16
- */
17
- var DiagramTypes;
18
- (function (DiagramTypes) {
19
- DiagramTypes["SD"] = "sequence-diagram";
20
- DiagramTypes["ERD"] = "entity-relationship-diagram";
21
- DiagramTypes["CAD"] = "cloud-architecture-diagram";
22
- DiagramTypes["FLOW"] = "flowchart-diagram";
23
- DiagramTypes["BPMN"] = "bpmn-diagram";
24
- })(DiagramTypes = exports.DiagramTypes || (exports.DiagramTypes = {}));
25
- const diagramElementSchema = zod_1.z.object({
26
- type: zod_1.z.literal('diagram'),
27
- diagramType: zod_1.z.nativeEnum(DiagramTypes),
28
- code: zod_1.z.string(),
29
- x: zod_1.z.number().optional(),
30
- y: zod_1.z.number().optional(),
31
- });
32
- const renderOptionsSchema = zod_1.z
33
- .object({
34
- padding: zod_1.z.number().optional(),
35
- scale: zod_1.z.union([zod_1.z.literal(1), zod_1.z.literal(2), zod_1.z.literal(3)]).optional(),
36
- background: zod_1.z.boolean().optional(),
37
- theme: zod_1.z.enum(['light', 'dark']).optional(),
38
- format: zod_1.z.enum(['png', 'jpeg']).optional(),
39
- selection: zod_1.z.array(zod_1.z.string()).optional(),
40
- ignoreElements: zod_1.z.array(zod_1.z.string()).optional(),
41
- limitToSelection: zod_1.z.boolean().optional(),
42
- customIcons: zod_1.z.array(zod_1.z.unknown()).optional(),
43
- typeface: zod_1.z.enum(exports.typefaceSettings).optional(),
44
- colorMode: zod_1.z.enum(exports.colorModeSettings).optional(),
45
- styleMode: zod_1.z.enum(exports.styleModeSettings).optional(),
46
- direction: zod_1.z.enum(exports.directionSettings).optional(),
47
- title: zod_1.z.string().optional(),
48
- })
49
- .passthrough();
50
- const renderPromptSchema = renderOptionsSchema
51
- .extend({
52
- text: zod_1.z.string(),
53
- returnFile: zod_1.z.boolean().optional(),
54
- diagramType: zod_1.z.string().optional(),
55
- mode: zod_1.z.string().optional(),
56
- priorRequestId: zod_1.z.string().optional(),
57
- attachments: zod_1.z.array(zod_1.z.unknown()).optional(),
58
- contextId: zod_1.z.string().optional(),
59
- git: zod_1.z.unknown().optional(),
60
- fileOptions: zod_1.z
61
- .object({
62
- create: zod_1.z.boolean().optional(),
63
- linkAccess: zod_1.z
64
- .enum([
65
- 'no-link-access',
66
- 'anyone-with-link-can-edit',
67
- 'publicly-viewable',
68
- 'publicly-editable',
69
- ])
70
- .optional(),
71
- })
72
- .optional(),
73
- })
74
- .passthrough();
75
- const renderElementsSchema = renderOptionsSchema
76
- .extend({
77
- elements: zod_1.z.array(diagramElementSchema),
78
- returnFile: zod_1.z.boolean().optional(),
79
- fileName: zod_1.z.string().optional(),
80
- teamId: zod_1.z.string().optional(),
81
- returnElements: zod_1.z.boolean().optional(),
82
- skipCache: zod_1.z.boolean().optional(),
83
- })
84
- .passthrough();
85
- // Schema for individual diagram type tools
86
- const singleDiagramSchema = zod_1.z.object({
87
- code: zod_1.z.string(),
88
- theme: zod_1.z.enum(['light', 'dark']).optional(),
89
- colorMode: zod_1.z.enum(exports.colorModeSettings).optional(),
90
- styleMode: zod_1.z.enum(exports.styleModeSettings).optional(),
91
- typeface: zod_1.z.enum(exports.typefaceSettings).optional(),
92
- background: zod_1.z.boolean().optional(),
93
- });
94
- const renderPromptJsonSchema = {
95
- type: 'object',
96
- additionalProperties: true,
97
- required: ['text'],
98
- properties: {
99
- text: { type: 'string' },
100
- returnFile: { type: 'boolean' },
101
- diagramType: { type: 'string' },
102
- mode: { type: 'string' },
103
- priorRequestId: { type: 'string' },
104
- attachments: { type: 'array', items: {} },
105
- contextId: { type: 'string' },
106
- git: {},
107
- fileOptions: {
108
- type: 'object',
109
- additionalProperties: false,
110
- properties: {
111
- create: { type: 'boolean' },
112
- linkAccess: {
113
- type: 'string',
114
- enum: [
115
- 'no-link-access',
116
- 'anyone-with-link-can-edit',
117
- 'publicly-viewable',
118
- 'publicly-editable',
119
- ],
120
- },
121
- },
122
- },
123
- padding: { type: 'number' },
124
- scale: { type: 'number', enum: [1, 2, 3] },
125
- background: { type: 'boolean' },
126
- theme: { type: 'string', enum: ['light', 'dark'] },
127
- format: { type: 'string', enum: ['png', 'jpeg'] },
128
- selection: { type: 'array', items: { type: 'string' } },
129
- typeface: { type: 'string', enum: [...exports.typefaceSettings] },
130
- colorMode: { type: 'string', enum: [...exports.colorModeSettings] },
131
- styleMode: { type: 'string', enum: [...exports.styleModeSettings] },
132
- direction: { type: 'string', enum: [...exports.directionSettings] },
133
- title: { type: 'string' },
134
- },
135
- };
136
- const renderElementsJsonSchema = {
137
- type: 'object',
138
- additionalProperties: true,
139
- required: ['elements'],
140
- properties: {
141
- elements: {
142
- type: 'array',
143
- items: {
144
- type: 'object',
145
- required: ['type', 'diagramType', 'code'],
146
- properties: {
147
- type: { type: 'string', const: 'diagram' },
148
- diagramType: {
149
- type: 'string',
150
- enum: Object.values(DiagramTypes),
151
- },
152
- code: { type: 'string' },
153
- },
154
- },
155
- },
156
- fileName: { type: 'string' },
157
- teamId: { type: 'string' },
158
- returnElements: { type: 'boolean' },
159
- skipCache: { type: 'boolean' },
160
- padding: { type: 'number' },
161
- scale: { type: 'number', enum: [1, 2, 3] },
162
- background: { type: 'boolean' },
163
- theme: { type: 'string', enum: ['light', 'dark'] },
164
- format: { type: 'string', enum: ['png', 'jpeg'] },
165
- typeface: { type: 'string', enum: [...exports.typefaceSettings] },
166
- colorMode: { type: 'string', enum: [...exports.colorModeSettings] },
167
- styleMode: { type: 'string', enum: [...exports.styleModeSettings] },
168
- direction: { type: 'string', enum: [...exports.directionSettings] },
169
- },
170
- };
171
- const singleDiagramJsonSchema = {
172
- type: 'object',
173
- required: ['code'],
174
- properties: {
175
- code: { type: 'string', description: 'The diagram code in Eraser syntax' },
176
- theme: { type: 'string', enum: ['light', 'dark'] },
177
- colorMode: { type: 'string', enum: [...exports.colorModeSettings] },
178
- styleMode: { type: 'string', enum: [...exports.styleModeSettings] },
179
- typeface: { type: 'string', enum: [...exports.typefaceSettings] },
180
- background: { type: 'boolean', description: 'Whether to include a solid background' },
181
- },
182
- };
183
- // Diagram type descriptions with syntax examples
184
- const SEQUENCE_DIAGRAM_DESCRIPTION = `Render a sequence diagram. Use Eraser's sequence diagram syntax.
185
-
186
- Example syntax:
187
- \`\`\`
188
- title Authentication Flow
189
-
190
- // Define actors with icons
191
- User [icon: user]
192
- Browser [icon: globe]
193
- Server [icon: server]
194
- Database [icon: database]
195
-
196
- // Messages between actors
197
- User > Browser: Enter credentials
198
- Browser > Server: POST /login
199
- Server > Database: Query user
200
- Database > Server: User data
201
- Server > Browser: JWT token
202
- Browser > User: Login success
203
-
204
- // Control flow
205
- alt [label: "Valid credentials"] {
206
- Server > Browser: 200 OK
207
- }
208
- else [label: "Invalid"] {
209
- Server > Browser: 401 Unauthorized
210
- }
211
-
212
- // Activation bars
213
- activate Server
214
- Server > Database: Query
215
- deactivate Server
216
-
217
- // Loops
218
- loop [label: "Retry 3 times"] {
219
- Browser > Server: Request
220
- }
221
- \`\`\``;
222
- const ERD_DESCRIPTION = `Render an entity-relationship diagram. Use Eraser's ERD syntax.
223
-
224
- Example syntax:
225
- \`\`\`
226
- title E-commerce Database
227
-
228
- // Define tables with columns
229
- users [icon: user, color: blue] {
230
- id int pk
231
- email string
232
- name string
233
- created_at timestamp
234
- }
235
-
236
- orders [icon: shopping-cart, color: green] {
237
- id int pk
238
- user_id int
239
- total decimal
240
- status string
241
- created_at timestamp
242
- }
243
-
244
- products [icon: box, color: orange] {
245
- id int pk
246
- name string
247
- price decimal
248
- stock int
249
- }
250
-
251
- order_items [icon: list] {
252
- order_id int pk
253
- product_id int pk
254
- quantity int
255
- price decimal
256
- }
257
-
258
- // Relationships
259
- users.id < orders.user_id
260
- orders.id < order_items.order_id
261
- products.id < order_items.product_id
262
- \`\`\``;
263
- const CLOUD_ARCHITECTURE_DESCRIPTION = `Render a cloud architecture diagram. Use Eraser's cloud architecture syntax.
264
-
265
- Example syntax:
266
- \`\`\`
267
- title AWS Microservices Architecture
268
-
269
- // Groups with cloud provider icons
270
- AWS Cloud [icon: aws] {
271
- VPC [icon: aws-vpc] {
272
- Public Subnet {
273
- ALB [icon: aws-elb]
274
- NAT Gateway [icon: aws-nat-gateway]
275
- }
276
- Private Subnet {
277
- ECS Cluster [icon: aws-ecs] {
278
- API Service [icon: aws-lambda]
279
- Worker Service [icon: aws-lambda]
280
- }
281
- RDS [icon: aws-rds]
282
- ElastiCache [icon: aws-elasticache]
283
- }
284
- }
285
- S3 [icon: aws-s3]
286
- CloudFront [icon: aws-cloudfront]
287
- }
288
-
289
- Users [icon: users]
290
-
291
- // Connections
292
- Users > CloudFront
293
- CloudFront > ALB
294
- ALB > API Service
295
- API Service > RDS
296
- API Service > ElastiCache
297
- Worker Service > S3
298
- \`\`\``;
299
- const FLOWCHART_DESCRIPTION = `Render a flowchart diagram. Use Eraser's flowchart syntax.
300
-
301
- Example syntax:
302
- \`\`\`
303
- title User Registration Flow
304
-
305
- // Nodes with shapes and icons
306
- Start [shape: oval, icon: play]
307
- Enter Details [icon: edit]
308
- Valid Email? [shape: diamond, icon: help-circle]
309
- Send Verification [icon: mail]
310
- Email Verified? [shape: diamond]
311
- Create Account [icon: user-plus, color: green]
312
- Show Error [icon: alert-triangle, color: red]
313
- End [shape: oval, icon: check]
314
-
315
- // Groups
316
- Validation [color: blue] {
317
- Check Password Strength [icon: lock]
318
- Password OK? [shape: diamond]
319
- }
320
-
321
- // Connections with labels
322
- Start > Enter Details
323
- Enter Details > Valid Email?
324
- Valid Email? > Send Verification: Yes
325
- Valid Email? > Show Error: No
326
- Send Verification > Email Verified?
327
- Email Verified? > Create Account: Yes
328
- Email Verified? > Show Error: No
329
- Create Account > End
330
- Show Error > Enter Details
331
- \`\`\``;
332
- const BPMN_DESCRIPTION = `Render a BPMN (Business Process Model and Notation) diagram. Use Eraser's BPMN syntax.
333
-
334
- Example syntax:
335
- \`\`\`
336
- title Order Fulfillment Process
337
-
338
- // Swimlanes (pools)
339
- Customer [color: blue] {
340
- Place Order [type: event, icon: shopping-cart]
341
- Receive Confirmation [type: event, icon: mail]
342
- Receive Package [type: event, icon: package]
343
- }
344
-
345
- Sales [color: green] {
346
- Process Order [icon: clipboard]
347
- Check Inventory [icon: database]
348
- In Stock? [type: gateway, icon: help-circle]
349
- Create Backorder [icon: clock]
350
- Confirm Order [icon: check]
351
- }
352
-
353
- Warehouse [color: orange] {
354
- Pick Items [icon: box]
355
- Pack Order [icon: package]
356
- Ship Order [icon: truck]
357
- }
358
-
359
- // Flow connections (use --> for message flows between pools)
360
- Place Order --> Process Order: Order details
361
- Process Order > Check Inventory
362
- Check Inventory > In Stock?
363
- In Stock? > Confirm Order: Yes
364
- In Stock? > Create Backorder: No
365
- Confirm Order --> Receive Confirmation: Confirmation email
366
- Confirm Order > Pick Items
367
- Pick Items > Pack Order
368
- Pack Order > Ship Order
369
- Ship Order --> Receive Package: Delivery
370
- \`\`\``;
3
+ exports.DiagramTypes = exports.isSingleDiagramTool = exports.singleDiagramTools = exports.mcpToolMap = exports.isMcpToolName = exports.mcpTools = void 0;
4
+ // Schemas
5
+ const shared_1 = require("./schemas/shared");
6
+ Object.defineProperty(exports, "DiagramTypes", { enumerable: true, get: function () { return shared_1.DiagramTypes; } });
7
+ const createFile_1 = require("./schemas/createFile");
8
+ const renderPrompt_1 = require("./schemas/renderPrompt");
9
+ const renderElements_1 = require("./schemas/renderElements");
10
+ const singleDiagram_1 = require("./schemas/singleDiagram");
11
+ // Descriptions
12
+ const tools_1 = require("./descriptions/tools");
13
+ const sequenceDiagram_1 = require("./descriptions/sequenceDiagram");
14
+ const erd_1 = require("./descriptions/erd");
15
+ const cloudArchitecture_1 = require("./descriptions/cloudArchitecture");
16
+ const flowchart_1 = require("./descriptions/flowchart");
17
+ const bpmn_1 = require("./descriptions/bpmn");
371
18
  exports.mcpTools = [
19
+ {
20
+ name: 'createFile',
21
+ description: tools_1.CREATE_FILE_DESCRIPTION,
22
+ schema: createFile_1.createFileSchema,
23
+ jsonSchema: (0, shared_1.toJsonSchema)(createFile_1.createFileSchema),
24
+ },
372
25
  {
373
26
  name: 'renderPrompt',
374
- description: 'Generate a diagram using AI from a natural language prompt, existing code, infrastructure configuration, or other diagram languages. Best for when you want AI to create the diagram code for you.',
375
- schema: renderPromptSchema,
376
- jsonSchema: renderPromptJsonSchema,
27
+ description: tools_1.RENDER_PROMPT_DESCRIPTION,
28
+ schema: renderPrompt_1.renderPromptSchema,
29
+ jsonSchema: (0, shared_1.toJsonSchema)(renderPrompt_1.renderPromptSchema),
377
30
  },
378
31
  {
379
32
  name: 'renderElements',
380
- description: 'Render multiple diagram elements. Advanced use case for rendering multiple diagrams at once.',
381
- schema: renderElementsSchema,
382
- jsonSchema: renderElementsJsonSchema,
33
+ description: tools_1.RENDER_ELEMENTS_DESCRIPTION,
34
+ schema: renderElements_1.renderElementsSchema,
35
+ jsonSchema: (0, shared_1.toJsonSchema)(renderElements_1.renderElementsSchema),
383
36
  },
384
37
  {
385
38
  name: 'renderSequenceDiagram',
386
- description: SEQUENCE_DIAGRAM_DESCRIPTION,
387
- schema: singleDiagramSchema,
388
- jsonSchema: singleDiagramJsonSchema,
39
+ description: sequenceDiagram_1.SEQUENCE_DIAGRAM_DESCRIPTION,
40
+ schema: singleDiagram_1.singleDiagramSchema,
41
+ jsonSchema: (0, shared_1.toJsonSchema)(singleDiagram_1.singleDiagramSchema),
389
42
  },
390
43
  {
391
44
  name: 'renderEntityRelationshipDiagram',
392
- description: ERD_DESCRIPTION,
393
- schema: singleDiagramSchema,
394
- jsonSchema: singleDiagramJsonSchema,
45
+ description: erd_1.ERD_DESCRIPTION,
46
+ schema: singleDiagram_1.singleDiagramSchema,
47
+ jsonSchema: (0, shared_1.toJsonSchema)(singleDiagram_1.singleDiagramSchema),
395
48
  },
396
49
  {
397
50
  name: 'renderCloudArchitectureDiagram',
398
- description: CLOUD_ARCHITECTURE_DESCRIPTION,
399
- schema: singleDiagramSchema,
400
- jsonSchema: singleDiagramJsonSchema,
51
+ description: cloudArchitecture_1.CLOUD_ARCHITECTURE_DESCRIPTION,
52
+ schema: singleDiagram_1.singleDiagramSchema,
53
+ jsonSchema: (0, shared_1.toJsonSchema)(singleDiagram_1.singleDiagramSchema),
401
54
  },
402
55
  {
403
56
  name: 'renderFlowchart',
404
- description: FLOWCHART_DESCRIPTION,
405
- schema: singleDiagramSchema,
406
- jsonSchema: singleDiagramJsonSchema,
57
+ description: flowchart_1.FLOWCHART_DESCRIPTION,
58
+ schema: singleDiagram_1.singleDiagramSchema,
59
+ jsonSchema: (0, shared_1.toJsonSchema)(singleDiagram_1.singleDiagramSchema),
407
60
  },
408
61
  {
409
62
  name: 'renderBpmnDiagram',
410
- description: BPMN_DESCRIPTION,
411
- schema: singleDiagramSchema,
412
- jsonSchema: singleDiagramJsonSchema,
63
+ description: bpmn_1.BPMN_DESCRIPTION,
64
+ schema: singleDiagram_1.singleDiagramSchema,
65
+ jsonSchema: (0, shared_1.toJsonSchema)(singleDiagram_1.singleDiagramSchema),
413
66
  },
414
67
  ];
415
68
  function isMcpToolName(name) {
@@ -419,11 +72,11 @@ exports.isMcpToolName = isMcpToolName;
419
72
  exports.mcpToolMap = new Map(exports.mcpTools.map((tool) => [tool.name, tool]));
420
73
  // Mapping from single diagram tool names to their diagram types
421
74
  exports.singleDiagramTools = {
422
- renderSequenceDiagram: DiagramTypes.SD,
423
- renderEntityRelationshipDiagram: DiagramTypes.ERD,
424
- renderCloudArchitectureDiagram: DiagramTypes.CAD,
425
- renderFlowchart: DiagramTypes.FLOW,
426
- renderBpmnDiagram: DiagramTypes.BPMN,
75
+ renderSequenceDiagram: shared_1.DiagramTypes.SD,
76
+ renderEntityRelationshipDiagram: shared_1.DiagramTypes.ERD,
77
+ renderCloudArchitectureDiagram: shared_1.DiagramTypes.CAD,
78
+ renderFlowchart: shared_1.DiagramTypes.FLOW,
79
+ renderBpmnDiagram: shared_1.DiagramTypes.BPMN,
427
80
  };
428
81
  function isSingleDiagramTool(name) {
429
82
  return name in exports.singleDiagramTools;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eraserlabs/eraser-mcp",
3
- "version": "0.1.1",
3
+ "version": "0.3.1-next.0",
4
4
  "description": "MCP server for generating diagrams with Eraser.io",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -29,7 +29,8 @@
29
29
  },
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
- "zod": "^3.25.76"
32
+ "zod": "^3.25.76",
33
+ "zod-to-json-schema": "^3.24.5"
33
34
  },
34
35
  "devDependencies": {
35
36
  "@types/node": "^20.0.0",