@eclipse-glsp/server-mcp 2.7.0-next.9
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 +23 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +41 -0
- package/lib/index.js.map +1 -0
- package/lib/prompts/handlers/describe-diagram-mcp-prompt-handler.d.ts +43 -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 +96 -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 +43 -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 +95 -0
- package/lib/prompts/handlers/suggest-improvements-mcp-prompt-handler.js.map +1 -0
- package/lib/prompts/index.d.ts +18 -0
- package/lib/prompts/index.d.ts.map +1 -0
- package/lib/prompts/index.js +34 -0
- package/lib/prompts/index.js.map +1 -0
- package/lib/resources/handlers/diagram-png-mcp-resource-handler.d.ts +81 -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 +174 -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 +52 -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 +96 -0
- package/lib/resources/handlers/diagram-svg-mcp-resource-handler.js.map +1 -0
- package/lib/resources/index.d.ts +20 -0
- package/lib/resources/index.d.ts.map +1 -0
- package/lib/resources/index.js +36 -0
- package/lib/resources/index.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/index.d.ts +37 -0
- package/lib/server/index.d.ts.map +1 -0
- package/lib/server/index.js +57 -0
- package/lib/server/index.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-module.d.ts +123 -0
- package/lib/server/mcp-diagram-module.d.ts.map +1 -0
- package/lib/server/mcp-diagram-module.js +186 -0
- package/lib/server/mcp-diagram-module.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-server-module.d.ts +143 -0
- package/lib/server/mcp-server-module.d.ts.map +1 -0
- package/lib/server/mcp-server-module.js +249 -0
- package/lib/server/mcp-server-module.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 +46 -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 +76 -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 +112 -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 +190 -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 +81 -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 +123 -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 +52 -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 +73 -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 +59 -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 +78 -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 +97 -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 +155 -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 +43 -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 +68 -0
- package/lib/tools/handlers/get-selection-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/layout-mcp-tool-handler.d.ts +43 -0
- package/lib/tools/handlers/layout-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/layout-mcp-tool-handler.js +71 -0
- package/lib/tools/handlers/layout-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/modify-edges-mcp-tool-handler.d.ts +78 -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 +136 -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 +92 -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 +125 -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 +102 -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 +158 -0
- package/lib/tools/handlers/query-elements-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/redo-mcp-tool-handler.d.ts +45 -0
- package/lib/tools/handlers/redo-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/redo-mcp-tool-handler.js +73 -0
- package/lib/tools/handlers/redo-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/save-model-mcp-tool-handler.d.ts +55 -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 +91 -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 +65 -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 +108 -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 +60 -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 +103 -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 +110 -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 +142 -0
- package/lib/tools/handlers/set-view-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/undo-mcp-tool-handler.d.ts +45 -0
- package/lib/tools/handlers/undo-mcp-tool-handler.d.ts.map +1 -0
- package/lib/tools/handlers/undo-mcp-tool-handler.js +74 -0
- package/lib/tools/handlers/undo-mcp-tool-handler.js.map +1 -0
- package/lib/tools/handlers/validate-diagram-mcp-tool-handler.d.ts +66 -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/tools/index.d.ts +34 -0
- package/lib/tools/index.d.ts.map +1 -0
- package/lib/tools/index.js +50 -0
- package/lib/tools/index.js.map +1 -0
- package/lib/util/index.d.ts +18 -0
- package/lib/util/index.d.ts.map +1 -0
- package/lib/util/index.js +34 -0
- package/lib/util/index.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 +24 -0
- package/src/prompts/handlers/describe-diagram-mcp-prompt-handler.ts +89 -0
- package/src/prompts/handlers/suggest-improvements-mcp-prompt-handler.ts +86 -0
- package/src/prompts/index.ts +18 -0
- package/src/resources/handlers/diagram-png-mcp-resource-handler.ts +181 -0
- package/src/resources/handlers/diagram-svg-mcp-resource-handler.ts +89 -0
- package/src/resources/index.ts +20 -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/index.ts +42 -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-module.ts +248 -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-server-module.ts +287 -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 +99 -0
- package/src/tools/handlers/count-elements-mcp-tool-handler.ts +66 -0
- package/src/tools/handlers/create-edges-mcp-tool-handler.spec.ts +196 -0
- package/src/tools/handlers/create-edges-mcp-tool-handler.ts +205 -0
- package/src/tools/handlers/create-nodes-mcp-tool-handler.spec.ts +197 -0
- package/src/tools/handlers/create-nodes-mcp-tool-handler.ts +131 -0
- package/src/tools/handlers/delete-elements-mcp-tool-handler.ts +73 -0
- package/src/tools/handlers/diagram-model-mcp-tool-handler.ts +66 -0
- package/src/tools/handlers/element-types-mcp-tool-handler.ts +151 -0
- package/src/tools/handlers/get-selection-mcp-tool-handler.ts +54 -0
- package/src/tools/handlers/layout-mcp-tool-handler.ts +56 -0
- package/src/tools/handlers/modify-edges-mcp-tool-handler.ts +148 -0
- package/src/tools/handlers/modify-nodes-mcp-tool-handler.ts +140 -0
- package/src/tools/handlers/query-elements-mcp-tool-handler.spec.ts +210 -0
- package/src/tools/handlers/query-elements-mcp-tool-handler.ts +161 -0
- package/src/tools/handlers/redo-mcp-tool-handler.ts +62 -0
- package/src/tools/handlers/save-model-mcp-tool-handler.ts +71 -0
- package/src/tools/handlers/session-info-mcp-tool-handler.spec.ts +152 -0
- package/src/tools/handlers/session-info-mcp-tool-handler.ts +97 -0
- package/src/tools/handlers/set-selection-mcp-tool-handler.spec.ts +118 -0
- package/src/tools/handlers/set-selection-mcp-tool-handler.ts +90 -0
- package/src/tools/handlers/set-view-mcp-tool-handler.ts +162 -0
- package/src/tools/handlers/undo-mcp-tool-handler.ts +61 -0
- package/src/tools/handlers/validate-diagram-mcp-tool-handler.ts +0 -0
- package/src/tools/index.ts +34 -0
- package/src/tools/tool-annotations.spec.ts +141 -0
- package/src/util/index.ts +18 -0
- package/src/util/markdown-util.ts +44 -0
- package/src/util/mcp-util.ts +25 -0
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
* This function serializes a given array of objects into a Markdown table string.
|
|
18
|
+
*/
|
|
19
|
+
export declare function objectArrayToMarkdownTable(data: Record<string, any>[]): string;
|
|
20
|
+
//# sourceMappingURL=markdown-util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-util.d.ts","sourceRoot":"","sources":["../../src/util/markdown-util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,MAAM,CAwB9E"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2026 EclipseSource and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
*
|
|
9
|
+
* This Source Code may also be made available under the following Secondary
|
|
10
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
* with the GNU Classpath Exception which is available at
|
|
13
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
*
|
|
15
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
********************************************************************************/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.objectArrayToMarkdownTable = objectArrayToMarkdownTable;
|
|
19
|
+
/**
|
|
20
|
+
* This function serializes a given array of objects into a Markdown table string.
|
|
21
|
+
*/
|
|
22
|
+
function objectArrayToMarkdownTable(data) {
|
|
23
|
+
if (!data.length) {
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
const headers = Object.keys(data[0]);
|
|
27
|
+
const headerRow = `| ${headers.join(' | ')} |`;
|
|
28
|
+
const separatorRow = `| ${headers.map(() => '---').join(' | ')} |`;
|
|
29
|
+
const dataRows = data.map((obj) => {
|
|
30
|
+
const rowString = headers
|
|
31
|
+
.map(header => {
|
|
32
|
+
var _a;
|
|
33
|
+
const value = (_a = obj[header]) !== null && _a !== void 0 ? _a : '';
|
|
34
|
+
if (typeof value === 'object') {
|
|
35
|
+
return JSON.stringify(value).replace(/["{}|]/g, '');
|
|
36
|
+
}
|
|
37
|
+
// Escape pipe characters in scalar values so they don't break the table layout
|
|
38
|
+
return String(value).replace(/\|/g, '\\|');
|
|
39
|
+
})
|
|
40
|
+
.join(' | ');
|
|
41
|
+
return `| ${rowString} |`;
|
|
42
|
+
});
|
|
43
|
+
return [headerRow, separatorRow, ...dataRows].join('\n');
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=markdown-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-util.js","sourceRoot":"","sources":["../../src/util/markdown-util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;AAKlF,gEAwBC;AA3BD;;GAEG;AACH,SAAgB,0BAA0B,CAAC,IAA2B;IAClE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACf,OAAO,EAAE,CAAC;IACd,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACrC,MAAM,SAAS,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IAC/C,MAAM,YAAY,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IAEnE,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAwB,EAAE,EAAE;QACnD,MAAM,SAAS,GAAG,OAAO;aACpB,GAAG,CAAC,MAAM,CAAC,EAAE;;YACV,MAAM,KAAK,GAAG,MAAA,GAAG,CAAC,MAAM,CAAC,mCAAI,EAAE,CAAC;YAChC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC5B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;YACxD,CAAC;YACD,+EAA+E;YAC/E,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC/C,CAAC,CAAC;aACD,IAAI,CAAC,KAAK,CAAC,CAAC;QACjB,OAAO,KAAK,SAAS,IAAI,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,SAAS,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
/**
|
|
17
|
+
* Formats a list of per-input notices (errors, warnings, …) as a Markdown bullet list with a
|
|
18
|
+
* leading heading. Returns an empty string when `notices` is empty so callers can append
|
|
19
|
+
* unconditionally.
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatNoticeList(kind: string, notices: string[]): string;
|
|
22
|
+
//# sourceMappingURL=mcp-util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-util.d.ts","sourceRoot":"","sources":["../../src/util/mcp-util.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAGxE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/********************************************************************************
|
|
3
|
+
* Copyright (c) 2025-2026 EclipseSource and others.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made available under the
|
|
6
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
+
*
|
|
9
|
+
* This Source Code may also be made available under the following Secondary
|
|
10
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
+
* with the GNU Classpath Exception which is available at
|
|
13
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
14
|
+
*
|
|
15
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
|
+
********************************************************************************/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.formatNoticeList = formatNoticeList;
|
|
19
|
+
/**
|
|
20
|
+
* Formats a list of per-input notices (errors, warnings, …) as a Markdown bullet list with a
|
|
21
|
+
* leading heading. Returns an empty string when `notices` is empty so callers can append
|
|
22
|
+
* unconditionally.
|
|
23
|
+
*/
|
|
24
|
+
function formatNoticeList(kind, notices) {
|
|
25
|
+
if (notices.length === 0)
|
|
26
|
+
return '';
|
|
27
|
+
return `\nThe following ${kind} occurred:\n${notices.map(notice => `- ${notice}`).join('\n')}`;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=mcp-util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-util.js","sourceRoot":"","sources":["../../src/util/mcp-util.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;AAOlF,4CAGC;AARD;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,IAAY,EAAE,OAAiB;IAC5D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACpC,OAAO,mBAAmB,IAAI,eAAe,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AACnG,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eclipse-glsp/server-mcp",
|
|
3
|
+
"version": "2.7.0-next.9+a58ea45",
|
|
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.9+a58ea45",
|
|
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": "a58ea45de80be3d2fcf46e0934af141b213f6187"
|
|
63
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
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 './prompts';
|
|
17
|
+
export * from './resources';
|
|
18
|
+
export * from './server';
|
|
19
|
+
export * from './tools';
|
|
20
|
+
export * from './util';
|
|
21
|
+
// Module classes — exported here (not from `./server`) to avoid circular imports through
|
|
22
|
+
// the handler barrels which the modules consume.
|
|
23
|
+
export * from './server/mcp-diagram-module';
|
|
24
|
+
export * from './server/mcp-server-module';
|
|
@@ -0,0 +1,89 @@
|
|
|
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 { ClientSessionManager } from '@eclipse-glsp/server';
|
|
18
|
+
import { inject, injectable } from 'inversify';
|
|
19
|
+
import * as z from 'zod/v4';
|
|
20
|
+
import { AbstractMcpPromptHandler, McpPromptResult, resolveActiveSessionId } from '../../server';
|
|
21
|
+
import {
|
|
22
|
+
CountElementsMcpToolHandler,
|
|
23
|
+
DiagramModelMcpToolHandler,
|
|
24
|
+
ElementTypesMcpToolHandler,
|
|
25
|
+
QueryElementsMcpToolHandler,
|
|
26
|
+
SetSelectionMcpToolHandler,
|
|
27
|
+
SetViewMcpToolHandler
|
|
28
|
+
} from '../../tools';
|
|
29
|
+
|
|
30
|
+
export const DescribeDiagramArgsSchema = z.object({
|
|
31
|
+
sessionId: z
|
|
32
|
+
.string()
|
|
33
|
+
.optional()
|
|
34
|
+
.describe('GLSP client session id (open diagram). Defaults to the only open session; required when multiple are open.')
|
|
35
|
+
});
|
|
36
|
+
export type DescribeDiagramArgs = z.infer<typeof DescribeDiagramArgsSchema>;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Prompt template that instructs the agent to produce a structured description of a diagram.
|
|
40
|
+
* Pre-baked starting point invokable from the MCP-client UI; the agent then orchestrates the
|
|
41
|
+
* necessary tool calls on its own.
|
|
42
|
+
*
|
|
43
|
+
* Server-scope on purpose — the prompt itself has no per-session state, so we avoid forcing
|
|
44
|
+
* the user to type a sessionId in the common single-diagram case.
|
|
45
|
+
*/
|
|
46
|
+
@injectable()
|
|
47
|
+
export class DescribeDiagramMcpPromptHandler extends AbstractMcpPromptHandler<DescribeDiagramArgs> {
|
|
48
|
+
static readonly NAME = 'describe-diagram';
|
|
49
|
+
readonly name = DescribeDiagramMcpPromptHandler.NAME;
|
|
50
|
+
override readonly title = 'Describe Diagram';
|
|
51
|
+
readonly description =
|
|
52
|
+
'Produce a structured, skim-friendly description of an open diagram. ' +
|
|
53
|
+
'The agent picks the right tools to gather data (overview, element-type breakdown, structure, notable elements) ' +
|
|
54
|
+
'and writes the description in its own words. ' +
|
|
55
|
+
'Use this as a starting point when the user asks "what does this diagram show?" or wants a documentation-style summary. ' +
|
|
56
|
+
'`sessionId` is optional — defaults to the only open session.';
|
|
57
|
+
readonly argsSchema = DescribeDiagramArgsSchema;
|
|
58
|
+
|
|
59
|
+
@inject(ClientSessionManager) protected clientSessionManager: ClientSessionManager;
|
|
60
|
+
|
|
61
|
+
override referencedToolNames(): string[] {
|
|
62
|
+
return [
|
|
63
|
+
CountElementsMcpToolHandler.NAME,
|
|
64
|
+
ElementTypesMcpToolHandler.NAME,
|
|
65
|
+
DiagramModelMcpToolHandler.NAME,
|
|
66
|
+
QueryElementsMcpToolHandler.NAME,
|
|
67
|
+
SetSelectionMcpToolHandler.NAME,
|
|
68
|
+
SetViewMcpToolHandler.NAME
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
protected createResult(args: DescribeDiagramArgs): McpPromptResult {
|
|
73
|
+
const sessionId = resolveActiveSessionId(this.clientSessionManager, args.sessionId);
|
|
74
|
+
const text =
|
|
75
|
+
`Describe the diagram for session \`${sessionId}\`. Include:\n\n` +
|
|
76
|
+
`1. **Overview** — diagram type and total element count (use \`${CountElementsMcpToolHandler.NAME}\`).\n` +
|
|
77
|
+
`2. **Element-type breakdown** — what kinds of elements are present and how many of each ` +
|
|
78
|
+
`(use \`${ElementTypesMcpToolHandler.NAME}\` and \`${CountElementsMcpToolHandler.NAME}\`).\n` +
|
|
79
|
+
`3. **Structure** — load the model with \`${DiagramModelMcpToolHandler.NAME}\` and summarize the ` +
|
|
80
|
+
`hierarchy and major connections.\n` +
|
|
81
|
+
`4. **Notable elements** — call out anything that stands out (unconnected nodes, deeply ` +
|
|
82
|
+
`nested groups, missing labels). Use \`${QueryElementsMcpToolHandler.NAME}\` to locate specific cases.\n\n` +
|
|
83
|
+
`Keep the description concise and skim-friendly. ` +
|
|
84
|
+
`When mentioning an element, prefer its label or type, with the alias appended in parens — e.g. ` +
|
|
85
|
+
`"the 'Brew' task (#7)" or "the decision node (#9)" — never the bare alias alone, since aliases mean nothing to the user. ` +
|
|
86
|
+
`Use \`${SetSelectionMcpToolHandler.NAME}\` or \`${SetViewMcpToolHandler.NAME} → 'center-on-elements'\` to draw the user's attention.`;
|
|
87
|
+
return { messages: [{ role: 'user', content: { type: 'text', text } }] };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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 { ClientSessionManager } from '@eclipse-glsp/server';
|
|
18
|
+
import { inject, injectable } from 'inversify';
|
|
19
|
+
import * as z from 'zod/v4';
|
|
20
|
+
import { AbstractMcpPromptHandler, McpPromptResult, resolveActiveSessionId } from '../../server';
|
|
21
|
+
import {
|
|
22
|
+
DiagramModelMcpToolHandler,
|
|
23
|
+
QueryElementsMcpToolHandler,
|
|
24
|
+
SetSelectionMcpToolHandler,
|
|
25
|
+
ValidateDiagramMcpToolHandler
|
|
26
|
+
} from '../../tools';
|
|
27
|
+
|
|
28
|
+
export const SuggestImprovementsArgsSchema = z.object({
|
|
29
|
+
sessionId: z
|
|
30
|
+
.string()
|
|
31
|
+
.optional()
|
|
32
|
+
.describe('GLSP client session id (open diagram). Defaults to the only open session; required when multiple are open.')
|
|
33
|
+
});
|
|
34
|
+
export type SuggestImprovementsArgs = z.infer<typeof SuggestImprovementsArgsSchema>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Prompt template that asks the agent to review the diagram and propose concrete improvements
|
|
38
|
+
* (validation issues, structural smells, missing labels, etc.). The agent orchestrates the
|
|
39
|
+
* tool calls; this prompt only frames the task.
|
|
40
|
+
*
|
|
41
|
+
* Server-scope on purpose — the prompt itself has no per-session state, so we avoid forcing
|
|
42
|
+
* the user to type a sessionId in the common single-diagram case.
|
|
43
|
+
*/
|
|
44
|
+
@injectable()
|
|
45
|
+
export class SuggestImprovementsMcpPromptHandler extends AbstractMcpPromptHandler<SuggestImprovementsArgs> {
|
|
46
|
+
static readonly NAME = 'suggest-improvements';
|
|
47
|
+
readonly name = SuggestImprovementsMcpPromptHandler.NAME;
|
|
48
|
+
override readonly title = 'Suggest Diagram Improvements';
|
|
49
|
+
readonly description =
|
|
50
|
+
'Review an open diagram and propose concrete improvements grouped by severity ' +
|
|
51
|
+
'(must-fix vs. nice-to-have). The agent runs validation, checks connectivity, looks for unclear labels, ' +
|
|
52
|
+
'and flags structural inconsistencies, then names the specific element ids for each suggestion so the user ' +
|
|
53
|
+
'can act on them. Read-only by intent — the prompt instructs the agent not to modify the diagram, only propose. ' +
|
|
54
|
+
'`sessionId` is optional — defaults to the only open session.';
|
|
55
|
+
readonly argsSchema = SuggestImprovementsArgsSchema;
|
|
56
|
+
|
|
57
|
+
@inject(ClientSessionManager) protected clientSessionManager: ClientSessionManager;
|
|
58
|
+
|
|
59
|
+
override referencedToolNames(): string[] {
|
|
60
|
+
return [
|
|
61
|
+
ValidateDiagramMcpToolHandler.NAME,
|
|
62
|
+
DiagramModelMcpToolHandler.NAME,
|
|
63
|
+
QueryElementsMcpToolHandler.NAME,
|
|
64
|
+
SetSelectionMcpToolHandler.NAME
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
protected createResult(args: SuggestImprovementsArgs): McpPromptResult {
|
|
69
|
+
const sessionId = resolveActiveSessionId(this.clientSessionManager, args.sessionId);
|
|
70
|
+
const text =
|
|
71
|
+
`Review the diagram for session \`${sessionId}\` and propose concrete improvements. Focus on:\n\n` +
|
|
72
|
+
`1. **Validation issues** — run \`${ValidateDiagramMcpToolHandler.NAME}\` and surface any markers.\n` +
|
|
73
|
+
`2. **Connectivity** — load the model (\`${DiagramModelMcpToolHandler.NAME}\`) and flag unconnected ` +
|
|
74
|
+
`nodes or orphaned subgraphs.\n` +
|
|
75
|
+
`3. **Labelling** — use \`${QueryElementsMcpToolHandler.NAME}\` to find nodes that lack a meaningful ` +
|
|
76
|
+
`label, and edges with missing or unclear text.\n` +
|
|
77
|
+
`4. **Structure** — call out elements whose type or placement looks inconsistent with ` +
|
|
78
|
+
`the rest of the diagram.\n\n` +
|
|
79
|
+
`Group findings by severity (must-fix vs. nice-to-have). ` +
|
|
80
|
+
`When naming elements, prefer their label or type with the alias in parens — e.g. ` +
|
|
81
|
+
`"the 'Brew' task (#7)" or "the decision node (#9)" — never the bare alias alone, since aliases mean nothing to the user. ` +
|
|
82
|
+
`Point at each suggestion via \`${SetSelectionMcpToolHandler.NAME}\` so the user can navigate. ` +
|
|
83
|
+
`Do not modify the diagram — only propose.`;
|
|
84
|
+
return { messages: [{ role: 'user', content: { type: 'text', text } }] };
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
export * from './handlers/describe-diagram-mcp-prompt-handler';
|
|
18
|
+
export * from './handlers/suggest-improvements-mcp-prompt-handler';
|
|
@@ -0,0 +1,181 @@
|
|
|
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 { ClientActionKinds, isGBoundsAware, RequestExportAction } from '@eclipse-glsp/server';
|
|
18
|
+
import { Role } from '@modelcontextprotocol/sdk/types.js';
|
|
19
|
+
import { inject, injectable } from 'inversify';
|
|
20
|
+
import * as z from 'zod/v4';
|
|
21
|
+
import {
|
|
22
|
+
AbstractMcpDiagramResourceHandler,
|
|
23
|
+
McpDiagramScopedInputSchema,
|
|
24
|
+
McpMimeType,
|
|
25
|
+
McpProgressReporter,
|
|
26
|
+
McpResourceContent,
|
|
27
|
+
McpResourceUri,
|
|
28
|
+
McpToolError
|
|
29
|
+
} from '../../server';
|
|
30
|
+
|
|
31
|
+
export const DiagramPngInputSchema = McpDiagramScopedInputSchema.extend({
|
|
32
|
+
scale: z
|
|
33
|
+
.number()
|
|
34
|
+
.min(0.1)
|
|
35
|
+
.max(4)
|
|
36
|
+
.optional()
|
|
37
|
+
.describe(
|
|
38
|
+
"Multiplier applied to the diagram's natural extent (range 0.1..4). Use values >1 for " +
|
|
39
|
+
'sharper-than-default renders, <1 for thumbnails. Ignored when `width` or `height` is supplied.'
|
|
40
|
+
),
|
|
41
|
+
width: z
|
|
42
|
+
.number()
|
|
43
|
+
.int()
|
|
44
|
+
.min(1)
|
|
45
|
+
.max(8192)
|
|
46
|
+
.optional()
|
|
47
|
+
.describe('Override the rendered width in pixels. When given alone, the height is derived from the diagram aspect ratio.'),
|
|
48
|
+
height: z
|
|
49
|
+
.number()
|
|
50
|
+
.int()
|
|
51
|
+
.min(1)
|
|
52
|
+
.max(8192)
|
|
53
|
+
.optional()
|
|
54
|
+
.describe('Override the rendered height in pixels. When given alone, the width is derived from the diagram aspect ratio.'),
|
|
55
|
+
timeoutMs: z
|
|
56
|
+
.number()
|
|
57
|
+
.int()
|
|
58
|
+
.min(100)
|
|
59
|
+
.max(60000)
|
|
60
|
+
.optional()
|
|
61
|
+
.describe('Override the default render timeout in milliseconds (100–60000). Useful for very large diagrams.')
|
|
62
|
+
});
|
|
63
|
+
export type DiagramPngInput = z.infer<typeof DiagramPngInputSchema>;
|
|
64
|
+
|
|
65
|
+
/** Rendering lives on the client — `RequestExportAction('png')` routes to the registered PNG exporter, which returns base64 via `ExportResultAction`. */
|
|
66
|
+
@injectable()
|
|
67
|
+
export class DiagramPngMcpResourceHandler extends AbstractMcpDiagramResourceHandler<DiagramPngInput> {
|
|
68
|
+
/** Default timeout (in ms) used when the call doesn't override `timeoutMs`. Override via subclass + rebind. */
|
|
69
|
+
protected readonly defaultTimeoutMs: number = 5000;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Default `scale` multiplier when the caller doesn't pin `width`/`height`/`scale`. `1` means
|
|
73
|
+
* "render at the diagram's natural extent" — sharp because the client rasterises the SVG
|
|
74
|
+
* at the requested size. Adopters override (e.g. to `2` for a high-DPI deployment) via
|
|
75
|
+
* subclass + rebind.
|
|
76
|
+
*/
|
|
77
|
+
protected readonly defaultScale: number = 1;
|
|
78
|
+
|
|
79
|
+
static readonly NAME = 'diagram-png';
|
|
80
|
+
readonly name = DiagramPngMcpResourceHandler.NAME;
|
|
81
|
+
override readonly title = 'Diagram Model PNG';
|
|
82
|
+
readonly description =
|
|
83
|
+
'Render the session diagram as a base64-encoded PNG screenshot of its current visible state. ' +
|
|
84
|
+
'Includes all nodes, edges, and their styling — useful when a visual answer would help the agent ' +
|
|
85
|
+
'(layout reasoning, confirming a recently-created element looks right, sharing the diagram with the user). ' +
|
|
86
|
+
"Defaults to a sharp render at the diagram's natural extent; pass `scale` to multiply, " +
|
|
87
|
+
'or `width`/`height` to pin specific dimensions. ' +
|
|
88
|
+
'Requires a connected frontend client to perform the render and is subject to a timeout if no response arrives. ' +
|
|
89
|
+
'For a structured-text view of the model use `diagram-model` instead; for vector output use `diagram-svg`.';
|
|
90
|
+
readonly mimeType: McpMimeType = 'image/png';
|
|
91
|
+
readonly uri: McpResourceUri = { template: 'glsp://diagrams/{sessionId}/png' };
|
|
92
|
+
/** Both the user (visual artifact) and the assistant (visual reasoning) consume the rendered diagram. */
|
|
93
|
+
override readonly audience: Role[] = ['user', 'assistant'];
|
|
94
|
+
/** Useful when relevant, but not always-relevant — clients may skip when text-only reasoning suffices. */
|
|
95
|
+
override readonly priority = 0.6;
|
|
96
|
+
// `lastModified` intentionally omitted: we have no cheap, accurate freshness signal for the
|
|
97
|
+
// rendered PNG (the model state doesn't track a "rendered at" timestamp), and a stale value
|
|
98
|
+
// would mislead clients.
|
|
99
|
+
override readonly toolAlternativeInputSchema = DiagramPngInputSchema;
|
|
100
|
+
|
|
101
|
+
@inject(McpProgressReporter) protected progress: McpProgressReporter;
|
|
102
|
+
|
|
103
|
+
@inject(ClientActionKinds) protected clientActionKinds: Set<string>;
|
|
104
|
+
|
|
105
|
+
/** Skip-bind when the GLSP client doesn't speak `RequestExportAction` — every read would otherwise time out. */
|
|
106
|
+
override canRegister(): boolean {
|
|
107
|
+
return this.clientActionKinds.has(RequestExportAction.KIND);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
protected async createResult({ scale, width, height, timeoutMs }: DiagramPngInput): Promise<McpResourceContent> {
|
|
111
|
+
const resolved = this.resolveSize(scale, width, height);
|
|
112
|
+
// Best-effort beat for clients that opted in via `_meta.progressToken`; no-ops otherwise.
|
|
113
|
+
await this.progress.emit({ progress: 0, message: 'Awaiting client-side PNG render…' });
|
|
114
|
+
const response = await this.requestAction(
|
|
115
|
+
RequestExportAction.create('png', { formatOptions: { width: resolved.width, height: resolved.height } }),
|
|
116
|
+
timeoutMs ?? this.defaultTimeoutMs
|
|
117
|
+
);
|
|
118
|
+
// A misbehaving exporter strategy returning text-encoded data here would silently corrupt the blob; fail loudly instead.
|
|
119
|
+
if (response.encoding !== 'base64') {
|
|
120
|
+
throw new McpToolError(`PNG export returned unexpected encoding '${response.encoding}'; expected 'base64'.`);
|
|
121
|
+
}
|
|
122
|
+
return { blob: response.data };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Resolve the final render size with this precedence:
|
|
127
|
+
* - `width` and `height` both given → use as-is.
|
|
128
|
+
* - only one of `width`/`height` given → derive the other from the diagram aspect ratio.
|
|
129
|
+
* - neither dimension given → natural × (`scale` ?? {@link defaultScale}).
|
|
130
|
+
*/
|
|
131
|
+
protected resolveSize(
|
|
132
|
+
scale: number | undefined,
|
|
133
|
+
width: number | undefined,
|
|
134
|
+
height: number | undefined
|
|
135
|
+
): { width: number; height: number } {
|
|
136
|
+
if (width !== undefined && height !== undefined) {
|
|
137
|
+
return { width, height };
|
|
138
|
+
}
|
|
139
|
+
const natural = this.computeNaturalSize();
|
|
140
|
+
if (width !== undefined) {
|
|
141
|
+
return { width, height: Math.max(1, Math.round(width * (natural.height / natural.width))) };
|
|
142
|
+
}
|
|
143
|
+
if (height !== undefined) {
|
|
144
|
+
return { width: Math.max(1, Math.round(height * (natural.width / natural.height))), height };
|
|
145
|
+
}
|
|
146
|
+
const factor = scale ?? this.defaultScale;
|
|
147
|
+
return {
|
|
148
|
+
width: Math.max(1, Math.round(natural.width * factor)),
|
|
149
|
+
height: Math.max(1, Math.round(natural.height * factor))
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Compute the diagram's natural extent as the bounding box of every {@link isGBoundsAware}
|
|
155
|
+
* element with both `position` and `size`. Throws when the model has no positioned elements
|
|
156
|
+
* — a 1×1 PNG of an empty diagram is technically renderable but useless, and surfacing it
|
|
157
|
+
* as a self-correctable error lets the LLM react (e.g. wait for layout, ask the user).
|
|
158
|
+
*/
|
|
159
|
+
protected computeNaturalSize(): { width: number; height: number } {
|
|
160
|
+
let maxX = 0;
|
|
161
|
+
let maxY = 0;
|
|
162
|
+
for (const id of this.modelState.index.allIds()) {
|
|
163
|
+
const element = this.modelState.index.get(id);
|
|
164
|
+
if (!element || !isGBoundsAware(element)) {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
const position = element.position;
|
|
168
|
+
const size = element.size;
|
|
169
|
+
if (position && size && size.width > 0 && size.height > 0) {
|
|
170
|
+
maxX = Math.max(maxX, position.x + size.width);
|
|
171
|
+
maxY = Math.max(maxY, position.y + size.height);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (maxX <= 0 || maxY <= 0) {
|
|
175
|
+
throw new McpToolError(
|
|
176
|
+
'Diagram has no positioned elements yet — render once after layout completes, or pass `width` / `height` explicitly.'
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
return { width: Math.ceil(maxX), height: Math.ceil(maxY) };
|
|
180
|
+
}
|
|
181
|
+
}
|