@iflow-mcp/sujimoshi_drawio-mcp 0.0.0-auto
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/LICENSE +201 -0
- package/README.md +399 -0
- package/dist/Graph.d.ts +203 -0
- package/dist/Graph.d.ts.map +1 -0
- package/dist/Graph.js +314 -0
- package/dist/Graph.js.map +1 -0
- package/dist/GraphFileManager.d.ts +34 -0
- package/dist/GraphFileManager.d.ts.map +1 -0
- package/dist/GraphFileManager.js +97 -0
- package/dist/GraphFileManager.js.map +1 -0
- package/dist/Logger.d.ts +9 -0
- package/dist/Logger.d.ts.map +1 -0
- package/dist/Logger.js +20 -0
- package/dist/Logger.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/AddNodeTool.d.ts +97 -0
- package/dist/mcp/AddNodeTool.d.ts.map +1 -0
- package/dist/mcp/AddNodeTool.js +103 -0
- package/dist/mcp/AddNodeTool.js.map +1 -0
- package/dist/mcp/EditNodeTool.d.ts +74 -0
- package/dist/mcp/EditNodeTool.d.ts.map +1 -0
- package/dist/mcp/EditNodeTool.js +66 -0
- package/dist/mcp/EditNodeTool.js.map +1 -0
- package/dist/mcp/GetDiagramInfoTool.d.ts +29 -0
- package/dist/mcp/GetDiagramInfoTool.d.ts.map +1 -0
- package/dist/mcp/GetDiagramInfoTool.js +38 -0
- package/dist/mcp/GetDiagramInfoTool.js.map +1 -0
- package/dist/mcp/LinkNodesTools.d.ts +64 -0
- package/dist/mcp/LinkNodesTools.d.ts.map +1 -0
- package/dist/mcp/LinkNodesTools.js +63 -0
- package/dist/mcp/LinkNodesTools.js.map +1 -0
- package/dist/mcp/McpServer.d.ts +24 -0
- package/dist/mcp/McpServer.d.ts.map +1 -0
- package/dist/mcp/McpServer.js +41 -0
- package/dist/mcp/McpServer.js.map +1 -0
- package/dist/mcp/NewDiagramTool.d.ts +29 -0
- package/dist/mcp/NewDiagramTool.d.ts.map +1 -0
- package/dist/mcp/NewDiagramTool.js +39 -0
- package/dist/mcp/NewDiagramTool.js.map +1 -0
- package/dist/mcp/RemoveNodesTool.d.ts +38 -0
- package/dist/mcp/RemoveNodesTool.d.ts.map +1 -0
- package/dist/mcp/RemoveNodesTool.js +48 -0
- package/dist/mcp/RemoveNodesTool.js.map +1 -0
- package/dist/mxgraph/index.d.ts +3 -0
- package/dist/mxgraph/index.d.ts.map +1 -0
- package/dist/mxgraph/index.js +10 -0
- package/dist/mxgraph/index.js.map +1 -0
- package/dist/mxgraph/jsdom.d.ts +2 -0
- package/dist/mxgraph/jsdom.d.ts.map +1 -0
- package/dist/mxgraph/jsdom.js +14 -0
- package/dist/mxgraph/jsdom.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GraphFileManager.js","sourceRoot":"","sources":["../src/GraphFileManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAG3B;;OAEG;IACH,KAAK,CAAC,gBAAgB,CAAC,QAAgB;QACrC,mDAAmD;QACnD,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC5C,MAAM,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QAE9B,6DAA6D;QAC7D,MAAM,UAAU,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAC3D,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAEnD,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC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,OAAO,IAAI,CAAC;QACd,CAAC;QAED,uCAAuC;QACvC,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACzD,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QAEvE,8DAA8D;QAC9D,MAAM,OAAO,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC;QACjD,OAAO,OAAO,CAAC;IACjB,CAAC;;AArGM,wBAAO,GAAG,IAAI,gBAAgB,EAAE,CAAC"}
|
package/dist/Logger.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class Logger {
|
|
2
|
+
name: string;
|
|
3
|
+
static main: Logger;
|
|
4
|
+
constructor(name: string);
|
|
5
|
+
log(level: 'info' | 'error', message: string, data?: any): void;
|
|
6
|
+
info(message: string, data?: any): void;
|
|
7
|
+
error(message: string, data?: any): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../src/Logger.ts"],"names":[],"mappings":"AAGA,qBAAa,MAAM;IAGE,IAAI,EAAE,MAAM;IAF/B,MAAM,CAAC,IAAI,SAAsB;gBAEd,IAAI,EAAE,MAAM;IAE/B,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ;IAM5D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ;IAIpC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ;CAGtC"}
|
package/dist/Logger.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { appendFileSync } from 'fs';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
export class Logger {
|
|
4
|
+
constructor(name) {
|
|
5
|
+
this.name = name;
|
|
6
|
+
}
|
|
7
|
+
log(level, message, data = {}) {
|
|
8
|
+
const lvl = level === 'info' ? '🟢' : '🔴';
|
|
9
|
+
const log = `[${new Date().toISOString()}] ${lvl} ${this.name} - ${message} ${JSON.stringify(data, null, 2)}`;
|
|
10
|
+
appendFileSync(resolve(__dirname, `../logs/${this.name}.log`), `${log}\n`);
|
|
11
|
+
}
|
|
12
|
+
info(message, data = {}) {
|
|
13
|
+
this.log('info', message, data);
|
|
14
|
+
}
|
|
15
|
+
error(message, data = {}) {
|
|
16
|
+
this.log('error', message, data);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
Logger.main = new Logger('main');
|
|
20
|
+
//# sourceMappingURL=Logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../src/Logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE/B,MAAM,OAAO,MAAM;IAGjB,YAAmB,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;IAAG,CAAC;IAEnC,GAAG,CAAC,KAAuB,EAAE,OAAe,EAAE,OAAY,EAAE;QAC1D,MAAM,GAAG,GAAG,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QAC3C,MAAM,GAAG,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,GAAG,IAAI,IAAI,CAAC,IAAI,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QAC9G,cAAc,CAAC,OAAO,CAAC,SAAS,EAAE,WAAW,IAAI,CAAC,IAAI,MAAM,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC,CAAC;IAC7E,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,OAAY,EAAE;QAClC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,OAAY,EAAE;QACnC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;;AAhBM,WAAI,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { LinkNodesTool } from './mcp/LinkNodesTools.js';
|
|
3
|
+
import { GetDiagramInfoTool } from './mcp/GetDiagramInfoTool.js';
|
|
4
|
+
import { McpServer } from './mcp/McpServer.js';
|
|
5
|
+
import { NewDiagramTool } from './mcp/NewDiagramTool.js';
|
|
6
|
+
import { AddNodeTool } from './mcp/AddNodeTool.js';
|
|
7
|
+
import { Logger } from './Logger.js';
|
|
8
|
+
import { EditNodeTool } from './mcp/EditNodeTool.js';
|
|
9
|
+
import { RemoveNodesTool } from './mcp/RemoveNodesTool.js';
|
|
10
|
+
new McpServer({
|
|
11
|
+
name: 'drawio-mcp',
|
|
12
|
+
version: '1.2.0',
|
|
13
|
+
tools: [
|
|
14
|
+
new NewDiagramTool(),
|
|
15
|
+
new AddNodeTool(),
|
|
16
|
+
new LinkNodesTool(),
|
|
17
|
+
new GetDiagramInfoTool(),
|
|
18
|
+
new EditNodeTool(),
|
|
19
|
+
new RemoveNodesTool(),
|
|
20
|
+
]
|
|
21
|
+
}).run().catch(error => {
|
|
22
|
+
Logger.main.error('Failed to start MCP server', { error });
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,IAAI,SAAS,CAAC;IACZ,IAAI,EAAE,YAAY;IAClB,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE;QACL,IAAI,cAAc,EAAE;QACpB,IAAI,WAAW,EAAE;QACjB,IAAI,aAAa,EAAE;QACnB,IAAI,kBAAkB,EAAE;QACxB,IAAI,YAAY,EAAE;QAClB,IAAI,eAAe,EAAE;KACtB;CACF,CAAC,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IACrB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,4BAA4B,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7D,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { GraphFileManager } from "../GraphFileManager.js";
|
|
2
|
+
import { Tool } from "./McpServer.js";
|
|
3
|
+
export declare class AddNodeTool implements Tool {
|
|
4
|
+
private fileManager;
|
|
5
|
+
constructor(fileManager?: GraphFileManager);
|
|
6
|
+
schema(): {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: string;
|
|
11
|
+
properties: {
|
|
12
|
+
file_path: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
layout: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
properties: {
|
|
20
|
+
algorithm: {
|
|
21
|
+
type: string;
|
|
22
|
+
enum: string[];
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
options: {
|
|
26
|
+
type: string;
|
|
27
|
+
description: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
required: string[];
|
|
31
|
+
};
|
|
32
|
+
nodes: {
|
|
33
|
+
type: string;
|
|
34
|
+
description: string;
|
|
35
|
+
items: {
|
|
36
|
+
type: string;
|
|
37
|
+
properties: {
|
|
38
|
+
id: {
|
|
39
|
+
type: string;
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
title: {
|
|
43
|
+
type: string;
|
|
44
|
+
description: string;
|
|
45
|
+
};
|
|
46
|
+
kind: {
|
|
47
|
+
type: string;
|
|
48
|
+
enum: string[];
|
|
49
|
+
default: string;
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
parent: {
|
|
53
|
+
type: string;
|
|
54
|
+
default: string;
|
|
55
|
+
description: string;
|
|
56
|
+
};
|
|
57
|
+
x: {
|
|
58
|
+
type: string;
|
|
59
|
+
description: string;
|
|
60
|
+
};
|
|
61
|
+
y: {
|
|
62
|
+
type: string;
|
|
63
|
+
description: string;
|
|
64
|
+
};
|
|
65
|
+
width: {
|
|
66
|
+
type: string;
|
|
67
|
+
description: string;
|
|
68
|
+
};
|
|
69
|
+
height: {
|
|
70
|
+
type: string;
|
|
71
|
+
description: string;
|
|
72
|
+
};
|
|
73
|
+
corner_radius: {
|
|
74
|
+
type: string;
|
|
75
|
+
minimum: number;
|
|
76
|
+
description: string;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
required: string[];
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
required: string[];
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
execute({ file_path, nodes, layout }: {
|
|
87
|
+
file_path: any;
|
|
88
|
+
nodes: any;
|
|
89
|
+
layout: any;
|
|
90
|
+
}): Promise<{
|
|
91
|
+
content: {
|
|
92
|
+
type: string;
|
|
93
|
+
text: string;
|
|
94
|
+
}[];
|
|
95
|
+
}>;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=AddNodeTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AddNodeTool.d.ts","sourceRoot":"","sources":["../../src/mcp/AddNodeTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGtC,qBAAa,WAAY,YAAW,IAAI;IAC1B,OAAO,CAAC,WAAW;gBAAX,WAAW,mBAA2B;IAE1D,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsDA,OAAO,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE;;;;KAAA;;;;;;CA8C3C"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import { GraphFileManager } from "../GraphFileManager.js";
|
|
3
|
+
import { Graph } from "../Graph.js";
|
|
4
|
+
export class AddNodeTool {
|
|
5
|
+
constructor(fileManager = GraphFileManager.default) {
|
|
6
|
+
this.fileManager = fileManager;
|
|
7
|
+
}
|
|
8
|
+
schema() {
|
|
9
|
+
return {
|
|
10
|
+
name: 'add_nodes',
|
|
11
|
+
description: 'Add one or more nodes to a diagram file. Optionally run an automatic layout after insertion.',
|
|
12
|
+
inputSchema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
file_path: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'Absolute or relative path to the diagram file to modify'
|
|
18
|
+
},
|
|
19
|
+
layout: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
description: 'Optional automatic layout configuration',
|
|
22
|
+
properties: {
|
|
23
|
+
algorithm: { type: 'string', enum: ['hierarchical', 'circle', 'organic', 'compact-tree', 'radial-tree', 'partition', 'stack'], description: 'Layout algorithm' },
|
|
24
|
+
options: { type: 'object', description: 'Algorithm-specific options (e.g., { direction: "top-down" | "left-right" } for hierarchical)' }
|
|
25
|
+
},
|
|
26
|
+
required: ['algorithm']
|
|
27
|
+
},
|
|
28
|
+
nodes: {
|
|
29
|
+
type: 'array',
|
|
30
|
+
description: 'Array of nodes to add',
|
|
31
|
+
items: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: {
|
|
34
|
+
id: { type: 'string', description: 'Unique identifier for the node' },
|
|
35
|
+
title: { type: 'string', description: 'Display label for the node (can contain newlines "\n")' },
|
|
36
|
+
kind: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
enum: Object.keys(Graph.Kinds),
|
|
39
|
+
default: 'Rectangle',
|
|
40
|
+
description: 'Shape/kind of the node'
|
|
41
|
+
},
|
|
42
|
+
parent: {
|
|
43
|
+
type: 'string',
|
|
44
|
+
default: 'root',
|
|
45
|
+
description: 'Parent node ID (root for top-level nodes)'
|
|
46
|
+
},
|
|
47
|
+
x: { type: 'number', description: 'X coordinate' },
|
|
48
|
+
y: { type: 'number', description: 'Y coordinate' },
|
|
49
|
+
width: { type: 'number', description: 'Custom width (optional)' },
|
|
50
|
+
height: { type: 'number', description: 'Custom height (optional)' },
|
|
51
|
+
corner_radius: { type: 'integer', minimum: 1, description: 'Corner radius in pixels (≥1), only for kind RoundedRectangle' }
|
|
52
|
+
},
|
|
53
|
+
required: ['id', 'title', 'x', 'y', 'kind']
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
required: ['file_path', 'nodes']
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
async execute({ file_path, nodes, layout }) {
|
|
62
|
+
if (!file_path || !nodes || !nodes.length) {
|
|
63
|
+
throw new McpError(ErrorCode.InvalidParams, 'file_path and nodes are required');
|
|
64
|
+
}
|
|
65
|
+
const graph = await this.fileManager.loadGraphFromSvg(file_path);
|
|
66
|
+
for (const node of nodes) {
|
|
67
|
+
const { id, title, kind, parent, x, y, width, height, corner_radius } = node;
|
|
68
|
+
graph.addNode({
|
|
69
|
+
id,
|
|
70
|
+
title,
|
|
71
|
+
kind: Graph.normalizeKind(kind),
|
|
72
|
+
parent,
|
|
73
|
+
x: Number(x),
|
|
74
|
+
y: Number(y),
|
|
75
|
+
...(width && { width: Number(width) }),
|
|
76
|
+
...(height && { height: Number(height) }),
|
|
77
|
+
...(corner_radius && { corner_radius: Number(corner_radius) })
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
// TODO: Prefer a separate `layout_diagram` tool to decouple layout from add operations for better edge-aware reflow.
|
|
81
|
+
if (layout) {
|
|
82
|
+
if (!layout.algorithm) {
|
|
83
|
+
throw new McpError(ErrorCode.InvalidParams, 'layout.algorithm is required when layout is provided');
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
graph.applyLayout(layout);
|
|
87
|
+
}
|
|
88
|
+
catch (e) {
|
|
89
|
+
throw new McpError(ErrorCode.InvalidParams, e?.message || 'Invalid layout configuration');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
await this.fileManager.saveGraphToSvg(graph, file_path);
|
|
93
|
+
return {
|
|
94
|
+
content: [
|
|
95
|
+
{
|
|
96
|
+
type: 'text',
|
|
97
|
+
text: `Nodes added to ${file_path}`,
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
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AC;QAExD,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,kBAAkB,SAAS,EAAE;iBACpC;aACF;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { GraphFileManager } from "../GraphFileManager.js";
|
|
2
|
+
import { Tool } from "./McpServer.js";
|
|
3
|
+
export declare class EditNodeTool implements Tool {
|
|
4
|
+
private fileManager;
|
|
5
|
+
constructor(fileManager?: GraphFileManager);
|
|
6
|
+
schema(): {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: string;
|
|
11
|
+
properties: {
|
|
12
|
+
file_path: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
nodes: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
items: {
|
|
20
|
+
type: string;
|
|
21
|
+
properties: {
|
|
22
|
+
id: {
|
|
23
|
+
type: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
title: {
|
|
27
|
+
type: string;
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
30
|
+
kind: {
|
|
31
|
+
type: string;
|
|
32
|
+
enum: string[];
|
|
33
|
+
description: string;
|
|
34
|
+
};
|
|
35
|
+
x: {
|
|
36
|
+
type: string;
|
|
37
|
+
description: string;
|
|
38
|
+
};
|
|
39
|
+
y: {
|
|
40
|
+
type: string;
|
|
41
|
+
description: string;
|
|
42
|
+
};
|
|
43
|
+
width: {
|
|
44
|
+
type: string;
|
|
45
|
+
description: string;
|
|
46
|
+
};
|
|
47
|
+
height: {
|
|
48
|
+
type: string;
|
|
49
|
+
description: string;
|
|
50
|
+
};
|
|
51
|
+
corner_radius: {
|
|
52
|
+
type: string;
|
|
53
|
+
minimum: number;
|
|
54
|
+
description: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
required: string[];
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
required: string[];
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
execute({ file_path, nodes }: {
|
|
65
|
+
file_path: any;
|
|
66
|
+
nodes: any;
|
|
67
|
+
}): Promise<{
|
|
68
|
+
content: {
|
|
69
|
+
type: string;
|
|
70
|
+
text: string;
|
|
71
|
+
}[];
|
|
72
|
+
}>;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=EditNodeTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditNodeTool.d.ts","sourceRoot":"","sources":["../../src/mcp/EditNodeTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGtC,qBAAa,YAAa,YAAW,IAAI;IAC3B,OAAO,CAAC,WAAW;gBAAX,WAAW,mBAA2B;IAE1D,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAuCA,OAAO,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE;;;KAAA;;;;;;CAwBnC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import { GraphFileManager } from "../GraphFileManager.js";
|
|
3
|
+
import { Graph } from "../Graph.js";
|
|
4
|
+
export class EditNodeTool {
|
|
5
|
+
constructor(fileManager = GraphFileManager.default) {
|
|
6
|
+
this.fileManager = fileManager;
|
|
7
|
+
}
|
|
8
|
+
schema() {
|
|
9
|
+
return {
|
|
10
|
+
name: 'edit_nodes',
|
|
11
|
+
description: 'Edit one or more nodes or edges in a diagram file',
|
|
12
|
+
inputSchema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
file_path: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'Absolute or relative path to the diagram file to modify'
|
|
18
|
+
},
|
|
19
|
+
nodes: {
|
|
20
|
+
type: 'array',
|
|
21
|
+
description: 'Array of nodes to edit',
|
|
22
|
+
items: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
id: { type: 'string', description: 'Unique identifier of the node or edge to update' },
|
|
26
|
+
title: { type: 'string', description: 'Display label for the node or edge to update (can contain newlines "\n") (optional)' },
|
|
27
|
+
kind: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
enum: Object.keys(Graph.Kinds),
|
|
30
|
+
description: 'Shape/kind of the node for edit, only appliable to nodes (optional)'
|
|
31
|
+
},
|
|
32
|
+
x: { type: 'number', description: 'New node X coordinate, only appliable to nodes (optional)' },
|
|
33
|
+
y: { type: 'number', description: 'New node Y coordinate, only appliable to nodes (optional)' },
|
|
34
|
+
width: { type: 'number', description: 'New node width, only appliable to nodes (optional)' },
|
|
35
|
+
height: { type: 'number', description: 'New node height, only appliable to nodes (optional)' },
|
|
36
|
+
corner_radius: { type: 'integer', minimum: 1, description: 'Corner radius in pixels (≥1), applies to RoundedRectangle' }
|
|
37
|
+
},
|
|
38
|
+
required: ['id']
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
required: ['file_path', 'nodes']
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
async execute({ file_path, nodes }) {
|
|
47
|
+
if (!file_path || !nodes || !nodes.length) {
|
|
48
|
+
throw new McpError(ErrorCode.InvalidParams, 'file_path and nodes are required');
|
|
49
|
+
}
|
|
50
|
+
const graph = await this.fileManager.loadGraphFromSvg(file_path);
|
|
51
|
+
for (const node of nodes) {
|
|
52
|
+
const { id, title, kind, x, y, width, height, corner_radius } = node;
|
|
53
|
+
graph.editNode({ id, title, kind: kind ? Graph.normalizeKind(kind) : undefined, x, y, width, height, ...(corner_radius && { corner_radius: Number(corner_radius) }) });
|
|
54
|
+
}
|
|
55
|
+
await this.fileManager.saveGraphToSvg(graph, file_path);
|
|
56
|
+
return {
|
|
57
|
+
content: [
|
|
58
|
+
{
|
|
59
|
+
type: 'text',
|
|
60
|
+
text: `Nodes edited in ${file_path}`,
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=EditNodeTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditNodeTool.js","sourceRoot":"","sources":["../../src/mcp/EditNodeTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,OAAO,YAAY;IACvB,YAAoB,cAAc,gBAAgB,CAAC,OAAO;QAAtC,gBAAW,GAAX,WAAW,CAA2B;IAAG,CAAC;IAE9D,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,YAAY;YAClB,WAAW,EAAE,mDAAmD;YAChE,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,SAAS,EAAE;wBACT,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,yDAAyD;qBACvE;oBACD,KAAK,EAAE;wBACL,IAAI,EAAE,OAAO;wBACb,WAAW,EAAE,wBAAwB;wBACrC,KAAK,EAAE;4BACL,IAAI,EAAE,QAAQ;4BACd,UAAU,EAAE;gCACV,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iDAAiD,EAAE;gCACtF,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qFAAqF,EAAE;gCAC7H,IAAI,EAAE;oCACJ,IAAI,EAAE,QAAQ;oCACd,IAAI,EA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AAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,aAAa,IAAI,EAAE,aAAa,EAAE,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACzK,CAAC;QAED,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAExD,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,mBAAmB,SAAS,EAAE;iBACrC;aACF;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { GraphFileManager } from "../GraphFileManager.js";
|
|
2
|
+
import { Tool } from "./McpServer.js";
|
|
3
|
+
export declare class GetDiagramInfoTool implements Tool {
|
|
4
|
+
private fileManager;
|
|
5
|
+
constructor(fileManager?: GraphFileManager);
|
|
6
|
+
schema(): {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: string;
|
|
11
|
+
properties: {
|
|
12
|
+
file_path: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
required: string[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
execute({ file_path }: {
|
|
21
|
+
file_path: any;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
content: {
|
|
24
|
+
type: string;
|
|
25
|
+
text: string;
|
|
26
|
+
}[];
|
|
27
|
+
}>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=GetDiagramInfoTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetDiagramInfoTool.d.ts","sourceRoot":"","sources":["../../src/mcp/GetDiagramInfoTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,qBAAa,kBAAmB,YAAW,IAAI;IACjC,OAAO,CAAC,WAAW;gBAAX,WAAW,mBAA2B;IAE1D,MAAM;;;;;;;;;;;;;;IAiBA,OAAO,CAAC,EAAE,SAAS,EAAE;;KAAA;;;;;;CAgB5B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { GraphFileManager } from "../GraphFileManager.js";
|
|
2
|
+
import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
export class GetDiagramInfoTool {
|
|
4
|
+
constructor(fileManager = GraphFileManager.default) {
|
|
5
|
+
this.fileManager = fileManager;
|
|
6
|
+
}
|
|
7
|
+
schema() {
|
|
8
|
+
return {
|
|
9
|
+
name: 'get_diagram_info',
|
|
10
|
+
description: 'Get xml representation of a diagram file',
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
file_path: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: 'Absolute or relative path to the diagram file to inspect'
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
required: ['file_path']
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async execute({ file_path }) {
|
|
24
|
+
if (!file_path) {
|
|
25
|
+
throw new McpError(ErrorCode.InvalidParams, 'file_path is required');
|
|
26
|
+
}
|
|
27
|
+
const graph = await this.fileManager.loadGraphFromSvg(file_path);
|
|
28
|
+
return {
|
|
29
|
+
content: [
|
|
30
|
+
{
|
|
31
|
+
type: 'text',
|
|
32
|
+
text: `Graph xml representation: \n${graph.toXML()}`
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=GetDiagramInfoTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GetDiagramInfoTool.js","sourceRoot":"","sources":["../../src/mcp/GetDiagramInfoTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAGzE,MAAM,OAAO,kBAAkB;IAC7B,YAAoB,cAAc,gBAAgB,CAAC,OAAO;QAAtC,gBAAW,GAAX,WAAW,CAA2B;IAAG,CAAC;IAE9D,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,kBAAkB;YACxB,WAAW,EAAE,0CAA0C;YACvD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,SAAS,EAAE;wBACT,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,0DAA0D;qBACxE;iBACF;gBACD,QAAQ,EAAE,CAAC,WAAW,CAAC;aACxB;SACF,CAAA;IACH,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAE,SAAS,EAAE;QACzB,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,uBAAuB,CAAC,CAAC;QACvE,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAEjE,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,+BAA+B,KAAK,CAAC,KAAK,EAAE,EAAE;iBACrD;aACF;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { GraphFileManager } from "../GraphFileManager.js";
|
|
2
|
+
import { Tool } from './McpServer.js';
|
|
3
|
+
export declare class LinkNodesTool implements Tool {
|
|
4
|
+
private fileManager;
|
|
5
|
+
constructor(fileManager?: GraphFileManager);
|
|
6
|
+
schema(): {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
inputSchema: {
|
|
10
|
+
type: string;
|
|
11
|
+
properties: {
|
|
12
|
+
file_path: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
edges: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
items: {
|
|
20
|
+
type: string;
|
|
21
|
+
properties: {
|
|
22
|
+
from: {
|
|
23
|
+
type: string;
|
|
24
|
+
description: string;
|
|
25
|
+
};
|
|
26
|
+
to: {
|
|
27
|
+
type: string;
|
|
28
|
+
description: string;
|
|
29
|
+
};
|
|
30
|
+
title: {
|
|
31
|
+
type: string;
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
dashed: {
|
|
35
|
+
type: string;
|
|
36
|
+
description: string;
|
|
37
|
+
};
|
|
38
|
+
reverse: {
|
|
39
|
+
type: string;
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
undirected: {
|
|
43
|
+
type: string;
|
|
44
|
+
description: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
required: string[];
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
required: string[];
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
execute({ file_path, edges }: {
|
|
55
|
+
file_path: any;
|
|
56
|
+
edges: any;
|
|
57
|
+
}): Promise<{
|
|
58
|
+
content: {
|
|
59
|
+
type: string;
|
|
60
|
+
text: string;
|
|
61
|
+
}[];
|
|
62
|
+
}>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=LinkNodesTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkNodesTools.d.ts","sourceRoot":"","sources":["../../src/mcp/LinkNodesTools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,qBAAa,aAAc,YAAW,IAAI;IAC5B,OAAO,CAAC,WAAW;gBAAX,WAAW,mBAA2B;IAE1D,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAiCA,OAAO,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE;;;KAAA;;;;;;CA6BnC"}
|