@mentagen/mcp 0.5.0 → 0.7.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.
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { NodeType } from '../client/types.js';
3
3
  import { formatError } from '../utils/errors.js';
4
+ import { pixelsToUnits, unitsToPixels } from '../utils/units.js';
4
5
  import { snapToGrid } from './grid-calc.js';
5
6
  import { calculateNodeSize } from './size-calc.js';
6
7
  export const updateSchema = z.object({
@@ -24,22 +25,10 @@ export const updateSchema = z.object({
24
25
  .string()
25
26
  .optional()
26
27
  .describe('Node color name (use mentagen_colors to see available colors)'),
27
- x: z
28
- .number()
29
- .optional()
30
- .describe('X position on the board canvas (must be multiple of 16)'),
31
- y: z
32
- .number()
33
- .optional()
34
- .describe('Y position on the board canvas (must be multiple of 16)'),
35
- width: z
36
- .number()
37
- .optional()
38
- .describe('Node width in pixels (must be multiple of 16)'),
39
- height: z
40
- .number()
41
- .optional()
42
- .describe('Node height in pixels (must be multiple of 16)'),
28
+ x: z.number().optional().describe('X position in grid units'),
29
+ y: z.number().optional().describe('Y position in grid units'),
30
+ width: z.number().optional().describe('Node width in grid units'),
31
+ height: z.number().optional().describe('Node height in grid units'),
43
32
  autoSize: z
44
33
  .boolean()
45
34
  .optional()
@@ -85,7 +74,7 @@ function buildUpdateData(params, nodeType) {
85
74
  for (const field of POSITION_FIELDS) {
86
75
  const value = params[field];
87
76
  if (value !== undefined) {
88
- data[field] = snapToGrid(value);
77
+ data[field] = snapToGrid(unitsToPixels(value));
89
78
  }
90
79
  }
91
80
  return Object.keys(data).length > 0 ? data : null;
@@ -116,10 +105,10 @@ function formatSuccessResponse(node) {
116
105
  node: {
117
106
  id: node._id,
118
107
  name: node.name,
119
- x: node.x,
120
- y: node.y,
121
- width: node.width,
122
- height: node.height,
108
+ x: pixelsToUnits(node.x),
109
+ y: pixelsToUnits(node.y),
110
+ width: pixelsToUnits(node.width),
111
+ height: pixelsToUnits(node.height),
123
112
  updatedAt: node.updatedAt || new Date().toISOString(),
124
113
  },
125
114
  };
@@ -132,8 +121,17 @@ export async function handleUpdate(client, params) {
132
121
  const { node: currentNode, autoSize } = await getNodeContext(client, params);
133
122
  const data = buildUpdateData({
134
123
  ...params,
135
- width: params.width ?? autoSize?.width,
136
- height: params.height ?? autoSize?.height,
124
+ // Convert autoSize from pixels to units since buildUpdateData expects units
125
+ width: params.width !== undefined
126
+ ? params.width
127
+ : autoSize?.width !== undefined
128
+ ? pixelsToUnits(autoSize.width)
129
+ : undefined,
130
+ height: params.height !== undefined
131
+ ? params.height
132
+ : autoSize?.height !== undefined
133
+ ? pixelsToUnits(autoSize.height)
134
+ : undefined,
137
135
  }, currentNode.type);
138
136
  if (!data) {
139
137
  return {
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Unit conversion utilities for grid-based positioning.
3
+ * 1 grid unit = 16 pixels
4
+ */
5
+ const GRID_SIZE = 16;
6
+ /**
7
+ * Convert grid units to pixels.
8
+ * Rounds the input to the nearest integer before conversion.
9
+ */
10
+ export function unitsToPixels(units) {
11
+ return Math.round(units) * GRID_SIZE;
12
+ }
13
+ /**
14
+ * Convert pixels to grid units.
15
+ * Rounds the result to the nearest integer unit.
16
+ */
17
+ export function pixelsToUnits(pixels) {
18
+ return Math.round(pixels / GRID_SIZE);
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mentagen/mcp",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "MCP server for Mentagen knowledge base integration with Cursor",
5
5
  "type": "module",
6
6
  "bin": "dist/index.js",
@@ -45,6 +45,6 @@
45
45
  "node": ">=18"
46
46
  },
47
47
  "resolutions": {
48
- "tar": "7.5.3"
48
+ "tar": "^7.5.4"
49
49
  }
50
50
  }