@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 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-options.js","sourceRoot":"","sources":["../../src/server/mcp-options.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;AAGlF,yCAAuC;AAEvC;;;;;;;;;;;GAWG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAAtB;QACH,WAAM,GAAyB,EAAE,CAAC;IACtC,CAAC;CAAA,CAAA;AAFY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,sBAAU,GAAE;GACA,gBAAgB,CAE5B;AAED;;;;GAIG;AACU,QAAA,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
* Per-call shape of a `notifications/progress` emission. Mirrors the SDK's
|
|
18
|
+
* `ProgressNotificationParams` minus the `progressToken` field (the reporter pulls that from
|
|
19
|
+
* the active request context — the caller's job is just to describe the progress beat).
|
|
20
|
+
*/
|
|
21
|
+
export interface McpProgressBeat {
|
|
22
|
+
/** Monotonic progress count. Spec is loose; convention: increment from 0 toward `total` if known, or use seconds-elapsed otherwise. */
|
|
23
|
+
progress: number;
|
|
24
|
+
/** Total when known (e.g. number of nodes to process). Omit when bounded only by a timeout. */
|
|
25
|
+
total?: number;
|
|
26
|
+
/** Short user-facing description; surfaces in compatible clients' UI. */
|
|
27
|
+
message?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Emits `notifications/progress` to the connected MCP client when the active request carries a
|
|
31
|
+
* `progressToken` in its `_meta`. Built on the same {@link mcpRequestContext} as
|
|
32
|
+
* {@link McpLogger}; handlers don't need to thread `extra` through their own signatures.
|
|
33
|
+
*
|
|
34
|
+
* Behaviour:
|
|
35
|
+
* - Outside a request context (init, background): no-op.
|
|
36
|
+
* - Inside a request context with no `progressToken` (client didn't opt in): no-op.
|
|
37
|
+
* Universally supported per spec — clients that don't render progress simply omit the token.
|
|
38
|
+
* - Failures to deliver are swallowed: a broken transport must not break the producing tool.
|
|
39
|
+
*
|
|
40
|
+
* Shared across MCP clients on the same GLSP session; per-client routing is handled by the
|
|
41
|
+
* active `mcpRequestContext` frame.
|
|
42
|
+
*
|
|
43
|
+
* @experimental
|
|
44
|
+
*/
|
|
45
|
+
export declare class McpProgressReporter {
|
|
46
|
+
emit(beat: McpProgressBeat): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=mcp-progress-reporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-progress-reporter.d.ts","sourceRoot":"","sources":["../../src/server/mcp-progress-reporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAKlF;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC5B,uIAAuI;IACvI,QAAQ,EAAE,MAAM,CAAC;IACjB,+FAA+F;IAC/F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBACa,mBAAmB;IACtB,IAAI,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAenD"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.McpProgressReporter = void 0;
|
|
25
|
+
const inversify_1 = require("inversify");
|
|
26
|
+
const mcp_request_context_1 = require("./mcp-request-context");
|
|
27
|
+
/**
|
|
28
|
+
* Emits `notifications/progress` to the connected MCP client when the active request carries a
|
|
29
|
+
* `progressToken` in its `_meta`. Built on the same {@link mcpRequestContext} as
|
|
30
|
+
* {@link McpLogger}; handlers don't need to thread `extra` through their own signatures.
|
|
31
|
+
*
|
|
32
|
+
* Behaviour:
|
|
33
|
+
* - Outside a request context (init, background): no-op.
|
|
34
|
+
* - Inside a request context with no `progressToken` (client didn't opt in): no-op.
|
|
35
|
+
* Universally supported per spec — clients that don't render progress simply omit the token.
|
|
36
|
+
* - Failures to deliver are swallowed: a broken transport must not break the producing tool.
|
|
37
|
+
*
|
|
38
|
+
* Shared across MCP clients on the same GLSP session; per-client routing is handled by the
|
|
39
|
+
* active `mcpRequestContext` frame.
|
|
40
|
+
*
|
|
41
|
+
* @experimental
|
|
42
|
+
*/
|
|
43
|
+
let McpProgressReporter = class McpProgressReporter {
|
|
44
|
+
async emit(beat) {
|
|
45
|
+
var _a;
|
|
46
|
+
const extra = mcp_request_context_1.mcpRequestContext.getStore();
|
|
47
|
+
const progressToken = (_a = extra === null || extra === void 0 ? void 0 : extra._meta) === null || _a === void 0 ? void 0 : _a.progressToken;
|
|
48
|
+
if (extra === undefined || progressToken === undefined) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
await extra.sendNotification({
|
|
53
|
+
method: 'notifications/progress',
|
|
54
|
+
params: { progressToken, ...beat }
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// Fire-and-forget — never propagate transport errors into tool execution.
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
exports.McpProgressReporter = McpProgressReporter;
|
|
63
|
+
exports.McpProgressReporter = McpProgressReporter = __decorate([
|
|
64
|
+
(0, inversify_1.injectable)()
|
|
65
|
+
], McpProgressReporter);
|
|
66
|
+
//# sourceMappingURL=mcp-progress-reporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-progress-reporter.js","sourceRoot":"","sources":["../../src/server/mcp-progress-reporter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;AAElF,yCAAuC;AACvC,+DAA0D;AAgB1D;;;;;;;;;;;;;;;GAeG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC5B,KAAK,CAAC,IAAI,CAAC,IAAqB;;QAC5B,MAAM,KAAK,GAAG,uCAAiB,CAAC,QAAQ,EAAE,CAAC;QAC3C,MAAM,aAAa,GAAG,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,0CAAE,aAAa,CAAC;QAClD,IAAI,KAAK,KAAK,SAAS,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;YACrD,OAAO;QACX,CAAC;QACD,IAAI,CAAC;YACD,MAAM,KAAK,CAAC,gBAAgB,CAAC;gBACzB,MAAM,EAAE,wBAAwB;gBAChC,MAAM,EAAE,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE;aACrC,CAAC,CAAC;QACP,CAAC;QAAC,MAAM,CAAC;YACL,0EAA0E;QAC9E,CAAC;IACL,CAAC;CACJ,CAAA;AAhBY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,sBAAU,GAAE;GACA,mBAAmB,CAgB/B"}
|
|
@@ -0,0 +1,120 @@
|
|
|
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
|
+
import { Logger, MaybePromise, ModelState } from '@eclipse-glsp/server';
|
|
17
|
+
import { interfaces } from 'inversify';
|
|
18
|
+
import { ZodObject, ZodRawShape } from 'zod/v4';
|
|
19
|
+
import { GLSPMcpServer } from './glsp-mcp-server';
|
|
20
|
+
import { McpPromptResult } from './mcp-handler-shared';
|
|
21
|
+
import { McpIdAliasService } from './mcp-id-alias-service';
|
|
22
|
+
import { McpDiagramScopedInput } from './mcp-input-schemas';
|
|
23
|
+
/**
|
|
24
|
+
* Multi-binding key for **server-scope** prompt handlers — singletons that don't target a
|
|
25
|
+
* specific GLSP client session. Diagram-scope prompts (one instance per open diagram) use the
|
|
26
|
+
* separate {@link McpDiagramPromptHandlerConstructor} multi-binding instead.
|
|
27
|
+
*
|
|
28
|
+
* Prompts are LLM-facing message templates the AI client may invoke. No prompts ship by default;
|
|
29
|
+
* the surface exists for adopters.
|
|
30
|
+
*
|
|
31
|
+
* @experimental
|
|
32
|
+
*/
|
|
33
|
+
export interface McpPromptHandler {
|
|
34
|
+
/** Prompt identifier exposed to the MCP client; matches the abstract base's field. */
|
|
35
|
+
readonly name: string;
|
|
36
|
+
registerPrompt(server: GLSPMcpServer): void;
|
|
37
|
+
/** Tool names this prompt's text references via `${OtherHandler.NAME}`; default: empty. */
|
|
38
|
+
referencedToolNames(): string[];
|
|
39
|
+
}
|
|
40
|
+
export declare const McpPromptHandler: unique symbol;
|
|
41
|
+
/** Shared infrastructure for both server- and diagram-scope prompt handlers. */
|
|
42
|
+
declare abstract class BaseMcpPromptHandler {
|
|
43
|
+
protected logger: Logger;
|
|
44
|
+
/**
|
|
45
|
+
* Prompt identifier exposed to the MCP client. Also used to reference this prompt from
|
|
46
|
+
* other handlers' prompt or description text — wire via `static readonly NAME = '…'` and
|
|
47
|
+
* `readonly name = ClassName.NAME` so those cross-references survive renames.
|
|
48
|
+
*/
|
|
49
|
+
abstract readonly name: string;
|
|
50
|
+
/** LLM-facing explanation surfaced in the prompt catalog. Keep concise — clients pass this verbatim to the model. */
|
|
51
|
+
abstract readonly description: string;
|
|
52
|
+
/** Adopter writes `z.object({ ... })`; the base passes `.shape` to the SDK. */
|
|
53
|
+
abstract readonly argsSchema: ZodObject<ZodRawShape>;
|
|
54
|
+
/** Optional human-friendly display name for UIs that render a friendlier label than `name`. */
|
|
55
|
+
readonly title?: string;
|
|
56
|
+
/** SDK-facing registration config; consumed by both registration paths. */
|
|
57
|
+
toRegistrationConfig(): {
|
|
58
|
+
title?: string;
|
|
59
|
+
description: string;
|
|
60
|
+
argsSchema: ZodRawShape;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Optional list of tool names this prompt's text refers to via `${OtherHandler.NAME}`
|
|
64
|
+
* substitutions. Default: empty. Override in concrete subclasses to declare references so
|
|
65
|
+
* the launcher can warn at registration time when an adopter unbinds a referenced tool —
|
|
66
|
+
* the prompt would otherwise still register and silently produce text pointing at a tool
|
|
67
|
+
* that no longer exists. Pure declarative metadata; never invoked at request time.
|
|
68
|
+
*/
|
|
69
|
+
referencedToolNames(): string[];
|
|
70
|
+
/**
|
|
71
|
+
* Catches `McpToolError` (→ surfaced as a `user`-role assistant message) and unexpected
|
|
72
|
+
* errors (→ logged + extracted message). Errors map to a single text-content message so
|
|
73
|
+
* the LLM sees the failure in the prompt response.
|
|
74
|
+
*/
|
|
75
|
+
protected execute(producer: () => MaybePromise<McpPromptResult>): Promise<McpPromptResult>;
|
|
76
|
+
protected errorResult(message: string): McpPromptResult;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Server-scope prompt base — for prompts that don't target a specific GLSP client session
|
|
80
|
+
* (e.g., a prompt that summarizes the system's state). Bound under {@link McpPromptHandler};
|
|
81
|
+
* the launcher invokes `registerPrompt(server)` once per MCP session.
|
|
82
|
+
*
|
|
83
|
+
* @experimental
|
|
84
|
+
*/
|
|
85
|
+
export declare abstract class AbstractMcpPromptHandler<T = Record<string, unknown>> extends BaseMcpPromptHandler implements McpPromptHandler {
|
|
86
|
+
/** Throw {@link McpToolError} for expected errors; the base wraps. */
|
|
87
|
+
protected abstract createResult(args: T): MaybePromise<McpPromptResult>;
|
|
88
|
+
registerPrompt(server: GLSPMcpServer): void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Diagram-scope prompt base — for prompts whose argument schema carries a `sessionId`
|
|
92
|
+
* (e.g., a `describe-diagram` prompt for one open diagram).
|
|
93
|
+
*
|
|
94
|
+
* The launcher's dispatcher resolves `args.sessionId` to the right GLSP session and invokes
|
|
95
|
+
* {@link handle} on this session's per-instance handler. From the handler's perspective the
|
|
96
|
+
* session is implicit — `this.clientId`, `this.modelState`, `this.aliasService` (and any
|
|
97
|
+
* adopter `@inject(...)` fields) all resolve to that GLSP session's container.
|
|
98
|
+
*
|
|
99
|
+
* @experimental
|
|
100
|
+
*/
|
|
101
|
+
export declare abstract class AbstractMcpDiagramPromptHandler<T extends McpDiagramScopedInput = McpDiagramScopedInput> extends BaseMcpPromptHandler {
|
|
102
|
+
protected clientId: string;
|
|
103
|
+
protected modelState: ModelState;
|
|
104
|
+
protected aliasService: McpIdAliasService;
|
|
105
|
+
/** Throw {@link McpToolError} for expected errors; the base wraps. */
|
|
106
|
+
protected abstract createResult(args: T): MaybePromise<McpPromptResult>;
|
|
107
|
+
/**
|
|
108
|
+
* Public dispatch entry point invoked by {@link McpServerLauncher}'s SDK callback.
|
|
109
|
+
*/
|
|
110
|
+
handle(args: T): Promise<McpPromptResult>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Multi-binding identifier for diagram-scope prompt handler constructors. See
|
|
114
|
+
* {@link McpDiagramToolHandlerConstructor} for the lifecycle pattern — same shape, applied to
|
|
115
|
+
* prompt handlers.
|
|
116
|
+
*/
|
|
117
|
+
export type McpDiagramPromptHandlerConstructor = interfaces.Newable<AbstractMcpDiagramPromptHandler<any>>;
|
|
118
|
+
export declare const McpDiagramPromptHandlerConstructor: unique symbol;
|
|
119
|
+
export {};
|
|
120
|
+
//# sourceMappingURL=mcp-prompt-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-prompt-handler.d.ts","sourceRoot":"","sources":["../../src/server/mcp-prompt-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAY,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAsB,UAAU,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAqC,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAG5D;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC7B,sFAAsF;IACtF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IAC5C,2FAA2F;IAC3F,mBAAmB,IAAI,MAAM,EAAE,CAAC;CACnC;AACD,eAAO,MAAM,gBAAgB,eAA6B,CAAC;AAE3D,gFAAgF;AAChF,uBACe,oBAAoB;IACf,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IAEzC;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAC/B,qHAAqH;IACrH,QAAQ,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IACtC,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,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,+BAA+B,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1G,eAAO,MAAM,kCAAkC,eAA+C,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
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
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.McpDiagramPromptHandlerConstructor = exports.AbstractMcpDiagramPromptHandler = exports.AbstractMcpPromptHandler = exports.McpPromptHandler = void 0;
|
|
28
|
+
const server_1 = require("@eclipse-glsp/server");
|
|
29
|
+
const inversify_1 = require("inversify");
|
|
30
|
+
const mcp_handler_shared_1 = require("./mcp-handler-shared");
|
|
31
|
+
const mcp_id_alias_service_1 = require("./mcp-id-alias-service");
|
|
32
|
+
const mcp_request_context_1 = require("./mcp-request-context");
|
|
33
|
+
exports.McpPromptHandler = Symbol('McpPromptHandler');
|
|
34
|
+
/** Shared infrastructure for both server- and diagram-scope prompt handlers. */
|
|
35
|
+
let BaseMcpPromptHandler = class BaseMcpPromptHandler {
|
|
36
|
+
/** SDK-facing registration config; consumed by both registration paths. */
|
|
37
|
+
toRegistrationConfig() {
|
|
38
|
+
return { title: this.title, description: this.description, argsSchema: this.argsSchema.shape };
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Optional list of tool names this prompt's text refers to via `${OtherHandler.NAME}`
|
|
42
|
+
* substitutions. Default: empty. Override in concrete subclasses to declare references so
|
|
43
|
+
* the launcher can warn at registration time when an adopter unbinds a referenced tool —
|
|
44
|
+
* the prompt would otherwise still register and silently produce text pointing at a tool
|
|
45
|
+
* that no longer exists. Pure declarative metadata; never invoked at request time.
|
|
46
|
+
*/
|
|
47
|
+
referencedToolNames() {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Catches `McpToolError` (→ surfaced as a `user`-role assistant message) and unexpected
|
|
52
|
+
* errors (→ logged + extracted message). Errors map to a single text-content message so
|
|
53
|
+
* the LLM sees the failure in the prompt response.
|
|
54
|
+
*/
|
|
55
|
+
async execute(producer) {
|
|
56
|
+
try {
|
|
57
|
+
return await producer();
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
if (err instanceof mcp_handler_shared_1.McpToolError) {
|
|
61
|
+
return this.errorResult(err.message);
|
|
62
|
+
}
|
|
63
|
+
const message = (0, mcp_handler_shared_1.extractErrorMessage)(err);
|
|
64
|
+
this.logger.error(`Unexpected error in prompt '${this.name}': ${message}`, err);
|
|
65
|
+
return this.errorResult(message);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
errorResult(message) {
|
|
69
|
+
return { messages: [{ role: 'user', content: { type: 'text', text: message } }] };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, inversify_1.inject)(server_1.Logger),
|
|
74
|
+
__metadata("design:type", server_1.Logger)
|
|
75
|
+
], BaseMcpPromptHandler.prototype, "logger", void 0);
|
|
76
|
+
BaseMcpPromptHandler = __decorate([
|
|
77
|
+
(0, inversify_1.injectable)()
|
|
78
|
+
], BaseMcpPromptHandler);
|
|
79
|
+
/**
|
|
80
|
+
* Server-scope prompt base — for prompts that don't target a specific GLSP client session
|
|
81
|
+
* (e.g., a prompt that summarizes the system's state). Bound under {@link McpPromptHandler};
|
|
82
|
+
* the launcher invokes `registerPrompt(server)` once per MCP session.
|
|
83
|
+
*
|
|
84
|
+
* @experimental
|
|
85
|
+
*/
|
|
86
|
+
let AbstractMcpPromptHandler = class AbstractMcpPromptHandler extends BaseMcpPromptHandler {
|
|
87
|
+
registerPrompt(server) {
|
|
88
|
+
server.registerPrompt(this.name, this.toRegistrationConfig(), async (args, extra) => mcp_request_context_1.mcpRequestContext.run(extra, () => this.execute(() => this.createResult(args))));
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
exports.AbstractMcpPromptHandler = AbstractMcpPromptHandler;
|
|
92
|
+
exports.AbstractMcpPromptHandler = AbstractMcpPromptHandler = __decorate([
|
|
93
|
+
(0, inversify_1.injectable)()
|
|
94
|
+
], AbstractMcpPromptHandler);
|
|
95
|
+
/**
|
|
96
|
+
* Diagram-scope prompt base — for prompts whose argument schema carries a `sessionId`
|
|
97
|
+
* (e.g., a `describe-diagram` prompt for one open diagram).
|
|
98
|
+
*
|
|
99
|
+
* The launcher's dispatcher resolves `args.sessionId` to the right GLSP session and invokes
|
|
100
|
+
* {@link handle} on this session's per-instance handler. From the handler's perspective the
|
|
101
|
+
* session is implicit — `this.clientId`, `this.modelState`, `this.aliasService` (and any
|
|
102
|
+
* adopter `@inject(...)` fields) all resolve to that GLSP session's container.
|
|
103
|
+
*
|
|
104
|
+
* @experimental
|
|
105
|
+
*/
|
|
106
|
+
let AbstractMcpDiagramPromptHandler = class AbstractMcpDiagramPromptHandler extends BaseMcpPromptHandler {
|
|
107
|
+
/**
|
|
108
|
+
* Public dispatch entry point invoked by {@link McpServerLauncher}'s SDK callback.
|
|
109
|
+
*/
|
|
110
|
+
handle(args) {
|
|
111
|
+
return this.execute(() => this.createResult(args));
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
exports.AbstractMcpDiagramPromptHandler = AbstractMcpDiagramPromptHandler;
|
|
115
|
+
__decorate([
|
|
116
|
+
(0, inversify_1.inject)(server_1.ClientId),
|
|
117
|
+
__metadata("design:type", String)
|
|
118
|
+
], AbstractMcpDiagramPromptHandler.prototype, "clientId", void 0);
|
|
119
|
+
__decorate([
|
|
120
|
+
(0, inversify_1.inject)(server_1.ModelState),
|
|
121
|
+
__metadata("design:type", Object)
|
|
122
|
+
], AbstractMcpDiagramPromptHandler.prototype, "modelState", void 0);
|
|
123
|
+
__decorate([
|
|
124
|
+
(0, inversify_1.inject)(mcp_id_alias_service_1.McpIdAliasService),
|
|
125
|
+
__metadata("design:type", Object)
|
|
126
|
+
], AbstractMcpDiagramPromptHandler.prototype, "aliasService", void 0);
|
|
127
|
+
exports.AbstractMcpDiagramPromptHandler = AbstractMcpDiagramPromptHandler = __decorate([
|
|
128
|
+
(0, inversify_1.injectable)()
|
|
129
|
+
], AbstractMcpDiagramPromptHandler);
|
|
130
|
+
exports.McpDiagramPromptHandlerConstructor = Symbol('McpDiagramPromptHandlerConstructor');
|
|
131
|
+
//# sourceMappingURL=mcp-prompt-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-prompt-handler.js","sourceRo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
|
|
|
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
|
+
import { RequestHandlerExtra } from '@modelcontextprotocol/sdk/shared/protocol.js';
|
|
17
|
+
import { ServerNotification, ServerRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
18
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
19
|
+
export type McpRequestExtra = RequestHandlerExtra<ServerRequest, ServerNotification>;
|
|
20
|
+
/**
|
|
21
|
+
* Module-level `AsyncLocalStorage` carrying the SDK's per-request `extra` (notification sender,
|
|
22
|
+
* progress token, request id, session id) for the duration of a tool/resource/prompt callback.
|
|
23
|
+
*
|
|
24
|
+
* The handler bases (tool / resource / prompt) wrap each registered SDK callback in
|
|
25
|
+
* `mcpRequestContext.run(extra, () => …)`. Anything inside the handler — and any await chain
|
|
26
|
+
* branching off it — can read the active context via {@link mcpRequestContext.getStore}.
|
|
27
|
+
*
|
|
28
|
+
* This lets {@link McpLogger} forward logs to the MCP client without every handler having to
|
|
29
|
+
* thread `extra` through its own signature, and lets future progress-emission code (P1f / PNG
|
|
30
|
+
* export) reach the same channel from inside `requestUntil` chains.
|
|
31
|
+
*
|
|
32
|
+
* Concurrent requests on the same MCP session each get their own AsyncLocalStorage frame —
|
|
33
|
+
* no cross-talk. Code that runs OUTSIDE a request (init contributions, background timers)
|
|
34
|
+
* sees `undefined` from `getStore()`.
|
|
35
|
+
*/
|
|
36
|
+
export declare const mcpRequestContext: AsyncLocalStorage<McpRequestExtra>;
|
|
37
|
+
//# sourceMappingURL=mcp-request-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-request-context.d.ts","sourceRoot":"","sources":["../../src/server/mcp-request-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,MAAM,eAAe,GAAG,mBAAmB,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;AAErF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,iBAAiB,oCAA2C,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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.mcpRequestContext = void 0;
|
|
19
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
20
|
+
/**
|
|
21
|
+
* Module-level `AsyncLocalStorage` carrying the SDK's per-request `extra` (notification sender,
|
|
22
|
+
* progress token, request id, session id) for the duration of a tool/resource/prompt callback.
|
|
23
|
+
*
|
|
24
|
+
* The handler bases (tool / resource / prompt) wrap each registered SDK callback in
|
|
25
|
+
* `mcpRequestContext.run(extra, () => …)`. Anything inside the handler — and any await chain
|
|
26
|
+
* branching off it — can read the active context via {@link mcpRequestContext.getStore}.
|
|
27
|
+
*
|
|
28
|
+
* This lets {@link McpLogger} forward logs to the MCP client without every handler having to
|
|
29
|
+
* thread `extra` through its own signature, and lets future progress-emission code (P1f / PNG
|
|
30
|
+
* export) reach the same channel from inside `requestUntil` chains.
|
|
31
|
+
*
|
|
32
|
+
* Concurrent requests on the same MCP session each get their own AsyncLocalStorage frame —
|
|
33
|
+
* no cross-talk. Code that runs OUTSIDE a request (init contributions, background timers)
|
|
34
|
+
* sees `undefined` from `getStore()`.
|
|
35
|
+
*/
|
|
36
|
+
exports.mcpRequestContext = new node_async_hooks_1.AsyncLocalStorage();
|
|
37
|
+
//# sourceMappingURL=mcp-request-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-request-context.js","sourceRoot":"","sources":["../../src/server/mcp-request-context.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAIlF,uDAAqD;AAIrD;;;;;;;;;;;;;;;GAeG;AACU,QAAA,iBAAiB,GAAG,IAAI,oCAAiB,EAAmB,CAAC"}
|