@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,63 @@
|
|
|
1
|
+
import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import { GraphFileManager } from "../GraphFileManager.js";
|
|
3
|
+
export class LinkNodesTool {
|
|
4
|
+
constructor(fileManager = GraphFileManager.default) {
|
|
5
|
+
this.fileManager = fileManager;
|
|
6
|
+
}
|
|
7
|
+
schema() {
|
|
8
|
+
return {
|
|
9
|
+
name: 'link_nodes',
|
|
10
|
+
description: 'Create one or more connections between nodes in 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 modify'
|
|
17
|
+
},
|
|
18
|
+
edges: {
|
|
19
|
+
type: 'array',
|
|
20
|
+
description: 'Array of edges to create',
|
|
21
|
+
items: {
|
|
22
|
+
type: 'object',
|
|
23
|
+
properties: {
|
|
24
|
+
from: { type: 'string', description: 'Source node ID' },
|
|
25
|
+
to: { type: 'string', description: 'Target node ID' },
|
|
26
|
+
title: { type: 'string', description: 'Connection label (optional)' },
|
|
27
|
+
dashed: { type: 'boolean', description: 'Whether the connection should be dashed' },
|
|
28
|
+
reverse: { type: 'boolean', description: 'Whether to reverse the connection direction' },
|
|
29
|
+
undirected: { type: 'boolean', description: 'Create an undirected edge (no arrows); overrides reverse' }
|
|
30
|
+
},
|
|
31
|
+
required: ['from', 'to']
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
required: ['file_path', 'edges']
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async execute({ file_path, edges }) {
|
|
40
|
+
if (!file_path || !edges || !edges.length) {
|
|
41
|
+
throw new McpError(ErrorCode.InvalidParams, 'file_path, from, and to are required');
|
|
42
|
+
}
|
|
43
|
+
const graph = await this.fileManager.loadGraphFromSvg(file_path);
|
|
44
|
+
for (const edge of edges) {
|
|
45
|
+
const { from, to, title, dashed, reverse, undirected } = edge;
|
|
46
|
+
const style = {
|
|
47
|
+
...(dashed && { dashed: 1 }),
|
|
48
|
+
...(reverse && { reverse: true }),
|
|
49
|
+
};
|
|
50
|
+
graph.linkNodes({ from, to, title, style, undirected });
|
|
51
|
+
}
|
|
52
|
+
await this.fileManager.saveGraphToSvg(graph, file_path);
|
|
53
|
+
return {
|
|
54
|
+
content: [
|
|
55
|
+
{
|
|
56
|
+
type: 'text',
|
|
57
|
+
text: `Linked nodes in ${file_path}`,
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=LinkNodesTools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LinkNodesTools.js","sourceRoot":"","sources":["../../src/mcp/LinkNodesTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,MAAM,OAAO,aAAa;IACxB,YAA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CAAsC,CAAC,CAAC;QACtF,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAEjE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;YAE9D,MAAM,KAAK,GAAG;gBACZ,GAAG,CAAC,MAAM,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;gBAC5B,GAAG,CAAC,OAAO,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;aAClC,CAAC;YAEF,KAAK,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;QAC1D,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,24 @@
|
|
|
1
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
+
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
|
|
3
|
+
import { Logger } from '../Logger.js';
|
|
4
|
+
export interface Tool {
|
|
5
|
+
schema: () => {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
inputSchema: object;
|
|
9
|
+
};
|
|
10
|
+
execute: (args: any) => Promise<any>;
|
|
11
|
+
}
|
|
12
|
+
export interface McpServerConfig {
|
|
13
|
+
tools: Tool[];
|
|
14
|
+
name: string;
|
|
15
|
+
version: string;
|
|
16
|
+
}
|
|
17
|
+
export declare class McpServer {
|
|
18
|
+
logger: Logger;
|
|
19
|
+
tools: Tool[];
|
|
20
|
+
server: Server;
|
|
21
|
+
constructor({ tools, name, version }: McpServerConfig, logger?: Logger);
|
|
22
|
+
run(transport?: Transport): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=McpServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpServer.d.ts","sourceRoot":"","sources":["../../src/mcp/McpServer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAQnE,OAAO,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,MAAM;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IACzE,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,SAAS;IAI0C,MAAM;IAHpE,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;gBAEH,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,eAAe,EAAS,MAAM,SAA0B;IAYxF,GAAG,CAAC,SAAS,GAAE,SAAsC;CAuB5D"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { CallToolRequestSchema, ErrorCode, ListToolsRequestSchema, McpError, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
import { Logger } from '../Logger.js';
|
|
6
|
+
export class McpServer {
|
|
7
|
+
constructor({ tools, name, version }, logger = new Logger('McpServer')) {
|
|
8
|
+
this.logger = logger;
|
|
9
|
+
this.tools = tools;
|
|
10
|
+
this.server = new Server({
|
|
11
|
+
name,
|
|
12
|
+
version,
|
|
13
|
+
}, {
|
|
14
|
+
capabilities: {
|
|
15
|
+
tools: {}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
async run(transport = new StdioServerTransport()) {
|
|
20
|
+
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
21
|
+
tools: this.tools.map(tool => tool.schema())
|
|
22
|
+
}));
|
|
23
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
24
|
+
try {
|
|
25
|
+
const tool = this.tools.find(tool => tool.schema().name === request.params.name);
|
|
26
|
+
if (!tool) {
|
|
27
|
+
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}`);
|
|
28
|
+
}
|
|
29
|
+
return tool.execute(request.params.arguments);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
this.logger.error(`Failed to execute tool: ${error.message}`, { error });
|
|
33
|
+
if (error instanceof McpError)
|
|
34
|
+
throw error;
|
|
35
|
+
throw new McpError(ErrorCode.InternalError, `Failed to execute tool: ${error.message}`);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
await this.server.connect(transport);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=McpServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpServer.js","sourceRoot":"","sources":["../../src/mcp/McpServer.ts"],"names":[],"mappings":"AAAA,YAAY;AAEZ,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,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ED,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAChD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;gBACzE,IAAI,KAAK,YAAY,QAAQ;oBAAE,MAAM,KAAK,CAAC;gBAC3C,MAAM,IAAI,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,2BAA2B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAC1F,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { GraphFileManager } from '../GraphFileManager.js';
|
|
2
|
+
import { Tool } from './McpServer.js';
|
|
3
|
+
export declare class NewDiagramTool 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=NewDiagramTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NewDiagramTool.d.ts","sourceRoot":"","sources":["../../src/mcp/NewDiagramTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,qBAAa,cAAe,YAAW,IAAI;IAC7B,OAAO,CAAC,WAAW;gBAAX,WAAW,mBAA2B;IAE1D,MAAM;;;;;;;;;;;;;;IAiBA,OAAO,CAAC,EAAE,SAAS,EAAE;;KAAA;;;;;;CAgB5B"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { GraphFileManager } from '../GraphFileManager.js';
|
|
2
|
+
import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import { Graph } from '../Graph.js';
|
|
4
|
+
export class NewDiagramTool {
|
|
5
|
+
constructor(fileManager = GraphFileManager.default) {
|
|
6
|
+
this.fileManager = fileManager;
|
|
7
|
+
}
|
|
8
|
+
schema() {
|
|
9
|
+
return {
|
|
10
|
+
name: 'new_diagram',
|
|
11
|
+
description: 'Create a new empty diagram file',
|
|
12
|
+
inputSchema: {
|
|
13
|
+
type: 'object',
|
|
14
|
+
properties: {
|
|
15
|
+
file_path: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'Absolute or relative path for the diagram file (should end with .drawio.svg)'
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
required: ['file_path']
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
async execute({ file_path }) {
|
|
25
|
+
if (!file_path) {
|
|
26
|
+
throw new McpError(ErrorCode.InvalidParams, 'file_path is required');
|
|
27
|
+
}
|
|
28
|
+
await this.fileManager.saveGraphToSvg(new Graph(), file_path);
|
|
29
|
+
return {
|
|
30
|
+
content: [
|
|
31
|
+
{
|
|
32
|
+
type: 'text',
|
|
33
|
+
text: `Created new diagram: ${file_path}`,
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=NewDiagramTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NewDiagramTool.js","sourceRoot":"","sources":["../../src/mcp/NewDiagramTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,MAAM,OAAO,cAAc;IACzB,YAAoB,cAAc,gBAAgB,CAAC,OAAO;QAAtC,gBAAW,GAAX,WAAW,CAA2B;IAAG,CAAC;IAE9D,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,aAAa;YACnB,WAAW,EAAE,iCAAiC;YAC9C,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,SAAS,EAAE;wBACT,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,8EAA8E;qBAC5F;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,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,KAAK,EAAE,EAAE,SAAS,CAAC,CAAC;QAE9D,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,wBAAwB,SAAS,EAAE;iBAC1C;aACF;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { GraphFileManager } from "../GraphFileManager.js";
|
|
2
|
+
import { Tool } from "./McpServer.js";
|
|
3
|
+
export declare class RemoveNodesTool 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
|
+
ids: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
items: {
|
|
20
|
+
type: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
required: string[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
execute({ file_path, ids }: {
|
|
29
|
+
file_path: any;
|
|
30
|
+
ids: any;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
content: {
|
|
33
|
+
type: string;
|
|
34
|
+
text: string;
|
|
35
|
+
}[];
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=RemoveNodesTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RemoveNodesTool.d.ts","sourceRoot":"","sources":["../../src/mcp/RemoveNodesTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,qBAAa,eAAgB,YAAW,IAAI;IAC9B,OAAO,CAAC,WAAW;gBAAX,WAAW,mBAA2B;IAE1D,MAAM;;;;;;;;;;;;;;;;;;;;;;IAyBA,OAAO,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE;;;KAAA;;;;;;CAoBjC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { GraphFileManager } from "../GraphFileManager.js";
|
|
2
|
+
import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
export class RemoveNodesTool {
|
|
4
|
+
constructor(fileManager = GraphFileManager.default) {
|
|
5
|
+
this.fileManager = fileManager;
|
|
6
|
+
}
|
|
7
|
+
schema() {
|
|
8
|
+
return {
|
|
9
|
+
name: 'remove_nodes',
|
|
10
|
+
description: 'Remove nodes or edges from 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 modify'
|
|
17
|
+
},
|
|
18
|
+
ids: {
|
|
19
|
+
type: 'array',
|
|
20
|
+
description: 'Array of node/edge IDs to remove',
|
|
21
|
+
items: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
description: 'Node ID'
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
required: ['file_path', 'ids']
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
async execute({ file_path, ids }) {
|
|
32
|
+
if (!file_path || !ids) {
|
|
33
|
+
throw new McpError(ErrorCode.InvalidParams, 'file_path and ids are required');
|
|
34
|
+
}
|
|
35
|
+
const graph = await this.fileManager.loadGraphFromSvg(file_path);
|
|
36
|
+
graph.removeNodes(ids);
|
|
37
|
+
await this.fileManager.saveGraphToSvg(graph, file_path);
|
|
38
|
+
return {
|
|
39
|
+
content: [
|
|
40
|
+
{
|
|
41
|
+
type: 'text',
|
|
42
|
+
text: `Removed nodes: ${ids.join(', ')} from ${file_path}`,
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=RemoveNodesTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RemoveNodesTool.js","sourceRoot":"","sources":["../../src/mcp/RemoveNodesTool.ts"],"names":[],"mappings":"AAAA,OAAO,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aACF;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import './jsdom.js';
|
|
2
|
+
export declare const mxGraph: any, mxGraphModel: any, mxGeometry: any, mxCodec: any, mxPoint: any, mxUtils: any, mxHierarchicalLayout: any, mxConstants: any, mxCircleLayout: any, mxSwimlaneLayout: any, mxFastOrganicLayout: any, mxCompactTreeLayout: any, mxRadialTreeLayout: any, mxPartitionLayout: any, mxStackLayout: any;
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mxgraph/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AAGpB,eAAO,MAAQ,OAAO,OAAE,YAAY,OAAE,UAAU,OAAE,OAAO,OAAE,OAAO,OAAE,OAAO,OAAE,oBAAoB,OAAE,WAAW,OAAE,cAAc,OAAE,gBAAgB,OAAE,mBAAmB,OAAE,mBAAmB,OAAE,kBAAkB,OAAE,iBAAiB,OAAE,aAAa,KAG9O,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import './jsdom.js';
|
|
2
|
+
import mxgraph from 'mxgraph';
|
|
3
|
+
export const { mxGraph, mxGraphModel, mxGeometry, mxCodec, mxPoint, mxUtils, mxHierarchicalLayout, mxConstants, mxCircleLayout, mxSwimlaneLayout, mxFastOrganicLayout, mxCompactTreeLayout, mxRadialTreeLayout, mxPartitionLayout, mxStackLayout } = mxgraph({
|
|
4
|
+
mxImageBasePath: "./src/images",
|
|
5
|
+
mxBasePath: "./src"
|
|
6
|
+
});
|
|
7
|
+
window.mxGraphModel = mxGraphModel;
|
|
8
|
+
window.mxGeometry = mxGeometry;
|
|
9
|
+
window.mxPoint = mxPoint;
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mxgraph/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,CAAC;AACpB,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAC3P,eAAe,EAAE,cAAc;IAC/B,UAAU,EAAE,OAAO;CACpB,CAAC,CAAC;AAEF,MAAc,CAAC,YAAY,GAAG,YAAY,CAAC;AAC3C,MAAc,CAAC,UAAU,GAAG,UAAU,CAAC;AACvC,MAAc,CAAC,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsdom.d.ts","sourceRoot":"","sources":["../../src/mxgraph/jsdom.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JSDOM } from "jsdom";
|
|
2
|
+
const dom = new JSDOM();
|
|
3
|
+
global.window = dom.window;
|
|
4
|
+
global.document = window.document;
|
|
5
|
+
global.XMLSerializer = window.XMLSerializer;
|
|
6
|
+
// Use Object.defineProperty to override read-only navigator property
|
|
7
|
+
Object.defineProperty(global, 'navigator', {
|
|
8
|
+
value: window.navigator,
|
|
9
|
+
writable: true,
|
|
10
|
+
configurable: true
|
|
11
|
+
});
|
|
12
|
+
global.location = window.location;
|
|
13
|
+
global.DOMParser = window.DOMParser;
|
|
14
|
+
//# sourceMappingURL=jsdom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsdom.js","sourceRoot":"","sources":["../../src/mxgraph/jsdom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAE9B,MAAM,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;AAEvB,MAAc,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;AACpC,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAClC,MAAM,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;AAC5C,qEAAqE;AACrE,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE;IACzC,KAAK,EAAE,MAAM,CAAC,SAAS;IACvB,QAAQ,EAAE,IAAI;IACd,YAAY,EAAE,IAAI;CACnB,CAAC,CAAC;AACH,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAClC,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@iflow-mcp/sujimoshi_drawio-mcp",
|
|
3
|
+
"version": "0.0.0-auto",
|
|
4
|
+
"description": "MCP server for generating draw.io diagrams using mxgraph. Create and manage diagrams programmatically with VSCode compatibility.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"drawio-mcp": "dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/**/*",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"start": "tsx src/index.ts",
|
|
17
|
+
"build": "tsc"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"mcp",
|
|
21
|
+
"model-context-protocol",
|
|
22
|
+
"drawio",
|
|
23
|
+
"diagrams",
|
|
24
|
+
"mxgraph",
|
|
25
|
+
"visualization",
|
|
26
|
+
"svg",
|
|
27
|
+
"vscode",
|
|
28
|
+
"architecture-diagrams"
|
|
29
|
+
],
|
|
30
|
+
"author": "",
|
|
31
|
+
"license": "ISC",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/Sujimoshi/drawio-mcp.git"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/Sujimoshi/drawio-mcp#readme",
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/Sujimoshi/drawio-mcp/issues"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=18.0.0"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@modelcontextprotocol/sdk": "^0.5.0",
|
|
45
|
+
"jsdom": "^19.0.0",
|
|
46
|
+
"mxgraph": "^4.2.2",
|
|
47
|
+
"pako": "^2.0.4"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/node": "^24.3.0",
|
|
51
|
+
"@types/pako": "^2.0.4",
|
|
52
|
+
"tsx": "^4.0.0",
|
|
53
|
+
"typescript": "^5.9.2"
|
|
54
|
+
}
|
|
55
|
+
}
|