dodraw-mcp-server 0.1.4 → 0.1.5

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.
@@ -140,7 +140,7 @@ exports.toolDefinitions = [
140
140
  },
141
141
  {
142
142
  name: "add_directional_node",
143
- description: "Add a new node relative to an existing node and connect them. PRIMARY method for creating diagrams.",
143
+ description: "Add a new node relative to an existing node and connect them. PRIMARY method for creating diagrams, including Class and Database diagrams. Supports 'columns' for DB tables.",
144
144
  inputSchema: {
145
145
  type: "object",
146
146
  properties: {
@@ -154,14 +154,28 @@ exports.toolDefinitions = [
154
154
  color: { type: "string" },
155
155
  edgeLabel: { type: "string", description: "Optional label for the connecting edge" },
156
156
  attributes: { type: "array", items: { type: "string" }, description: "Optional list of attributes for Class nodes" },
157
- methods: { type: "array", items: { type: "string" }, description: "Optional list of methods for Class nodes" }
157
+ methods: { type: "array", items: { type: "string" }, description: "Optional list of methods for Class nodes" },
158
+ columns: {
159
+ type: "array",
160
+ description: "Optional list of columns for Table nodes",
161
+ items: {
162
+ type: "object",
163
+ properties: {
164
+ name: { type: "string" },
165
+ type: { type: "string" },
166
+ isPk: { type: "boolean" },
167
+ isFk: { type: "boolean" }
168
+ },
169
+ required: ["name", "type"]
170
+ }
171
+ }
158
172
  },
159
173
  required: ["filePath", "sourceNodeId", "direction", "label"]
160
174
  }
161
175
  },
162
176
  {
163
177
  name: "create_uml_class",
164
- description: "Create a UML Class node with methods and attributes",
178
+ description: "Create a UML Class node. Use this for the FIRST class. For connected classes, use 'add_directional_node' to ensure correct relative positioning.",
165
179
  inputSchema: {
166
180
  type: "object",
167
181
  properties: {
@@ -178,7 +192,7 @@ exports.toolDefinitions = [
178
192
  },
179
193
  {
180
194
  name: "create_db_table",
181
- description: "Create a Database Entity (ERD Table)",
195
+ description: "Create a Database Entity (ERD Table). Use this for the FIRST table. For connected tables, use 'add_directional_node' with 'columns' to ensure correct relative positioning.",
182
196
  inputSchema: {
183
197
  type: "object",
184
198
  properties: {
@@ -402,6 +416,14 @@ async function handleToolCall(name, args) {
402
416
  attributes: args.attributes || [],
403
417
  methods: args.methods || []
404
418
  } : undefined,
419
+ dbTableData: args.columns ? {
420
+ columns: args.columns.map((c) => ({
421
+ name: c.name,
422
+ type: c.type,
423
+ isPk: !!c.isPk,
424
+ isFk: !!c.isFk
425
+ }))
426
+ } : undefined,
405
427
  textAlignVertical: 'center',
406
428
  textAlignHorizontal: 'center'
407
429
  };
@@ -528,11 +550,19 @@ async function handleToolCall(name, args) {
528
550
  const methodCount = (args.methods || []).length;
529
551
  const estimatedHeight = 0.8 + (attrCount + methodCount) * 0.4;
530
552
  const height = Math.max(2, estimatedHeight);
553
+ // Auto-placement logic if X/Y not provided
554
+ let x = args.x !== undefined ? Number(args.x) : 0;
555
+ let z = args.y !== undefined ? Number(args.y) : 0;
556
+ if (args.x === undefined && args.y === undefined && state.nodes.length > 0) {
557
+ const lastNode = state.nodes[state.nodes.length - 1];
558
+ x = lastNode.x + 5;
559
+ z = lastNode.z;
560
+ }
531
561
  const newNode = {
532
562
  id: newNodeId,
533
- x: args.x ? Number(args.x) : 0,
563
+ x: x,
534
564
  y: 0,
535
- z: args.y ? Number(args.y) : 0,
565
+ z: z,
536
566
  width: width,
537
567
  height: height,
538
568
  label: args.className,
@@ -556,11 +586,19 @@ async function handleToolCall(name, args) {
556
586
  const estimatedHeight = 0.8 + cols.length * 0.4;
557
587
  const height = Math.max(2, estimatedHeight);
558
588
  const width = 3;
589
+ // Auto-placement logic if X/Y not provided
590
+ let x = args.x !== undefined ? Number(args.x) : 0;
591
+ let z = args.y !== undefined ? Number(args.y) : 0;
592
+ if (args.x === undefined && args.y === undefined && state.nodes.length > 0) {
593
+ const lastNode = state.nodes[state.nodes.length - 1];
594
+ x = lastNode.x + 5;
595
+ z = lastNode.z;
596
+ }
559
597
  const newNode = {
560
598
  id: newNodeId,
561
- x: args.x ? Number(args.x) : 0,
599
+ x: x,
562
600
  y: 0,
563
- z: args.y ? Number(args.y) : 0,
601
+ z: z,
564
602
  width: width,
565
603
  height: height,
566
604
  label: args.tableName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dodraw-mcp-server",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "MCP server for DoDraw",
5
5
  "main": "dist/src/index.js",
6
6
  "bin": {
@@ -140,7 +140,7 @@ export const toolDefinitions: Tool[] = [
140
140
  },
141
141
  {
142
142
  name: "add_directional_node",
143
- description: "Add a new node relative to an existing node and connect them. PRIMARY method for creating diagrams.",
143
+ description: "Add a new node relative to an existing node and connect them. PRIMARY method for creating diagrams, including Class and Database diagrams. Supports 'columns' for DB tables.",
144
144
  inputSchema: {
145
145
  type: "object",
146
146
  properties: {
@@ -154,14 +154,28 @@ export const toolDefinitions: Tool[] = [
154
154
  color: { type: "string" },
155
155
  edgeLabel: { type: "string", description: "Optional label for the connecting edge" },
156
156
  attributes: { type: "array", items: { type: "string" }, description: "Optional list of attributes for Class nodes" },
157
- methods: { type: "array", items: { type: "string" }, description: "Optional list of methods for Class nodes" }
157
+ methods: { type: "array", items: { type: "string" }, description: "Optional list of methods for Class nodes" },
158
+ columns: {
159
+ type: "array",
160
+ description: "Optional list of columns for Table nodes",
161
+ items: {
162
+ type: "object",
163
+ properties: {
164
+ name: { type: "string" },
165
+ type: { type: "string" },
166
+ isPk: { type: "boolean" },
167
+ isFk: { type: "boolean" }
168
+ },
169
+ required: ["name", "type"]
170
+ }
171
+ }
158
172
  },
159
173
  required: ["filePath", "sourceNodeId", "direction", "label"]
160
174
  }
161
175
  },
162
176
  {
163
177
  name: "create_uml_class",
164
- description: "Create a UML Class node with methods and attributes",
178
+ description: "Create a UML Class node. Use this for the FIRST class. For connected classes, use 'add_directional_node' to ensure correct relative positioning.",
165
179
  inputSchema: {
166
180
  type: "object",
167
181
  properties: {
@@ -178,7 +192,7 @@ export const toolDefinitions: Tool[] = [
178
192
  },
179
193
  {
180
194
  name: "create_db_table",
181
- description: "Create a Database Entity (ERD Table)",
195
+ description: "Create a Database Entity (ERD Table). Use this for the FIRST table. For connected tables, use 'add_directional_node' with 'columns' to ensure correct relative positioning.",
182
196
  inputSchema: {
183
197
  type: "object",
184
198
  properties: {
@@ -417,6 +431,14 @@ export async function handleToolCall(name: string, args: any): Promise<any> {
417
431
  attributes: args.attributes || [],
418
432
  methods: args.methods || []
419
433
  } : undefined,
434
+ dbTableData: args.columns ? {
435
+ columns: args.columns.map((c: any) => ({
436
+ name: c.name,
437
+ type: c.type,
438
+ isPk: !!c.isPk,
439
+ isFk: !!c.isFk
440
+ }))
441
+ } : undefined,
420
442
  textAlignVertical: 'center',
421
443
  textAlignHorizontal: 'center'
422
444
  };
@@ -544,11 +566,21 @@ export async function handleToolCall(name: string, args: any): Promise<any> {
544
566
  const estimatedHeight = 0.8 + (attrCount + methodCount) * 0.4;
545
567
  const height = Math.max(2, estimatedHeight);
546
568
 
569
+ // Auto-placement logic if X/Y not provided
570
+ let x = args.x !== undefined ? Number(args.x) : 0;
571
+ let z = args.y !== undefined ? Number(args.y) : 0;
572
+
573
+ if (args.x === undefined && args.y === undefined && state.nodes.length > 0) {
574
+ const lastNode = state.nodes[state.nodes.length - 1];
575
+ x = lastNode.x + 5;
576
+ z = lastNode.z;
577
+ }
578
+
547
579
  const newNode: NodeData = {
548
580
  id: newNodeId,
549
- x: args.x ? Number(args.x) : 0,
581
+ x: x,
550
582
  y: 0,
551
- z: args.y ? Number(args.y) : 0,
583
+ z: z,
552
584
  width: width,
553
585
  height: height,
554
586
  label: args.className,
@@ -573,13 +605,24 @@ export async function handleToolCall(name: string, args: any): Promise<any> {
573
605
  // Header + items
574
606
  const estimatedHeight = 0.8 + cols.length * 0.4;
575
607
  const height = Math.max(2, estimatedHeight);
608
+
576
609
  const width = 3;
577
610
 
611
+ // Auto-placement logic if X/Y not provided
612
+ let x = args.x !== undefined ? Number(args.x) : 0;
613
+ let z = args.y !== undefined ? Number(args.y) : 0;
614
+
615
+ if (args.x === undefined && args.y === undefined && state.nodes.length > 0) {
616
+ const lastNode = state.nodes[state.nodes.length - 1];
617
+ x = lastNode.x + 5;
618
+ z = lastNode.z;
619
+ }
620
+
578
621
  const newNode: NodeData = {
579
622
  id: newNodeId,
580
- x: args.x ? Number(args.x) : 0,
623
+ x: x,
581
624
  y: 0,
582
- z: args.y ? Number(args.y) : 0,
625
+ z: z,
583
626
  width: width,
584
627
  height: height,
585
628
  label: args.tableName,