@kineviz/graphxr-mcp 0.1.0 → 0.2.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/README.md +243 -9
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -141,24 +141,258 @@ Enable debug logging to see detailed output:
|
|
|
141
141
|
|
|
142
142
|
## GraphXR API Reference
|
|
143
143
|
|
|
144
|
-
The `run_javascript` tool executes code with access to the `gxr` global object.
|
|
144
|
+
The `run_javascript` tool executes code with access to the `gxr` global object. Here are common operations:
|
|
145
|
+
|
|
146
|
+
### Adding Nodes and Edges
|
|
147
|
+
|
|
148
|
+
```javascript
|
|
149
|
+
// Add a single node
|
|
150
|
+
gxr.addNode({ id: "A", category: "Person", properties: { name: "Alice", age: 30 } });
|
|
151
|
+
|
|
152
|
+
// Add multiple nodes
|
|
153
|
+
gxr.addNodes([
|
|
154
|
+
{ id: "A", category: "Person", properties: { name: "Alice" } },
|
|
155
|
+
{ id: "B", category: "Person", properties: { name: "Bob" } }
|
|
156
|
+
]);
|
|
157
|
+
|
|
158
|
+
// Add an edge between nodes
|
|
159
|
+
gxr.addEdge({ sourceId: "A", targetId: "B", relationship: "KNOWS" });
|
|
160
|
+
|
|
161
|
+
// Add multiple edges
|
|
162
|
+
gxr.addEdges([
|
|
163
|
+
{ sourceId: "A", targetId: "B", relationship: "KNOWS" },
|
|
164
|
+
{ sourceId: "B", targetId: "C", relationship: "KNOWS" }
|
|
165
|
+
]);
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Generating Random Graphs
|
|
169
|
+
|
|
170
|
+
```javascript
|
|
171
|
+
// Generate a random graph
|
|
172
|
+
gxr.randomGraph({
|
|
173
|
+
nodeCount: 100,
|
|
174
|
+
edgeCount: 200,
|
|
175
|
+
categories: ["Person", "Company"],
|
|
176
|
+
relationships: ["WORKS_FOR", "KNOWS"]
|
|
177
|
+
});
|
|
178
|
+
gxr.forceLayout();
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Working with Nodes and Edges
|
|
145
182
|
|
|
146
183
|
```javascript
|
|
147
|
-
//
|
|
148
|
-
gxr.
|
|
184
|
+
// Iterate over all nodes
|
|
185
|
+
gxr.nodes().forEach(n => console.log(n.properties));
|
|
149
186
|
|
|
150
|
-
//
|
|
151
|
-
|
|
187
|
+
// Filter nodes by category
|
|
188
|
+
gxr.nodes({ category: "Person" }).forEach(console.log);
|
|
152
189
|
|
|
153
|
-
//
|
|
154
|
-
gxr.
|
|
190
|
+
// Filter nodes by property
|
|
191
|
+
gxr.nodes({ properties: { age: (age) => age > 30 } }).style('selected', true);
|
|
155
192
|
|
|
156
|
-
//
|
|
157
|
-
|
|
193
|
+
// Select nodes
|
|
194
|
+
gxr.selectNodes({ category: "Person" });
|
|
195
|
+
gxr.selectNodes((n) => n.properties.age > 30);
|
|
196
|
+
|
|
197
|
+
// Deselect all nodes
|
|
198
|
+
gxr.deselectNodes();
|
|
199
|
+
|
|
200
|
+
// Clear the graph
|
|
201
|
+
gxr.clear();
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Layouts
|
|
205
|
+
|
|
206
|
+
```javascript
|
|
207
|
+
// Force-directed layout
|
|
208
|
+
gxr.forceLayout();
|
|
209
|
+
|
|
210
|
+
// Arrange nodes in a circle
|
|
211
|
+
await gxr.circle();
|
|
212
|
+
|
|
213
|
+
// Arrange nodes on a sphere
|
|
214
|
+
await gxr.sphere();
|
|
215
|
+
|
|
216
|
+
// Arrange nodes in a grid
|
|
217
|
+
await gxr.grid();
|
|
218
|
+
|
|
219
|
+
// Arrange nodes in a line
|
|
220
|
+
await gxr.line();
|
|
221
|
+
|
|
222
|
+
// Hierarchical tree layout from selected nodes
|
|
223
|
+
await gxr.nodes({ category: "Root" }).ego({
|
|
224
|
+
depth: 3,
|
|
225
|
+
mode: 'tree',
|
|
226
|
+
orientation: 'down'
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// Parametric layout by property values
|
|
230
|
+
await gxr.parametric({
|
|
231
|
+
x: 'year',
|
|
232
|
+
y: 'revenue',
|
|
233
|
+
z: 0
|
|
234
|
+
});
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Styling
|
|
238
|
+
|
|
239
|
+
```javascript
|
|
240
|
+
// Color nodes by a property
|
|
241
|
+
gxr.colorNodesByProperty({ property: 'age', scale: 'BuGn' });
|
|
242
|
+
|
|
243
|
+
// Color specific values
|
|
244
|
+
gxr.colorNodesByProperty({
|
|
245
|
+
property: 'status',
|
|
246
|
+
colorMap: {
|
|
247
|
+
'active': '#00FF00',
|
|
248
|
+
'inactive': '#FF0000'
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
// Size nodes by property
|
|
253
|
+
gxr.sizeNodesByProperty({ category: "Person", property: 'age' });
|
|
254
|
+
|
|
255
|
+
// Set category color and icon
|
|
256
|
+
gxr.setCategoryColor("Person", "#00ff00");
|
|
257
|
+
gxr.setCategoryIconByName("Person", "person");
|
|
258
|
+
|
|
259
|
+
// Set relationship color
|
|
260
|
+
gxr.setRelationshipColor("KNOWS", "#0000ff");
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### Camera Controls
|
|
264
|
+
|
|
265
|
+
```javascript
|
|
266
|
+
// Fly to center of all nodes
|
|
267
|
+
gxr.flyToCenter();
|
|
268
|
+
|
|
269
|
+
// Zoom out to see all nodes
|
|
270
|
+
gxr.flyOut();
|
|
271
|
+
|
|
272
|
+
// Zoom in/out
|
|
273
|
+
gxr.zoomIn(2.0);
|
|
274
|
+
gxr.zoomOut(0.5);
|
|
275
|
+
|
|
276
|
+
// Enable camera rotation
|
|
277
|
+
gxr.setCameraRotating(true);
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Screenshots and Export
|
|
281
|
+
|
|
282
|
+
```javascript
|
|
283
|
+
// Take a screenshot (returns Blob)
|
|
284
|
+
const blob = await gxr.screenshot();
|
|
285
|
+
|
|
286
|
+
// Screenshot with options
|
|
287
|
+
const blob = await gxr.screenshot({
|
|
288
|
+
frameNodes: true,
|
|
289
|
+
hidePanels: true,
|
|
290
|
+
includeLegends: true,
|
|
291
|
+
format: 'png',
|
|
292
|
+
quality: 1.0
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// Get graph as JSON snapshot
|
|
296
|
+
const snapshot = gxr.snapshot();
|
|
297
|
+
|
|
298
|
+
// Apply a snapshot
|
|
299
|
+
gxr.snapshot(previousSnapshot);
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### Transform Operations
|
|
303
|
+
|
|
304
|
+
```javascript
|
|
305
|
+
// Link nodes by matching property values
|
|
306
|
+
gxr.link({
|
|
307
|
+
sourceCategory: "Person",
|
|
308
|
+
sourceProperty: "company",
|
|
309
|
+
targetCategory: "Company",
|
|
310
|
+
targetProperty: "name",
|
|
311
|
+
relationship: "WORKS_AT"
|
|
312
|
+
});
|
|
313
|
+
|
|
314
|
+
// Merge nodes with same key property
|
|
315
|
+
gxr.merge({
|
|
316
|
+
category: "Person",
|
|
317
|
+
keys: ['email']
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
// Extract property to new nodes
|
|
321
|
+
gxr.extract({
|
|
322
|
+
sourceCategory: "Episodes",
|
|
323
|
+
targetCategory: "Season",
|
|
324
|
+
props: [{ name: "seasonNumber", isKey: true }],
|
|
325
|
+
relationship: "IN_SEASON"
|
|
326
|
+
});
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Query
|
|
330
|
+
|
|
331
|
+
```javascript
|
|
332
|
+
// Execute a Cypher query (if connected to a database)
|
|
333
|
+
await gxr.query("MATCH (n:Person) RETURN n LIMIT 10");
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### Utilities
|
|
337
|
+
|
|
338
|
+
```javascript
|
|
339
|
+
// Display a toast message
|
|
340
|
+
gxr.toast("Hello, world!");
|
|
341
|
+
gxr.toast().success("Operation completed!");
|
|
342
|
+
gxr.toast().error("Something went wrong");
|
|
343
|
+
|
|
344
|
+
// Sleep for a duration
|
|
345
|
+
await gxr.sleep(1000);
|
|
346
|
+
|
|
347
|
+
// Get project info
|
|
348
|
+
const projectId = gxr.getProjectId();
|
|
349
|
+
const projectName = gxr.getProjectName();
|
|
158
350
|
```
|
|
159
351
|
|
|
160
352
|
For full API documentation, see the [GraphXR API Reference](https://graphxr.kineviz.com/docs).
|
|
161
353
|
|
|
354
|
+
## Publishing (for maintainers)
|
|
355
|
+
|
|
356
|
+
### Prerequisites
|
|
357
|
+
|
|
358
|
+
- npm account with access to the `@kineviz` scope
|
|
359
|
+
- Node.js 18 or later
|
|
360
|
+
|
|
361
|
+
### First-time Setup
|
|
362
|
+
|
|
363
|
+
Log in to npm with the @kineviz scope:
|
|
364
|
+
|
|
365
|
+
```bash
|
|
366
|
+
npm login --scope=@kineviz
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Release Process
|
|
370
|
+
|
|
371
|
+
From the `modules/mcp` directory:
|
|
372
|
+
|
|
373
|
+
```bash
|
|
374
|
+
cd modules/mcp
|
|
375
|
+
|
|
376
|
+
# Bump version and publish in one command
|
|
377
|
+
npm version patch && yarn release # 0.1.0 → 0.1.1 (bug fixes)
|
|
378
|
+
npm version minor && yarn release # 0.1.0 → 0.2.0 (new features)
|
|
379
|
+
npm version major && yarn release # 0.1.0 → 1.0.0 (breaking changes)
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Or step by step:
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
# 1. Bump version
|
|
386
|
+
npm version patch # or minor, or major
|
|
387
|
+
|
|
388
|
+
# 2. Build and publish
|
|
389
|
+
yarn release
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
The `yarn release` command will:
|
|
393
|
+
1. Build the package (`yarn build`)
|
|
394
|
+
2. Publish to npm with public access
|
|
395
|
+
|
|
162
396
|
## License
|
|
163
397
|
|
|
164
398
|
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kineviz/graphxr-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "MCP server for GraphXR - enables Claude/Cursor to create graph visualizations",
|
|
5
5
|
"bin": {
|
|
6
6
|
"graphxr-mcp": "./dist/index.js"
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "node build-package.js",
|
|
14
|
-
"prepublishOnly": "yarn build"
|
|
14
|
+
"prepublishOnly": "yarn build",
|
|
15
|
+
"release": "yarn build && npm publish --access public"
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
|
17
18
|
"@modelcontextprotocol/sdk": "^1.0.0",
|