@eclipse-glsp/server-mcp 2.7.0-next.10
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 +642 -0
- package/README.md +57 -0
- package/lib/index.d.ts +66 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +82 -0
- package/lib/index.js.map +1 -0
- package/lib/modules/mcp-diagram-module.d.ts +123 -0
- package/lib/modules/mcp-diagram-module.d.ts.map +1 -0
- package/lib/modules/mcp-diagram-module.js +202 -0
- package/lib/modules/mcp-diagram-module.js.map +1 -0
- package/lib/modules/mcp-server-module.d.ts +143 -0
- package/lib/modules/mcp-server-module.d.ts.map +1 -0
- package/lib/modules/mcp-server-module.js +251 -0
- package/lib/modules/mcp-server-module.js.map +1 -0
- package/lib/prompts/handlers/describe-diagram-mcp-prompt-handler.d.ts +44 -0
- package/lib/prompts/handlers/describe-diagram-mcp-prompt-handler.d.ts.map +1 -0
- package/lib/prompts/handlers/describe-diagram-mcp-prompt-handler.js +102 -0
- package/lib/prompts/handlers/describe-diagram-mcp-prompt-handler.js.map +1 -0
- package/lib/prompts/handlers/suggest-improvements-mcp-prompt-handler.d.ts +44 -0
- package/lib/prompts/handlers/suggest-improvements-mcp-prompt-handler.d.ts.map +1 -0
- package/lib/prompts/handlers/suggest-improvements-mcp-prompt-handler.js +99 -0
- package/lib/prompts/handlers/suggest-improvements-mcp-prompt-handler.js.map +1 -0
- package/lib/resources/handlers/diagram-png-mcp-resource-handler.d.ts +84 -0
- package/lib/resources/handlers/diagram-png-mcp-resource-handler.d.ts.map +1 -0
- package/lib/resources/handlers/diagram-png-mcp-resource-handler.js +177 -0
- package/lib/resources/handlers/diagram-png-mcp-resource-handler.js.map +1 -0
- package/lib/resources/handlers/diagram-svg-mcp-resource-handler.d.ts +55 -0
- package/lib/resources/handlers/diagram-svg-mcp-resource-handler.d.ts.map +1 -0
- package/lib/resources/handlers/diagram-svg-mcp-resource-handler.js +99 -0
- package/lib/resources/handlers/diagram-svg-mcp-resource-handler.js.map +1 -0
- package/lib/resources/services/element-types-provider.d.ts +65 -0
- package/lib/resources/services/element-types-provider.d.ts.map +1 -0
- package/lib/resources/services/element-types-provider.js +81 -0
- package/lib/resources/services/element-types-provider.js.map +1 -0
- package/lib/resources/services/mcp-model-serializer.d.ts +78 -0
- package/lib/resources/services/mcp-model-serializer.d.ts.map +1 -0
- package/lib/resources/services/mcp-model-serializer.js +188 -0
- package/lib/resources/services/mcp-model-serializer.js.map +1 -0
- package/lib/server/glsp-mcp-server.d.ts +82 -0
- package/lib/server/glsp-mcp-server.d.ts.map +1 -0
- package/lib/server/glsp-mcp-server.js +140 -0
- package/lib/server/glsp-mcp-server.js.map +1 -0
- package/lib/server/lru-event-store.d.ts +53 -0
- package/lib/server/lru-event-store.d.ts.map +1 -0
- package/lib/server/lru-event-store.js +100 -0
- package/lib/server/lru-event-store.js.map +1 -0
- package/lib/server/mcp-diagram-handler-dispatcher.d.ts +144 -0
- package/lib/server/mcp-diagram-handler-dispatcher.d.ts.map +1 -0
- package/lib/server/mcp-diagram-handler-dispatcher.js +382 -0
- package/lib/server/mcp-diagram-handler-dispatcher.js.map +1 -0
- package/lib/server/mcp-diagram-prompt-handler-registry.d.ts +33 -0
- package/lib/server/mcp-diagram-prompt-handler-registry.d.ts.map +1 -0
- package/lib/server/mcp-diagram-prompt-handler-registry.js +76 -0
- package/lib/server/mcp-diagram-prompt-handler-registry.js.map +1 -0
- package/lib/server/mcp-diagram-resource-handler-registry.d.ts +35 -0
- package/lib/server/mcp-diagram-resource-handler-registry.d.ts.map +1 -0
- package/lib/server/mcp-diagram-resource-handler-registry.js +94 -0
- package/lib/server/mcp-diagram-resource-handler-registry.js.map +1 -0
- package/lib/server/mcp-diagram-tool-handler-registry.d.ts +57 -0
- package/lib/server/mcp-diagram-tool-handler-registry.d.ts.map +1 -0
- package/lib/server/mcp-diagram-tool-handler-registry.js +111 -0
- package/lib/server/mcp-diagram-tool-handler-registry.js.map +1 -0
- package/lib/server/mcp-handler-shared.d.ts +142 -0
- package/lib/server/mcp-handler-shared.d.ts.map +1 -0
- package/lib/server/mcp-handler-shared.js +199 -0
- package/lib/server/mcp-handler-shared.js.map +1 -0
- package/lib/server/mcp-http-transport.d.ts +93 -0
- package/lib/server/mcp-http-transport.d.ts.map +1 -0
- package/lib/server/mcp-http-transport.js +350 -0
- package/lib/server/mcp-http-transport.js.map +1 -0
- package/lib/server/mcp-id-alias-service.d.ts +70 -0
- package/lib/server/mcp-id-alias-service.d.ts.map +1 -0
- package/lib/server/mcp-id-alias-service.js +85 -0
- package/lib/server/mcp-id-alias-service.js.map +1 -0
- package/lib/server/mcp-input-schemas.d.ts +73 -0
- package/lib/server/mcp-input-schemas.d.ts.map +1 -0
- package/lib/server/mcp-input-schemas.js +67 -0
- package/lib/server/mcp-input-schemas.js.map +1 -0
- package/lib/server/mcp-label-provider.d.ts +45 -0
- package/lib/server/mcp-label-provider.d.ts.map +1 -0
- package/lib/server/mcp-label-provider.js +42 -0
- package/lib/server/mcp-label-provider.js.map +1 -0
- package/lib/server/mcp-log-level-registry.d.ts +54 -0
- package/lib/server/mcp-log-level-registry.d.ts.map +1 -0
- package/lib/server/mcp-log-level-registry.js +80 -0
- package/lib/server/mcp-log-level-registry.js.map +1 -0
- package/lib/server/mcp-logger.d.ts +59 -0
- package/lib/server/mcp-logger.d.ts.map +1 -0
- package/lib/server/mcp-logger.js +104 -0
- package/lib/server/mcp-logger.js.map +1 -0
- package/lib/server/mcp-mime-types.d.ts +28 -0
- package/lib/server/mcp-mime-types.d.ts.map +1 -0
- package/lib/server/mcp-mime-types.js +18 -0
- package/lib/server/mcp-mime-types.js.map +1 -0
- package/lib/server/mcp-options.d.ts +39 -0
- package/lib/server/mcp-options.d.ts.map +1 -0
- package/lib/server/mcp-options.js +53 -0
- package/lib/server/mcp-options.js.map +1 -0
- package/lib/server/mcp-progress-reporter.d.ts +48 -0
- package/lib/server/mcp-progress-reporter.d.ts.map +1 -0
- package/lib/server/mcp-progress-reporter.js +66 -0
- package/lib/server/mcp-progress-reporter.js.map +1 -0
- package/lib/server/mcp-prompt-handler.d.ts +120 -0
- package/lib/server/mcp-prompt-handler.d.ts.map +1 -0
- package/lib/server/mcp-prompt-handler.js +131 -0
- package/lib/server/mcp-prompt-handler.js.map +1 -0
- package/lib/server/mcp-request-context.d.ts +37 -0
- package/lib/server/mcp-request-context.d.ts.map +1 -0
- package/lib/server/mcp-request-context.js +37 -0
- package/lib/server/mcp-request-context.js.map +1 -0
- package/lib/server/mcp-resource-handler.d.ts +212 -0
- package/lib/server/mcp-resource-handler.d.ts.map +1 -0
- package/lib/server/mcp-resource-handler.js +298 -0
- package/lib/server/mcp-resource-handler.js.map +1 -0
- package/lib/server/mcp-server-launcher.d.ts +143 -0
- package/lib/server/mcp-server-launcher.d.ts.map +1 -0
- package/lib/server/mcp-server-launcher.js +355 -0
- package/lib/server/mcp-server-launcher.js.map +1 -0
- package/lib/server/mcp-session.d.ts +44 -0
- package/lib/server/mcp-session.d.ts.map +1 -0
- package/lib/server/mcp-session.js +18 -0
- package/lib/server/mcp-session.js.map +1 -0
- package/lib/server/mcp-tool-handler.d.ts +259 -0
- package/lib/server/mcp-tool-handler.d.ts.map +1 -0
- package/lib/server/mcp-tool-handler.js +355 -0
- package/lib/server/mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/count-elements-mcp-tool-handler.d.ts +47 -0
- package/lib/tools/handlers/count-elements-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/count-elements-mcp-tool-handler.js +77 -0
- package/lib/tools/handlers/count-elements-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/create-edges-mcp-tool-handler.d.ts +113 -0
- package/lib/tools/handlers/create-edges-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/create-edges-mcp-tool-handler.js +191 -0
- package/lib/tools/handlers/create-edges-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/create-nodes-mcp-tool-handler.d.ts +82 -0
- package/lib/tools/handlers/create-nodes-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/create-nodes-mcp-tool-handler.js +124 -0
- package/lib/tools/handlers/create-nodes-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/delete-elements-mcp-tool-handler.d.ts +53 -0
- package/lib/tools/handlers/delete-elements-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/delete-elements-mcp-tool-handler.js +74 -0
- package/lib/tools/handlers/delete-elements-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/diagram-model-mcp-tool-handler.d.ts +60 -0
- package/lib/tools/handlers/diagram-model-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/diagram-model-mcp-tool-handler.js +79 -0
- package/lib/tools/handlers/diagram-model-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/element-types-mcp-tool-handler.d.ts +98 -0
- package/lib/tools/handlers/element-types-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/element-types-mcp-tool-handler.js +156 -0
- package/lib/tools/handlers/element-types-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/get-selection-mcp-tool-handler.d.ts +44 -0
- package/lib/tools/handlers/get-selection-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/get-selection-mcp-tool-handler.js +70 -0
- package/lib/tools/handlers/get-selection-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/layout-mcp-tool-handler.d.ts +44 -0
- package/lib/tools/handlers/layout-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/layout-mcp-tool-handler.js +72 -0
- package/lib/tools/handlers/layout-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/modify-edges-mcp-tool-handler.d.ts +79 -0
- package/lib/tools/handlers/modify-edges-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/modify-edges-mcp-tool-handler.js +138 -0
- package/lib/tools/handlers/modify-edges-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/modify-nodes-mcp-tool-handler.d.ts +93 -0
- package/lib/tools/handlers/modify-nodes-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/modify-nodes-mcp-tool-handler.js +127 -0
- package/lib/tools/handlers/modify-nodes-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/query-elements-mcp-tool-handler.d.ts +103 -0
- package/lib/tools/handlers/query-elements-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/query-elements-mcp-tool-handler.js +160 -0
- package/lib/tools/handlers/query-elements-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/redo-mcp-tool-handler.d.ts +46 -0
- package/lib/tools/handlers/redo-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/redo-mcp-tool-handler.js +75 -0
- package/lib/tools/handlers/redo-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/save-model-mcp-tool-handler.d.ts +57 -0
- package/lib/tools/handlers/save-model-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/save-model-mcp-tool-handler.js +93 -0
- package/lib/tools/handlers/save-model-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/session-info-mcp-tool-handler.d.ts +66 -0
- package/lib/tools/handlers/session-info-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/session-info-mcp-tool-handler.js +109 -0
- package/lib/tools/handlers/session-info-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/set-selection-mcp-tool-handler.d.ts +61 -0
- package/lib/tools/handlers/set-selection-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/set-selection-mcp-tool-handler.js +104 -0
- package/lib/tools/handlers/set-selection-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/set-view-mcp-tool-handler.d.ts +111 -0
- package/lib/tools/handlers/set-view-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/set-view-mcp-tool-handler.js +144 -0
- package/lib/tools/handlers/set-view-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/undo-mcp-tool-handler.d.ts +46 -0
- package/lib/tools/handlers/undo-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/undo-mcp-tool-handler.js +76 -0
- package/lib/tools/handlers/undo-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/validate-diagram-mcp-tool-handler.d.ts +67 -0
- package/lib/tools/handlers/validate-diagram-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/validate-diagram-mcp-tool-handler.js +0 -0
- package/lib/tools/handlers/validate-diagram-mcp-tool-handler.js.map +1 -0
- package/lib/util/markdown-util.d.ts +20 -0
- package/lib/util/markdown-util.d.ts.map +1 -0
- package/lib/util/markdown-util.js +45 -0
- package/lib/util/markdown-util.js.map +1 -0
- package/lib/util/mcp-util.d.ts +22 -0
- package/lib/util/mcp-util.d.ts.map +1 -0
- package/lib/util/mcp-util.js +29 -0
- package/lib/util/mcp-util.js.map +1 -0
- package/package.json +63 -0
- package/src/index.ts +65 -0
- package/src/modules/mcp-diagram-module.ts +247 -0
- package/src/modules/mcp-server-module.ts +289 -0
- package/src/prompts/handlers/describe-diagram-mcp-prompt-handler.ts +88 -0
- package/src/prompts/handlers/suggest-improvements-mcp-prompt-handler.ts +85 -0
- package/src/resources/handlers/diagram-png-mcp-resource-handler.ts +177 -0
- package/src/resources/handlers/diagram-svg-mcp-resource-handler.ts +85 -0
- package/src/resources/services/element-types-provider.ts +105 -0
- package/src/resources/services/mcp-model-serializer.ts +211 -0
- package/src/server/glsp-mcp-server.spec.ts +73 -0
- package/src/server/glsp-mcp-server.ts +196 -0
- package/src/server/lru-event-store.spec.ts +121 -0
- package/src/server/lru-event-store.ts +112 -0
- package/src/server/mcp-diagram-handler-dispatcher.spec.ts +231 -0
- package/src/server/mcp-diagram-handler-dispatcher.ts +459 -0
- package/src/server/mcp-diagram-prompt-handler-registry.ts +59 -0
- package/src/server/mcp-diagram-resource-handler-registry.ts +73 -0
- package/src/server/mcp-diagram-tool-handler-registry.ts +97 -0
- package/src/server/mcp-handler-shared.spec.ts +53 -0
- package/src/server/mcp-handler-shared.ts +247 -0
- package/src/server/mcp-http-transport-e2e.spec.ts +151 -0
- package/src/server/mcp-http-transport.spec.ts +385 -0
- package/src/server/mcp-http-transport.ts +368 -0
- package/src/server/mcp-id-alias-service.spec.ts +106 -0
- package/src/server/mcp-id-alias-service.ts +104 -0
- package/src/server/mcp-input-schemas.ts +82 -0
- package/src/server/mcp-label-provider.ts +52 -0
- package/src/server/mcp-log-level-registry.spec.ts +75 -0
- package/src/server/mcp-log-level-registry.ts +90 -0
- package/src/server/mcp-logger.spec.ts +227 -0
- package/src/server/mcp-logger.ts +91 -0
- package/src/server/mcp-mime-types.ts +31 -0
- package/src/server/mcp-options.ts +43 -0
- package/src/server/mcp-progress-reporter.spec.ts +93 -0
- package/src/server/mcp-progress-reporter.ts +67 -0
- package/src/server/mcp-prompt-handler.ts +157 -0
- package/src/server/mcp-request-context.ts +39 -0
- package/src/server/mcp-resource-handler.ts +389 -0
- package/src/server/mcp-server-launcher.spec.ts +173 -0
- package/src/server/mcp-server-launcher.ts +369 -0
- package/src/server/mcp-session.ts +45 -0
- package/src/server/mcp-tool-handler.spec.ts +182 -0
- package/src/server/mcp-tool-handler.ts +431 -0
- package/src/server/raw-http.spec.ts +59 -0
- package/src/tools/handlers/count-elements-mcp-tool-handler.spec.ts +101 -0
- package/src/tools/handlers/count-elements-mcp-tool-handler.ts +68 -0
- package/src/tools/handlers/create-edges-mcp-tool-handler.spec.ts +198 -0
- package/src/tools/handlers/create-edges-mcp-tool-handler.ts +200 -0
- package/src/tools/handlers/create-nodes-mcp-tool-handler.spec.ts +199 -0
- package/src/tools/handlers/create-nodes-mcp-tool-handler.ts +126 -0
- package/src/tools/handlers/delete-elements-mcp-tool-handler.ts +69 -0
- package/src/tools/handlers/diagram-model-mcp-tool-handler.ts +68 -0
- package/src/tools/handlers/element-types-mcp-tool-handler.ts +152 -0
- package/src/tools/handlers/get-selection-mcp-tool-handler.ts +56 -0
- package/src/tools/handlers/layout-mcp-tool-handler.ts +58 -0
- package/src/tools/handlers/modify-edges-mcp-tool-handler.ts +142 -0
- package/src/tools/handlers/modify-nodes-mcp-tool-handler.ts +134 -0
- package/src/tools/handlers/query-elements-mcp-tool-handler.spec.ts +212 -0
- package/src/tools/handlers/query-elements-mcp-tool-handler.ts +157 -0
- package/src/tools/handlers/redo-mcp-tool-handler.ts +64 -0
- package/src/tools/handlers/save-model-mcp-tool-handler.ts +74 -0
- package/src/tools/handlers/session-info-mcp-tool-handler.spec.ts +152 -0
- package/src/tools/handlers/session-info-mcp-tool-handler.ts +98 -0
- package/src/tools/handlers/set-selection-mcp-tool-handler.spec.ts +120 -0
- package/src/tools/handlers/set-selection-mcp-tool-handler.ts +92 -0
- package/src/tools/handlers/set-view-mcp-tool-handler.ts +156 -0
- package/src/tools/handlers/undo-mcp-tool-handler.ts +63 -0
- package/src/tools/handlers/validate-diagram-mcp-tool-handler.ts +0 -0
- package/src/tools/tool-annotations.spec.ts +141 -0
- package/src/util/markdown-util.ts +44 -0
- package/src/util/mcp-util.ts +25 -0
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eclipse-glsp/server-mcp",
|
|
3
|
+
"version": "2.7.0-next.10+bed0bb0",
|
|
4
|
+
"description": "Extension of the GLSP Node Server for the Model Context Protocol",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"eclipse",
|
|
7
|
+
"graphics",
|
|
8
|
+
"diagram",
|
|
9
|
+
"modeling",
|
|
10
|
+
"visualization",
|
|
11
|
+
"glsp",
|
|
12
|
+
"diagram editor",
|
|
13
|
+
"mcp"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://www.eclipse.org/glsp/",
|
|
16
|
+
"bugs": "https://github.com/eclipse-glsp/glsp/issues",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/eclipse-glsp/glsp-server-node.git"
|
|
20
|
+
},
|
|
21
|
+
"license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",
|
|
22
|
+
"author": {
|
|
23
|
+
"name": "Eclipse GLSP"
|
|
24
|
+
},
|
|
25
|
+
"contributors": [
|
|
26
|
+
{
|
|
27
|
+
"name": "Eclipse GLSP Project",
|
|
28
|
+
"email": "glsp-dev@eclipse.org",
|
|
29
|
+
"url": "https://projects.eclipse.org/projects/ecd.glsp"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"main": "lib/index",
|
|
33
|
+
"types": "lib/index",
|
|
34
|
+
"files": [
|
|
35
|
+
"lib",
|
|
36
|
+
"src"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc -b",
|
|
40
|
+
"clean": "rimraf lib *.tsbuildinfo coverage .nyc_output",
|
|
41
|
+
"generate:index": "glsp generateIndex src -f -s",
|
|
42
|
+
"lint": "eslint --ext .ts,.tsx ./src",
|
|
43
|
+
"test": "mocha --config ../../.mocharc \"./src/**/*.spec.?(ts|tsx)\"",
|
|
44
|
+
"test:ci": "yarn test --reporter mocha-ctrf-json-reporter",
|
|
45
|
+
"test:coverage": "nyc yarn test",
|
|
46
|
+
"watch": "tsc -w"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@eclipse-glsp/server": "2.7.0-next.10+bed0bb0",
|
|
50
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
51
|
+
"express": "^5.2.1"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/express": "^5.0.6"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"inversify": "^6.1.3"
|
|
58
|
+
},
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public"
|
|
61
|
+
},
|
|
62
|
+
"gitHead": "bed0bb089fb49e7a5cf5be5dfe02d4116dae944f"
|
|
63
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2025-2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
export * from './modules/mcp-diagram-module';
|
|
17
|
+
export * from './modules/mcp-server-module';
|
|
18
|
+
export * from './prompts/handlers/describe-diagram-mcp-prompt-handler';
|
|
19
|
+
export * from './prompts/handlers/suggest-improvements-mcp-prompt-handler';
|
|
20
|
+
export * from './resources/handlers/diagram-png-mcp-resource-handler';
|
|
21
|
+
export * from './resources/handlers/diagram-svg-mcp-resource-handler';
|
|
22
|
+
export * from './resources/services/element-types-provider';
|
|
23
|
+
export * from './resources/services/mcp-model-serializer';
|
|
24
|
+
export * from './server/glsp-mcp-server';
|
|
25
|
+
export * from './server/lru-event-store';
|
|
26
|
+
export * from './server/mcp-diagram-handler-dispatcher';
|
|
27
|
+
export * from './server/mcp-diagram-prompt-handler-registry';
|
|
28
|
+
export * from './server/mcp-diagram-resource-handler-registry';
|
|
29
|
+
export * from './server/mcp-diagram-tool-handler-registry';
|
|
30
|
+
export * from './server/mcp-handler-shared';
|
|
31
|
+
export * from './server/mcp-http-transport';
|
|
32
|
+
export * from './server/mcp-id-alias-service';
|
|
33
|
+
export * from './server/mcp-input-schemas';
|
|
34
|
+
export * from './server/mcp-label-provider';
|
|
35
|
+
export * from './server/mcp-log-level-registry';
|
|
36
|
+
export * from './server/mcp-logger';
|
|
37
|
+
export * from './server/mcp-mime-types';
|
|
38
|
+
export * from './server/mcp-options';
|
|
39
|
+
export * from './server/mcp-progress-reporter';
|
|
40
|
+
export * from './server/mcp-prompt-handler';
|
|
41
|
+
export * from './server/mcp-request-context';
|
|
42
|
+
export * from './server/mcp-resource-handler';
|
|
43
|
+
export * from './server/mcp-server-launcher';
|
|
44
|
+
export * from './server/mcp-session';
|
|
45
|
+
export * from './server/mcp-tool-handler';
|
|
46
|
+
export * from './tools/handlers/count-elements-mcp-tool-handler';
|
|
47
|
+
export * from './tools/handlers/create-edges-mcp-tool-handler';
|
|
48
|
+
export * from './tools/handlers/create-nodes-mcp-tool-handler';
|
|
49
|
+
export * from './tools/handlers/delete-elements-mcp-tool-handler';
|
|
50
|
+
export * from './tools/handlers/diagram-model-mcp-tool-handler';
|
|
51
|
+
export * from './tools/handlers/element-types-mcp-tool-handler';
|
|
52
|
+
export * from './tools/handlers/get-selection-mcp-tool-handler';
|
|
53
|
+
export * from './tools/handlers/layout-mcp-tool-handler';
|
|
54
|
+
export * from './tools/handlers/modify-edges-mcp-tool-handler';
|
|
55
|
+
export * from './tools/handlers/modify-nodes-mcp-tool-handler';
|
|
56
|
+
export * from './tools/handlers/query-elements-mcp-tool-handler';
|
|
57
|
+
export * from './tools/handlers/redo-mcp-tool-handler';
|
|
58
|
+
export * from './tools/handlers/save-model-mcp-tool-handler';
|
|
59
|
+
export * from './tools/handlers/session-info-mcp-tool-handler';
|
|
60
|
+
export * from './tools/handlers/set-selection-mcp-tool-handler';
|
|
61
|
+
export * from './tools/handlers/set-view-mcp-tool-handler';
|
|
62
|
+
export * from './tools/handlers/undo-mcp-tool-handler';
|
|
63
|
+
export * from './tools/handlers/validate-diagram-mcp-tool-handler';
|
|
64
|
+
export * from './util/markdown-util';
|
|
65
|
+
export * from './util/mcp-util';
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
|
|
17
|
+
import { applyBindingTarget, BindingTarget, ClientSessionInitializer, GLSPModule, InstanceMultiBinding } from '@eclipse-glsp/server';
|
|
18
|
+
import { interfaces } from 'inversify';
|
|
19
|
+
import { DiagramPngMcpResourceHandler } from '../resources/handlers/diagram-png-mcp-resource-handler';
|
|
20
|
+
import { DiagramSvgMcpResourceHandler } from '../resources/handlers/diagram-svg-mcp-resource-handler';
|
|
21
|
+
import { DefaultElementTypesProvider, ElementTypesProvider } from '../resources/services/element-types-provider';
|
|
22
|
+
import { MarkdownMcpModelSerializer, McpModelSerializer } from '../resources/services/mcp-model-serializer';
|
|
23
|
+
import { CountElementsMcpToolHandler } from '../tools/handlers/count-elements-mcp-tool-handler';
|
|
24
|
+
import { CreateEdgesMcpToolHandler } from '../tools/handlers/create-edges-mcp-tool-handler';
|
|
25
|
+
import { CreateNodesMcpToolHandler } from '../tools/handlers/create-nodes-mcp-tool-handler';
|
|
26
|
+
import { DeleteElementsMcpToolHandler } from '../tools/handlers/delete-elements-mcp-tool-handler';
|
|
27
|
+
import { DiagramModelMcpToolHandler } from '../tools/handlers/diagram-model-mcp-tool-handler';
|
|
28
|
+
import { GetSelectionMcpToolHandler } from '../tools/handlers/get-selection-mcp-tool-handler';
|
|
29
|
+
import { LayoutMcpToolHandler } from '../tools/handlers/layout-mcp-tool-handler';
|
|
30
|
+
import { ModifyEdgesMcpToolHandler } from '../tools/handlers/modify-edges-mcp-tool-handler';
|
|
31
|
+
import { ModifyNodesMcpToolHandler } from '../tools/handlers/modify-nodes-mcp-tool-handler';
|
|
32
|
+
import { QueryElementsMcpToolHandler } from '../tools/handlers/query-elements-mcp-tool-handler';
|
|
33
|
+
import { RedoMcpToolHandler } from '../tools/handlers/redo-mcp-tool-handler';
|
|
34
|
+
import { SaveModelMcpToolHandler } from '../tools/handlers/save-model-mcp-tool-handler';
|
|
35
|
+
import { SetSelectionMcpToolHandler } from '../tools/handlers/set-selection-mcp-tool-handler';
|
|
36
|
+
import { SetViewMcpToolHandler } from '../tools/handlers/set-view-mcp-tool-handler';
|
|
37
|
+
import { UndoMcpToolHandler } from '../tools/handlers/undo-mcp-tool-handler';
|
|
38
|
+
import { ValidateDiagramMcpToolHandler } from '../tools/handlers/validate-diagram-mcp-tool-handler';
|
|
39
|
+
import {
|
|
40
|
+
McpDiagramPromptHandlerFactory,
|
|
41
|
+
McpDiagramPromptHandlerRegistry,
|
|
42
|
+
McpDiagramPromptHandlerRegistryInitializer
|
|
43
|
+
} from '../server/mcp-diagram-prompt-handler-registry';
|
|
44
|
+
import {
|
|
45
|
+
McpDiagramResourceHandlerFactory,
|
|
46
|
+
McpDiagramResourceHandlerRegistry,
|
|
47
|
+
McpDiagramResourceHandlerRegistryInitializer
|
|
48
|
+
} from '../server/mcp-diagram-resource-handler-registry';
|
|
49
|
+
import {
|
|
50
|
+
McpDiagramToolHandlerFactory,
|
|
51
|
+
McpDiagramToolHandlerRegistry,
|
|
52
|
+
McpDiagramToolHandlerRegistryInitializer
|
|
53
|
+
} from '../server/mcp-diagram-tool-handler-registry';
|
|
54
|
+
import { DefaultMcpIdAliasService, McpIdAliasService } from '../server/mcp-id-alias-service';
|
|
55
|
+
import { McpDiagramScopedInput } from '../server/mcp-input-schemas';
|
|
56
|
+
import { DefaultMcpLabelProvider, McpLabelProvider } from '../server/mcp-label-provider';
|
|
57
|
+
import { AbstractMcpDiagramPromptHandler, McpDiagramPromptHandlerConstructor } from '../server/mcp-prompt-handler';
|
|
58
|
+
import { AbstractMcpDiagramResourceHandler, McpDiagramResourceHandlerConstructor } from '../server/mcp-resource-handler';
|
|
59
|
+
import { BaseMcpDiagramToolHandler, McpDiagramToolHandlerConstructor } from '../server/mcp-tool-handler';
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Per-GLSP-client-session DI module for the MCP server. Loaded inside `configureDiagramModule`
|
|
63
|
+
* so each `ClientSession.container` gets its own instance of session-scoped services.
|
|
64
|
+
*
|
|
65
|
+
* Binds the {@link McpIdAliasService}, the {@link McpModelSerializer}, the
|
|
66
|
+
* {@link ElementTypesProvider}, and the diagram-scope handler-constructor multi-bindings
|
|
67
|
+
* (`McpDiagram*HandlerConstructor`). Adopters subclass and override the `bind*` hooks to swap
|
|
68
|
+
* single-instance services and the `configure*` hooks to extend the multi-binding handler sets.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* class WorkflowMcpDiagramModule extends DefaultMcpDiagramModule {
|
|
73
|
+
* // Single-instance binding: return the class.
|
|
74
|
+
* protected override bindModelSerializer(): BindingTarget<McpModelSerializer> {
|
|
75
|
+
* return WorkflowMcpModelSerializer;
|
|
76
|
+
* }
|
|
77
|
+
* // Multi-binding: extend or rebind the default set.
|
|
78
|
+
* protected override configureToolHandlers(binding) {
|
|
79
|
+
* super.configureToolHandlers(binding);
|
|
80
|
+
* binding.add(WorkflowExtraTool);
|
|
81
|
+
* binding.rebind(CreateNodesMcpToolHandler, WorkflowCreateNodesMcpToolHandler);
|
|
82
|
+
* }
|
|
83
|
+
* }
|
|
84
|
+
* new WorkflowServerModule().configureDiagramModule(
|
|
85
|
+
* new WorkflowDiagramModule(...),
|
|
86
|
+
* elkLayoutModule,
|
|
87
|
+
* new WorkflowMcpDiagramModule()
|
|
88
|
+
* );
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export abstract class AbstractMcpDiagramModule extends GLSPModule {
|
|
92
|
+
protected bind!: interfaces.Bind;
|
|
93
|
+
protected rebind!: interfaces.Rebind;
|
|
94
|
+
|
|
95
|
+
protected override configure(
|
|
96
|
+
bind: interfaces.Bind,
|
|
97
|
+
_unbind: interfaces.Unbind,
|
|
98
|
+
isBound: interfaces.IsBound,
|
|
99
|
+
rebind: interfaces.Rebind
|
|
100
|
+
): void {
|
|
101
|
+
this.bind = bind;
|
|
102
|
+
this.rebind = rebind;
|
|
103
|
+
const context = { bind, isBound };
|
|
104
|
+
applyBindingTarget(context, McpIdAliasService, this.bindIdAliasService()).inSingletonScope();
|
|
105
|
+
applyBindingTarget(context, McpLabelProvider, this.bindLabelProvider()).inSingletonScope();
|
|
106
|
+
applyBindingTarget(context, McpModelSerializer, this.bindModelSerializer()).inSingletonScope();
|
|
107
|
+
applyBindingTarget(context, ElementTypesProvider, this.bindElementTypesProvider()).inSingletonScope();
|
|
108
|
+
this.configureMultiBinding(new InstanceMultiBinding<McpDiagramToolHandlerConstructor>(McpDiagramToolHandlerConstructor), binding =>
|
|
109
|
+
this.configureToolHandlers(binding as InstanceMultiBinding<McpDiagramToolHandlerConstructor>)
|
|
110
|
+
);
|
|
111
|
+
this.configureMultiBinding(
|
|
112
|
+
new InstanceMultiBinding<McpDiagramResourceHandlerConstructor>(McpDiagramResourceHandlerConstructor),
|
|
113
|
+
binding => this.configureResourceHandlers(binding as InstanceMultiBinding<McpDiagramResourceHandlerConstructor>)
|
|
114
|
+
);
|
|
115
|
+
this.configureMultiBinding(
|
|
116
|
+
new InstanceMultiBinding<McpDiagramPromptHandlerConstructor>(McpDiagramPromptHandlerConstructor),
|
|
117
|
+
binding => this.configurePromptHandlers(binding as InstanceMultiBinding<McpDiagramPromptHandlerConstructor>)
|
|
118
|
+
);
|
|
119
|
+
this.configureHandlerRegistries();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Bind the per-GLSP-session handler registries, factories, and {@link ClientSessionInitializer}s
|
|
124
|
+
* that populate the registries at session-open. Adopters typically don't override.
|
|
125
|
+
*
|
|
126
|
+
* Each kind (tool / resource / prompt) follows the same shape:
|
|
127
|
+
* - `Registry` — singleton-per-session, holds instantiated handlers keyed by `name`.
|
|
128
|
+
* - `Factory` — `dynamicValue` that calls `ctx.container.resolve(constructor)`, so the
|
|
129
|
+
* handler's `@inject(...)` fields resolve against the live `ClientSession.container`.
|
|
130
|
+
* - `RegistryInitializer` — at session-open, reads the constructor multi-binding (added by
|
|
131
|
+
* adopter `configure*Handlers` overrides) and instantiates each via the factory.
|
|
132
|
+
* Picked up by Inversify alongside core's own `ClientSessionInitializer`s
|
|
133
|
+
* (`OperationHandlerRegistryInitializer` etc.).
|
|
134
|
+
*/
|
|
135
|
+
protected configureHandlerRegistries(): void {
|
|
136
|
+
this.bind(McpDiagramToolHandlerRegistry).toSelf().inSingletonScope();
|
|
137
|
+
this.bind<McpDiagramToolHandlerFactory>(McpDiagramToolHandlerFactory).toDynamicValue(
|
|
138
|
+
ctx => (constructor: McpDiagramToolHandlerConstructor) =>
|
|
139
|
+
ctx.container.resolve<BaseMcpDiagramToolHandler<McpDiagramScopedInput>>(constructor)
|
|
140
|
+
);
|
|
141
|
+
this.bind(McpDiagramToolHandlerRegistryInitializer).toSelf().inSingletonScope();
|
|
142
|
+
this.bind(ClientSessionInitializer).toService(McpDiagramToolHandlerRegistryInitializer);
|
|
143
|
+
|
|
144
|
+
this.bind(McpDiagramResourceHandlerRegistry).toSelf().inSingletonScope();
|
|
145
|
+
this.bind<McpDiagramResourceHandlerFactory>(McpDiagramResourceHandlerFactory).toDynamicValue(
|
|
146
|
+
ctx => (constructor: McpDiagramResourceHandlerConstructor) =>
|
|
147
|
+
ctx.container.resolve<AbstractMcpDiagramResourceHandler<McpDiagramScopedInput>>(constructor)
|
|
148
|
+
);
|
|
149
|
+
this.bind(McpDiagramResourceHandlerRegistryInitializer).toSelf().inSingletonScope();
|
|
150
|
+
this.bind(ClientSessionInitializer).toService(McpDiagramResourceHandlerRegistryInitializer);
|
|
151
|
+
|
|
152
|
+
this.bind(McpDiagramPromptHandlerRegistry).toSelf().inSingletonScope();
|
|
153
|
+
this.bind<McpDiagramPromptHandlerFactory>(McpDiagramPromptHandlerFactory).toDynamicValue(
|
|
154
|
+
ctx => (constructor: McpDiagramPromptHandlerConstructor) =>
|
|
155
|
+
ctx.container.resolve<AbstractMcpDiagramPromptHandler<McpDiagramScopedInput>>(constructor)
|
|
156
|
+
);
|
|
157
|
+
this.bind(McpDiagramPromptHandlerRegistryInitializer).toSelf().inSingletonScope();
|
|
158
|
+
this.bind(ClientSessionInitializer).toService(McpDiagramPromptHandlerRegistryInitializer);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* {@link McpIdAliasService} binding. Override to swap in a custom alias strategy. Bind the
|
|
163
|
+
* shipped `NullMcpIdAliasService` (passthrough) to expose raw GLSP ids on the wire — useful
|
|
164
|
+
* for diagnostic readability or when token cost isn't a concern.
|
|
165
|
+
*/
|
|
166
|
+
protected bindIdAliasService(): BindingTarget<McpIdAliasService> {
|
|
167
|
+
return DefaultMcpIdAliasService;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* {@link McpLabelProvider} binding. Override to teach MCP about adopter-specific label
|
|
172
|
+
* locations (e.g., labels nested in header components or compartments). One override here
|
|
173
|
+
* covers every read-side echo and every write-side label-edit operation.
|
|
174
|
+
*/
|
|
175
|
+
protected bindLabelProvider(): BindingTarget<McpLabelProvider> {
|
|
176
|
+
return DefaultMcpLabelProvider;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* {@link McpModelSerializer} binding. Override to swap in a diagram-type-specific serializer
|
|
181
|
+
* (e.g. one that emits JSON, or knows the adopter's element schema). Per-session scope means
|
|
182
|
+
* each diagram type provides its own serializer without a server-level rebind.
|
|
183
|
+
*/
|
|
184
|
+
protected bindModelSerializer(): BindingTarget<McpModelSerializer> {
|
|
185
|
+
return MarkdownMcpModelSerializer;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* {@link ElementTypesProvider} binding. Override to ship a constant-value list of creatable
|
|
190
|
+
* element types for the adopter's diagram type instead of the default impl that scrapes
|
|
191
|
+
* {@link OperationHandlerRegistry} (noisy for non-trivial diagrams).
|
|
192
|
+
*/
|
|
193
|
+
protected bindElementTypesProvider(): BindingTarget<ElementTypesProvider> {
|
|
194
|
+
return DefaultElementTypesProvider;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Override to add or replace diagram-scope tool handlers. Adopters typically
|
|
199
|
+
* `super.configureToolHandlers(binding)` to keep the defaults, then `binding.add(MyTool)`
|
|
200
|
+
* for additions or `binding.rebind(StandardTool, MyTool)` for overrides.
|
|
201
|
+
*/
|
|
202
|
+
protected configureToolHandlers(binding: InstanceMultiBinding<McpDiagramToolHandlerConstructor>): void {
|
|
203
|
+
binding.add(CreateNodesMcpToolHandler);
|
|
204
|
+
binding.add(CreateEdgesMcpToolHandler);
|
|
205
|
+
binding.add(DeleteElementsMcpToolHandler);
|
|
206
|
+
binding.add(SaveModelMcpToolHandler);
|
|
207
|
+
binding.add(ValidateDiagramMcpToolHandler);
|
|
208
|
+
binding.add(DiagramModelMcpToolHandler);
|
|
209
|
+
binding.add(QueryElementsMcpToolHandler);
|
|
210
|
+
binding.add(CountElementsMcpToolHandler);
|
|
211
|
+
binding.add(ModifyNodesMcpToolHandler);
|
|
212
|
+
binding.add(ModifyEdgesMcpToolHandler);
|
|
213
|
+
binding.add(UndoMcpToolHandler);
|
|
214
|
+
binding.add(RedoMcpToolHandler);
|
|
215
|
+
binding.add(GetSelectionMcpToolHandler);
|
|
216
|
+
binding.add(SetSelectionMcpToolHandler);
|
|
217
|
+
binding.add(SetViewMcpToolHandler);
|
|
218
|
+
// Auto-skips at session-open via `canRegister()` when no `LayoutEngine` is bound.
|
|
219
|
+
binding.add(LayoutMcpToolHandler);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** See {@link configureToolHandlers}. */
|
|
223
|
+
protected configureResourceHandlers(binding: InstanceMultiBinding<McpDiagramResourceHandlerConstructor>): void {
|
|
224
|
+
binding.add(DiagramPngMcpResourceHandler);
|
|
225
|
+
binding.add(DiagramSvgMcpResourceHandler);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* See {@link configureToolHandlers}. No diagram-scope prompts ship by default — the shipped
|
|
230
|
+
* `describe-diagram` and `suggest-improvements` prompts are diagram-type-agnostic and bound
|
|
231
|
+
* server-scope. Adopters add their own diagram-type-specific prompts here.
|
|
232
|
+
*/
|
|
233
|
+
protected configurePromptHandlers(_binding: InstanceMultiBinding<McpDiagramPromptHandlerConstructor>): void {
|
|
234
|
+
// empty by default
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Default {@link AbstractMcpDiagramModule} entry point. Adopters who don't need overrides
|
|
240
|
+
* use it directly: `new DefaultMcpDiagramModule()`. Adopters with customizations subclass
|
|
241
|
+
* `AbstractMcpDiagramModule` (or this class) and override the `bind*` / `configure*` hooks.
|
|
242
|
+
*
|
|
243
|
+
* @experimental The MCP integration is under active development. Option names, schema shapes,
|
|
244
|
+
* and handler contracts MAY change in minor releases until the feature graduates from
|
|
245
|
+
* experimental status.
|
|
246
|
+
*/
|
|
247
|
+
export class DefaultMcpDiagramModule extends AbstractMcpDiagramModule {}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
|
|
17
|
+
import { McpServerOptions as McpServerOptionsType } from '@eclipse-glsp/protocol';
|
|
18
|
+
import { BindingContext } from '@eclipse-glsp/protocol/lib/di';
|
|
19
|
+
import {
|
|
20
|
+
AbstractMultiBinding,
|
|
21
|
+
applyBindingTarget,
|
|
22
|
+
BindingTarget,
|
|
23
|
+
GLSPModule,
|
|
24
|
+
GLSPServerInitializer,
|
|
25
|
+
GLSPServerListener,
|
|
26
|
+
Logger
|
|
27
|
+
} from '@eclipse-glsp/server';
|
|
28
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
29
|
+
import { interfaces } from 'inversify';
|
|
30
|
+
import { DescribeDiagramMcpPromptHandler } from '../prompts/handlers/describe-diagram-mcp-prompt-handler';
|
|
31
|
+
import { SuggestImprovementsMcpPromptHandler } from '../prompts/handlers/suggest-improvements-mcp-prompt-handler';
|
|
32
|
+
import { ElementTypesMcpToolHandler } from '../tools/handlers/element-types-mcp-tool-handler';
|
|
33
|
+
import { SessionInfoMcpToolHandler } from '../tools/handlers/session-info-mcp-tool-handler';
|
|
34
|
+
import { DefaultGLSPMcpServer, GLSPMcpServerFactory } from '../server/glsp-mcp-server';
|
|
35
|
+
import { DefaultMcpDiagramHandlerDispatcher, McpDiagramHandlerDispatcher } from '../server/mcp-diagram-handler-dispatcher';
|
|
36
|
+
import { DefaultMcpLogLevelRegistry, McpLogLevelRegistry } from '../server/mcp-log-level-registry';
|
|
37
|
+
import { LruEventStore } from '../server/lru-event-store';
|
|
38
|
+
import { McpHttpTransport } from '../server/mcp-http-transport';
|
|
39
|
+
import { McpLogger } from '../server/mcp-logger';
|
|
40
|
+
import { McpServerDefaults, McpServerOptions } from '../server/mcp-options';
|
|
41
|
+
import { McpProgressReporter } from '../server/mcp-progress-reporter';
|
|
42
|
+
import { McpPromptHandler } from '../server/mcp-prompt-handler';
|
|
43
|
+
import { McpResourceHandler } from '../server/mcp-resource-handler';
|
|
44
|
+
import { McpServerLauncher } from '../server/mcp-server-launcher';
|
|
45
|
+
import { McpToolHandler } from '../server/mcp-tool-handler';
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* GLSP-generic default agent persona — adopters typically pass a product-specific persona to
|
|
49
|
+
* the {@link DefaultMcpServerModule} constructor (e.g. workflow-server might say "You are the
|
|
50
|
+
* Workflow Modeling Agent...").
|
|
51
|
+
*
|
|
52
|
+
* **Spec note.** This is wired to the MCP `instructions` field, which the spec describes as
|
|
53
|
+
* "concise instructions". This persona is intentionally verbose (~700 chars of behavior rules)
|
|
54
|
+
* — within the spec's "free-form server-supplied instructions" allowance and adopter-overridable
|
|
55
|
+
* via `mcpDefaults.agentPersona`. Don't trim on autopilot if a "concise" interpretation drifts
|
|
56
|
+
* back: the verbose form materially improves LLM tool-use compliance for graphical modelling.
|
|
57
|
+
*/
|
|
58
|
+
const DEFAULT_AGENT_PERSONA = `
|
|
59
|
+
You are the GLSP Modeling Agent. Your primary goal is to assist in the creation and modification of graphical models using the
|
|
60
|
+
GLSP MCP server. You have to adhere to the following principles:
|
|
61
|
+
- MCP-Interaction: Any modeling related activity has to occur using the MCP server.
|
|
62
|
+
- Real Data: The diagram model is the ground truth regarding the existing graphical model. Always query it before modifying the diagram.
|
|
63
|
+
- Real Creation: Consult the available element types before creating elements.
|
|
64
|
+
- Visual Proof: An image of the graphical model can be created, if you deem it useful for calculating or verifying layout decisions.
|
|
65
|
+
- Precision: All IDs and types must be exact.
|
|
66
|
+
- Visualization: When creating nodes, suggest sensible default positions and avoid visual overlapping.
|
|
67
|
+
- Careful: Under no circumstances save the model without explicit instruction. If you deem it sensible, you may ask the user for permission.
|
|
68
|
+
The same goes for Undo/Redo operations.
|
|
69
|
+
- Layouting: If available, make use of automatic layouting when not given explicit custom layouting requirements.
|
|
70
|
+
- Human-friendly references: When mentioning an element in user-visible prose, prefer its label, then its element type
|
|
71
|
+
(the bare ids returned by the tools are internal aliases that mean nothing to the user). Append the alias in parentheses
|
|
72
|
+
so the user can correlate it with follow-up tools. Use the \`set-selection\` tool — or the \`set-view\` tool with
|
|
73
|
+
\`action: "center-on-elements"\` — to point the user at the elements you reference.
|
|
74
|
+
`;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Multi-binding helper for MCP handler classes. Singleton-scoped sibling of core's
|
|
78
|
+
* `MultiBinding<T>` — same `binding.add(...)` / `binding.rebind(old, new)` adopter shape, but
|
|
79
|
+
* core's plain `MultiBinding` binds in transient scope, while MCP handlers cache deferred
|
|
80
|
+
* resolvers (selection/PNG round-trips) and need singleton scope to keep their state.
|
|
81
|
+
*/
|
|
82
|
+
export class McpHandlerMultiBinding<T> extends AbstractMultiBinding<interfaces.Newable<T>> {
|
|
83
|
+
override applyBindings(context: BindingContext): void {
|
|
84
|
+
this.bindings.forEach(handlerClass => {
|
|
85
|
+
if (!context.isBound(handlerClass)) {
|
|
86
|
+
context.bind(handlerClass).toSelf().inSingletonScope();
|
|
87
|
+
}
|
|
88
|
+
context.bind(this.identifier).toService(handlerClass);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Server-scope DI module for the MCP server. Adopters subclass {@link DefaultMcpServerModule}
|
|
95
|
+
* and override the `bind*` hooks to swap single-instance services or the `configure*` hooks to
|
|
96
|
+
* add/replace handlers in the multi-bindings. Mirrors the `DiagramModule` pattern from core
|
|
97
|
+
* (`bindGModelSerializer()`, `configureActionHandlers(binding)`, etc.).
|
|
98
|
+
*
|
|
99
|
+
* Adopter-provided default option values flow through the constructor — pass a
|
|
100
|
+
* `Partial<McpServerOptions>` to override individual fields. The launcher then merges these
|
|
101
|
+
* defaults with init-time options from the GLSP `initialize` request (init-time wins per field).
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* // Drop-in: GLSP defaults.
|
|
106
|
+
* launcher.configure(serverModule, new DefaultMcpServerModule());
|
|
107
|
+
*
|
|
108
|
+
* // Drop-in with a product-specific override.
|
|
109
|
+
* launcher.configure(serverModule, new DefaultMcpServerModule({ dataMode: 'resources' }));
|
|
110
|
+
*
|
|
111
|
+
* // Subclass when handler customization is needed.
|
|
112
|
+
* class WorkflowMcpServerModule extends DefaultMcpServerModule {
|
|
113
|
+
* constructor() { super({ agentPersona: WORKFLOW_PERSONA }); }
|
|
114
|
+
* protected override configureToolHandlers(binding) {
|
|
115
|
+
* super.configureToolHandlers(binding);
|
|
116
|
+
* binding.add(WorkflowSpecificTool);
|
|
117
|
+
* }
|
|
118
|
+
* }
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export abstract class AbstractMcpServerModule extends GLSPModule {
|
|
122
|
+
protected bind!: interfaces.Bind;
|
|
123
|
+
protected rebind!: interfaces.Rebind;
|
|
124
|
+
|
|
125
|
+
constructor(protected readonly defaultOptions: McpServerDefaults = {}) {
|
|
126
|
+
super();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
protected override configure(
|
|
130
|
+
bind: interfaces.Bind,
|
|
131
|
+
_unbind: interfaces.Unbind,
|
|
132
|
+
isBound: interfaces.IsBound,
|
|
133
|
+
rebind: interfaces.Rebind
|
|
134
|
+
): void {
|
|
135
|
+
this.bind = bind;
|
|
136
|
+
this.rebind = rebind;
|
|
137
|
+
const context = { bind, isBound };
|
|
138
|
+
applyBindingTarget(context, McpServerLauncher, this.bindMcpServerLauncher()).inSingletonScope();
|
|
139
|
+
// The launcher is bound under two additional service identifiers so core's existing
|
|
140
|
+
// multi-bindings pick it up alongside the rest of the server's contributions/listeners.
|
|
141
|
+
bind(GLSPServerInitializer).toService(McpServerLauncher);
|
|
142
|
+
bind(GLSPServerListener).toService(McpServerLauncher);
|
|
143
|
+
applyBindingTarget(context, McpHttpTransport, this.bindMcpHttpTransport()).inSingletonScope();
|
|
144
|
+
applyBindingTarget(context, McpDiagramHandlerDispatcher, this.bindMcpDiagramHandlerDispatcher()).inSingletonScope();
|
|
145
|
+
applyBindingTarget(context, McpServerOptions, this.bindMcpServerOptions()).inSingletonScope();
|
|
146
|
+
applyBindingTarget(context, McpServerDefaults, this.bindMcpServerDefaults());
|
|
147
|
+
applyBindingTarget(context, McpLogger, this.bindMcpLogger()).inSingletonScope();
|
|
148
|
+
applyBindingTarget(context, McpLogLevelRegistry, this.bindMcpLogLevelRegistry()).inSingletonScope();
|
|
149
|
+
applyBindingTarget(context, McpProgressReporter, this.bindMcpProgressReporter()).inSingletonScope();
|
|
150
|
+
applyBindingTarget(context, GLSPMcpServerFactory, this.bindGLSPMcpServerFactory());
|
|
151
|
+
this.configureMultiBinding(new McpHandlerMultiBinding<McpToolHandler>(McpToolHandler), binding =>
|
|
152
|
+
this.configureToolHandlers(binding as McpHandlerMultiBinding<McpToolHandler>)
|
|
153
|
+
);
|
|
154
|
+
this.configureMultiBinding(new McpHandlerMultiBinding<McpResourceHandler>(McpResourceHandler), binding =>
|
|
155
|
+
this.configureResourceHandlers(binding as McpHandlerMultiBinding<McpResourceHandler>)
|
|
156
|
+
);
|
|
157
|
+
this.configureMultiBinding(new McpHandlerMultiBinding<McpPromptHandler>(McpPromptHandler), binding =>
|
|
158
|
+
this.configurePromptHandlers(binding as McpHandlerMultiBinding<McpPromptHandler>)
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* {@link McpServerLauncher} binding. Bound as a singleton AND aliased to
|
|
164
|
+
* `GLSPServerInitializer` + `GLSPServerListener` (the launcher implements both).
|
|
165
|
+
* Override to swap in a custom launcher impl.
|
|
166
|
+
*/
|
|
167
|
+
protected bindMcpServerLauncher(): BindingTarget<McpServerLauncher> {
|
|
168
|
+
return McpServerLauncher;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** {@link McpHttpTransport} binding. Override to swap to a different transport implementation. */
|
|
172
|
+
protected bindMcpHttpTransport(): BindingTarget<McpHttpTransport> {
|
|
173
|
+
return McpHttpTransport;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* {@link McpDiagramHandlerDispatcher} binding. Owns diagram-scope handler discovery,
|
|
178
|
+
* SDK registration, and per-call dispatch routing. Override (or `rebind` to a subclass)
|
|
179
|
+
* to customize registration without subclassing the launcher itself.
|
|
180
|
+
*/
|
|
181
|
+
protected bindMcpDiagramHandlerDispatcher(): BindingTarget<McpDiagramHandlerDispatcher> {
|
|
182
|
+
return DefaultMcpDiagramHandlerDispatcher;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** {@link McpServerOptions} holder binding. Mutated at init by the launcher. */
|
|
186
|
+
protected bindMcpServerOptions(): BindingTarget<McpServerOptions> {
|
|
187
|
+
return McpServerOptions;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* {@link McpServerDefaults} binding — adopter-supplied default option values flow through
|
|
192
|
+
* the constructor and land here as a constant. The launcher merges these defaults with
|
|
193
|
+
* init-time options at server init (init-time wins per field).
|
|
194
|
+
*/
|
|
195
|
+
protected bindMcpServerDefaults(): BindingTarget<McpServerDefaults> {
|
|
196
|
+
return { constantValue: this.defaultOptions };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* {@link McpLogger} binding. Bound on the server container; per-session containers inherit
|
|
201
|
+
* it, so handlers at any scope can inject it; routes through the active MCP request via
|
|
202
|
+
* {@link mcpRequestContext}.
|
|
203
|
+
*/
|
|
204
|
+
protected bindMcpLogger(): BindingTarget<McpLogger> {
|
|
205
|
+
return McpLogger;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/** {@link McpProgressReporter} binding. Same scope/lifecycle story as {@link bindMcpLogger}. */
|
|
209
|
+
protected bindMcpProgressReporter(): BindingTarget<McpProgressReporter> {
|
|
210
|
+
return McpProgressReporter;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* {@link McpLogLevelRegistry} binding — holds per-MCP-session `logging/setLevel` thresholds
|
|
215
|
+
* read by {@link McpLogger} when filtering `notifications/message`.
|
|
216
|
+
*/
|
|
217
|
+
protected bindMcpLogLevelRegistry(): BindingTarget<McpLogLevelRegistry> {
|
|
218
|
+
return DefaultMcpLogLevelRegistry;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* {@link GLSPMcpServerFactory} binding — produces a fresh {@link DefaultGLSPMcpServer} per
|
|
223
|
+
* MCP-session-init call. Override to wrap the SDK `McpServer` differently (e.g. add custom
|
|
224
|
+
* middleware, swap the Proxy strategy).
|
|
225
|
+
*/
|
|
226
|
+
protected bindGLSPMcpServerFactory(): BindingTarget<GLSPMcpServerFactory> {
|
|
227
|
+
return {
|
|
228
|
+
dynamicValue: ctx => {
|
|
229
|
+
const logger = ctx.container.get<Logger>(Logger);
|
|
230
|
+
return (mcpServer: McpServer, options: McpServerOptionsType): DefaultGLSPMcpServer =>
|
|
231
|
+
new DefaultGLSPMcpServer(mcpServer, options, logger);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Override to add or replace tool handlers. Adopters typically `super.configureToolHandlers(binding)`
|
|
238
|
+
* to keep the defaults, then `binding.add(MyTool)` for additions or
|
|
239
|
+
* `binding.rebind(StandardTool, MyTool)` for overrides.
|
|
240
|
+
*/
|
|
241
|
+
protected configureToolHandlers(binding: McpHandlerMultiBinding<McpToolHandler>): void {
|
|
242
|
+
binding.add(SessionInfoMcpToolHandler);
|
|
243
|
+
binding.add(ElementTypesMcpToolHandler);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** See {@link configureToolHandlers}. No server-scope resources ship by default. */
|
|
247
|
+
protected configureResourceHandlers(_binding: McpHandlerMultiBinding<McpResourceHandler>): void {
|
|
248
|
+
// empty by default
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* See {@link configureToolHandlers}. Server-scope by default because the shipped prompts
|
|
253
|
+
* (`describe-diagram`, `suggest-improvements`) are diagram-type-agnostic and resolve their
|
|
254
|
+
* target session at invocation time — diagram-scope adopters add prompts via
|
|
255
|
+
* {@link DefaultMcpDiagramModule.configurePromptHandlers}.
|
|
256
|
+
*/
|
|
257
|
+
protected configurePromptHandlers(binding: McpHandlerMultiBinding<McpPromptHandler>): void {
|
|
258
|
+
binding.add(DescribeDiagramMcpPromptHandler);
|
|
259
|
+
binding.add(SuggestImprovementsMcpPromptHandler);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Default {@link AbstractMcpServerModule} entry point. Ships GLSP-default option values (see
|
|
265
|
+
* {@link DEFAULT_OPTIONS}) on top of the abstract module's hook defaults. Adopter-provided
|
|
266
|
+
* overrides via the constructor merge on top.
|
|
267
|
+
*
|
|
268
|
+
* @experimental The MCP integration is under active development. Option names, schema shapes,
|
|
269
|
+
* and handler contracts MAY change in minor releases until the feature graduates from
|
|
270
|
+
* experimental status.
|
|
271
|
+
*/
|
|
272
|
+
export class DefaultMcpServerModule extends AbstractMcpServerModule {
|
|
273
|
+
static readonly DEFAULT_OPTIONS: McpServerDefaults = {
|
|
274
|
+
host: '127.0.0.1',
|
|
275
|
+
allowedHosts: ['127.0.0.1', 'localhost'],
|
|
276
|
+
// `allowedOrigins` deliberately undefined: accept absent Origin (typical for desktop-IDE
|
|
277
|
+
// MCP clients) and rely on Host validation to gate DNS-rebinding. Adopters whose
|
|
278
|
+
// deployment is browser-fronted set this explicitly to their frontend's origin.
|
|
279
|
+
dataMode: 'tools',
|
|
280
|
+
agentPersona: DEFAULT_AGENT_PERSONA,
|
|
281
|
+
// 10K events per session is generous for typical workloads (a few MB) and large enough
|
|
282
|
+
// that disconnects within seconds recover via `Last-Event-ID` resumability.
|
|
283
|
+
eventStoreLimit: LruEventStore.DEFAULT_LIMIT
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
constructor(overrides: McpServerDefaults = {}) {
|
|
287
|
+
super({ ...DefaultMcpServerModule.DEFAULT_OPTIONS, ...overrides });
|
|
288
|
+
}
|
|
289
|
+
}
|