@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.
- package/dist/index.js +3 -0
- package/dist/resources/index.js +93 -0
- package/dist/tools/batch-update.js +18 -6
- package/dist/tools/check-collision.js +30 -12
- package/dist/tools/create-graph.js +22 -16
- package/dist/tools/create.js +17 -15
- package/dist/tools/find-overlaps.js +24 -4
- package/dist/tools/find-position.js +97 -72
- package/dist/tools/grid-calc.js +44 -27
- package/dist/tools/index.js +55 -96
- package/dist/tools/list-nodes.js +5 -4
- package/dist/tools/list-positions.js +5 -4
- package/dist/tools/read.js +14 -1
- package/dist/tools/size-calc.js +10 -5
- package/dist/tools/update.js +21 -23
- package/dist/utils/units.js +19 -0
- package/package.json +2 -2
package/dist/tools/update.js
CHANGED
|
@@ -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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
136
|
-
|
|
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.
|
|
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.
|
|
48
|
+
"tar": "^7.5.4"
|
|
49
49
|
}
|
|
50
50
|
}
|