@eclipse-glsp/server-mcp 2.7.0-next.9 → 2.8.0-next.0
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/README.md +17 -3
- package/{lib/util/index.d.ts → browser.d.ts} +1 -3
- package/browser.js +18 -0
- package/common.d.ts +16 -0
- package/common.js +18 -0
- package/lib/{resources → browser}/index.d.ts +5 -4
- package/lib/browser/index.d.ts.map +1 -0
- package/lib/{index.js → browser/index.js} +20 -24
- package/lib/browser/index.js.map +1 -0
- package/lib/browser/modules/browser-mcp-server-module.d.ts +42 -0
- package/lib/browser/modules/browser-mcp-server-module.d.ts.map +1 -0
- package/lib/browser/modules/browser-mcp-server-module.js +50 -0
- package/lib/browser/modules/browser-mcp-server-module.js.map +1 -0
- package/lib/browser/reexport.d.ts +17 -0
- package/lib/browser/reexport.d.ts.map +1 -0
- package/lib/{util/index.js → browser/reexport.js} +17 -18
- package/lib/browser/reexport.js.map +1 -0
- package/lib/browser/server/browser-mcp-request-context.d.ts +27 -0
- package/lib/browser/server/browser-mcp-request-context.d.ts.map +1 -0
- package/lib/browser/server/browser-mcp-request-context.js +67 -0
- package/lib/browser/server/browser-mcp-request-context.js.map +1 -0
- package/lib/browser/server/mcp-worker-bridge.d.ts +81 -0
- package/lib/browser/server/mcp-worker-bridge.d.ts.map +1 -0
- package/lib/browser/server/mcp-worker-bridge.js +159 -0
- package/lib/browser/server/mcp-worker-bridge.js.map +1 -0
- package/lib/browser/server/web-mcp-server-launcher.d.ts +34 -0
- package/lib/browser/server/web-mcp-server-launcher.d.ts.map +1 -0
- package/lib/browser/server/web-mcp-server-launcher.js +50 -0
- package/lib/browser/server/web-mcp-server-launcher.js.map +1 -0
- package/lib/common/index.d.ts +65 -0
- package/lib/common/index.d.ts.map +1 -0
- package/lib/common/index.js +81 -0
- package/lib/common/index.js.map +1 -0
- package/lib/{server/mcp-server-module.d.ts → common/modules/abstract-mcp-server-module.d.ts} +55 -46
- package/lib/common/modules/abstract-mcp-server-module.d.ts.map +1 -0
- package/lib/{server/mcp-server-module.js → common/modules/abstract-mcp-server-module.js} +58 -79
- package/lib/common/modules/abstract-mcp-server-module.js.map +1 -0
- package/lib/{server → common/modules}/mcp-diagram-module.d.ts +5 -5
- package/lib/common/modules/mcp-diagram-module.d.ts.map +1 -0
- package/lib/{server → common/modules}/mcp-diagram-module.js +44 -28
- package/lib/common/modules/mcp-diagram-module.js.map +1 -0
- package/lib/{prompts → common/prompts}/handlers/describe-diagram-mcp-prompt-handler.d.ts +2 -1
- package/lib/common/prompts/handlers/describe-diagram-mcp-prompt-handler.d.ts.map +1 -0
- package/lib/{prompts → common/prompts}/handlers/describe-diagram-mcp-prompt-handler.js +21 -15
- package/lib/common/prompts/handlers/describe-diagram-mcp-prompt-handler.js.map +1 -0
- package/lib/{prompts → common/prompts}/handlers/suggest-improvements-mcp-prompt-handler.d.ts +2 -1
- package/lib/common/prompts/handlers/suggest-improvements-mcp-prompt-handler.d.ts.map +1 -0
- package/lib/{prompts → common/prompts}/handlers/suggest-improvements-mcp-prompt-handler.js +16 -12
- package/lib/common/prompts/handlers/suggest-improvements-mcp-prompt-handler.js.map +1 -0
- package/lib/{resources → common/resources}/handlers/diagram-png-mcp-resource-handler.d.ts +4 -1
- package/lib/common/resources/handlers/diagram-png-mcp-resource-handler.d.ts.map +1 -0
- package/lib/{resources → common/resources}/handlers/diagram-png-mcp-resource-handler.js +10 -7
- package/lib/common/resources/handlers/diagram-png-mcp-resource-handler.js.map +1 -0
- package/lib/{resources → common/resources}/handlers/diagram-svg-mcp-resource-handler.d.ts +4 -1
- package/lib/common/resources/handlers/diagram-svg-mcp-resource-handler.d.ts.map +1 -0
- package/lib/{resources → common/resources}/handlers/diagram-svg-mcp-resource-handler.js +9 -6
- package/lib/common/resources/handlers/diagram-svg-mcp-resource-handler.js.map +1 -0
- package/lib/common/resources/services/element-types-provider.d.ts.map +1 -0
- package/lib/common/resources/services/element-types-provider.js.map +1 -0
- package/lib/common/resources/services/mcp-model-serializer.d.ts.map +1 -0
- package/lib/{resources → common/resources}/services/mcp-model-serializer.js +2 -2
- package/lib/common/resources/services/mcp-model-serializer.js.map +1 -0
- package/lib/common/server/abstract-mcp-server-launcher.d.ts +168 -0
- package/lib/common/server/abstract-mcp-server-launcher.d.ts.map +1 -0
- package/lib/{server/mcp-server-launcher.js → common/server/abstract-mcp-server-launcher.js} +235 -121
- package/lib/common/server/abstract-mcp-server-launcher.js.map +1 -0
- package/lib/{server → common/server}/glsp-mcp-server.d.ts +1 -1
- package/lib/common/server/glsp-mcp-server.d.ts.map +1 -0
- package/lib/{server → common/server}/glsp-mcp-server.js +6 -1
- package/lib/common/server/glsp-mcp-server.js.map +1 -0
- package/lib/{server → common/server}/lru-event-store.d.ts +1 -1
- package/lib/common/server/lru-event-store.d.ts.map +1 -0
- package/lib/common/server/lru-event-store.js.map +1 -0
- package/lib/{server → common/server}/mcp-diagram-handler-dispatcher.d.ts +3 -1
- package/lib/common/server/mcp-diagram-handler-dispatcher.d.ts.map +1 -0
- package/lib/{server → common/server}/mcp-diagram-handler-dispatcher.js +12 -6
- package/lib/common/server/mcp-diagram-handler-dispatcher.js.map +1 -0
- package/lib/common/server/mcp-diagram-prompt-handler-registry.d.ts.map +1 -0
- package/lib/common/server/mcp-diagram-prompt-handler-registry.js.map +1 -0
- package/lib/common/server/mcp-diagram-resource-handler-registry.d.ts.map +1 -0
- package/lib/{server → common/server}/mcp-diagram-resource-handler-registry.js +4 -1
- package/lib/common/server/mcp-diagram-resource-handler-registry.js.map +1 -0
- package/lib/common/server/mcp-diagram-tool-handler-registry.d.ts.map +1 -0
- package/lib/{server → common/server}/mcp-diagram-tool-handler-registry.js +3 -1
- package/lib/common/server/mcp-diagram-tool-handler-registry.js.map +1 -0
- package/lib/common/server/mcp-handler-shared.d.ts.map +1 -0
- package/lib/common/server/mcp-handler-shared.js.map +1 -0
- package/lib/common/server/mcp-id-alias-service.d.ts.map +1 -0
- package/lib/common/server/mcp-id-alias-service.js.map +1 -0
- package/lib/{server → common/server}/mcp-input-schemas.d.ts +8 -0
- package/lib/common/server/mcp-input-schemas.d.ts.map +1 -0
- package/lib/{server → common/server}/mcp-input-schemas.js +13 -1
- package/lib/common/server/mcp-input-schemas.js.map +1 -0
- package/lib/common/server/mcp-label-provider.d.ts.map +1 -0
- package/lib/common/server/mcp-label-provider.js.map +1 -0
- package/lib/{server → common/server}/mcp-log-level-registry.d.ts +1 -1
- package/lib/common/server/mcp-log-level-registry.d.ts.map +1 -0
- package/lib/common/server/mcp-log-level-registry.js.map +1 -0
- package/lib/{server → common/server}/mcp-logger.d.ts +4 -2
- package/lib/common/server/mcp-logger.d.ts.map +1 -0
- package/lib/{server → common/server}/mcp-logger.js +11 -3
- package/lib/common/server/mcp-logger.js.map +1 -0
- package/lib/common/server/mcp-mime-types.d.ts.map +1 -0
- package/lib/common/server/mcp-mime-types.js.map +1 -0
- package/lib/{server → common/server}/mcp-options.d.ts +1 -1
- package/lib/common/server/mcp-options.d.ts.map +1 -0
- package/lib/{server → common/server}/mcp-options.js +1 -1
- package/lib/common/server/mcp-options.js.map +1 -0
- package/lib/{server → common/server}/mcp-progress-reporter.d.ts +4 -2
- package/lib/common/server/mcp-progress-reporter.d.ts.map +1 -0
- package/lib/{server → common/server}/mcp-progress-reporter.js +14 -3
- package/lib/common/server/mcp-progress-reporter.js.map +1 -0
- package/lib/{server → common/server}/mcp-prompt-handler.d.ts +3 -1
- package/lib/common/server/mcp-prompt-handler.d.ts.map +1 -0
- package/lib/{server → common/server}/mcp-prompt-handler.js +10 -2
- package/lib/common/server/mcp-prompt-handler.js.map +1 -0
- package/lib/common/server/mcp-request-context.d.ts +35 -0
- package/lib/common/server/mcp-request-context.d.ts.map +1 -0
- package/lib/common/server/mcp-request-context.js +30 -0
- package/lib/common/server/mcp-request-context.js.map +1 -0
- package/lib/{server → common/server}/mcp-resource-handler.d.ts +3 -1
- package/lib/common/server/mcp-resource-handler.d.ts.map +1 -0
- package/lib/{server → common/server}/mcp-resource-handler.js +13 -5
- package/lib/common/server/mcp-resource-handler.js.map +1 -0
- package/lib/common/server/mcp-session.d.ts.map +1 -0
- package/lib/common/server/mcp-session.js.map +1 -0
- package/lib/{server → common/server}/mcp-tool-handler.d.ts +3 -1
- package/lib/common/server/mcp-tool-handler.d.ts.map +1 -0
- package/lib/{server → common/server}/mcp-tool-handler.js +7 -1
- package/lib/{server → common/server}/mcp-tool-handler.js.map +1 -1
- package/lib/{tools → common/tools}/handlers/count-elements-mcp-tool-handler.d.ts +2 -1
- package/lib/common/tools/handlers/count-elements-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/count-elements-mcp-tool-handler.js +4 -3
- package/lib/common/tools/handlers/count-elements-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/create-edges-mcp-tool-handler.d.ts +4 -1
- package/lib/common/tools/handlers/create-edges-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/create-edges-mcp-tool-handler.js +9 -7
- package/lib/common/tools/handlers/create-edges-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/create-nodes-mcp-tool-handler.d.ts +4 -1
- package/lib/common/tools/handlers/create-nodes-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/create-nodes-mcp-tool-handler.js +10 -8
- package/lib/common/tools/handlers/create-nodes-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/delete-elements-mcp-tool-handler.d.ts +4 -1
- package/lib/common/tools/handlers/delete-elements-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/delete-elements-mcp-tool-handler.js +9 -6
- package/lib/common/tools/handlers/delete-elements-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/diagram-model-mcp-tool-handler.d.ts +2 -1
- package/lib/common/tools/handlers/diagram-model-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/diagram-model-mcp-tool-handler.js +4 -3
- package/lib/common/tools/handlers/diagram-model-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/element-types-mcp-tool-handler.d.ts +2 -1
- package/lib/common/tools/handlers/element-types-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/element-types-mcp-tool-handler.js +6 -5
- package/lib/common/tools/handlers/element-types-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/get-selection-mcp-tool-handler.d.ts +2 -1
- package/lib/common/tools/handlers/get-selection-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/get-selection-mcp-tool-handler.js +6 -4
- package/lib/common/tools/handlers/get-selection-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/layout-mcp-tool-handler.d.ts +4 -1
- package/lib/common/tools/handlers/layout-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/layout-mcp-tool-handler.js +7 -5
- package/lib/common/tools/handlers/layout-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/modify-edges-mcp-tool-handler.d.ts +2 -1
- package/lib/common/tools/handlers/modify-edges-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/modify-edges-mcp-tool-handler.js +12 -10
- package/lib/common/tools/handlers/modify-edges-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/modify-nodes-mcp-tool-handler.d.ts +2 -1
- package/lib/common/tools/handlers/modify-nodes-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/modify-nodes-mcp-tool-handler.js +13 -11
- package/lib/common/tools/handlers/modify-nodes-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/query-elements-mcp-tool-handler.d.ts +2 -1
- package/lib/common/tools/handlers/query-elements-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/query-elements-mcp-tool-handler.js +7 -5
- package/lib/common/tools/handlers/query-elements-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/redo-mcp-tool-handler.d.ts +2 -1
- package/lib/common/tools/handlers/redo-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/redo-mcp-tool-handler.js +6 -4
- package/lib/common/tools/handlers/redo-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/save-model-mcp-tool-handler.d.ts +3 -1
- package/lib/common/tools/handlers/save-model-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/save-model-mcp-tool-handler.js +7 -5
- package/lib/common/tools/handlers/save-model-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/session-info-mcp-tool-handler.d.ts +2 -1
- package/lib/common/tools/handlers/session-info-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/session-info-mcp-tool-handler.js +4 -3
- package/lib/common/tools/handlers/session-info-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/set-selection-mcp-tool-handler.d.ts +2 -1
- package/lib/common/tools/handlers/set-selection-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/set-selection-mcp-tool-handler.js +6 -5
- package/lib/common/tools/handlers/set-selection-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/set-view-mcp-tool-handler.d.ts +2 -1
- package/lib/common/tools/handlers/set-view-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/set-view-mcp-tool-handler.js +10 -8
- package/lib/common/tools/handlers/set-view-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/undo-mcp-tool-handler.d.ts +2 -1
- package/lib/common/tools/handlers/undo-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/undo-mcp-tool-handler.js +6 -4
- package/lib/common/tools/handlers/undo-mcp-tool-handler.js.map +1 -0
- package/lib/{tools → common/tools}/handlers/validate-diagram-mcp-tool-handler.d.ts +2 -1
- package/lib/common/tools/handlers/validate-diagram-mcp-tool-handler.d.ts.map +1 -0
- package/lib/{tools → common/tools}/handlers/validate-diagram-mcp-tool-handler.js +0 -0
- package/lib/common/tools/handlers/validate-diagram-mcp-tool-handler.js.map +1 -0
- package/lib/common/util/markdown-util.d.ts.map +1 -0
- package/lib/common/util/markdown-util.js.map +1 -0
- package/lib/common/util/mcp-util.d.ts.map +1 -0
- package/lib/common/util/mcp-util.js.map +1 -0
- package/lib/{prompts → node}/index.d.ts +4 -2
- package/lib/node/index.d.ts.map +1 -0
- package/lib/{resources → node}/index.js +4 -4
- package/lib/node/index.js.map +1 -0
- package/lib/node/modules/node-mcp-server-module.d.ts +37 -0
- package/lib/node/modules/node-mcp-server-module.d.ts.map +1 -0
- package/lib/node/modules/node-mcp-server-module.js +52 -0
- package/lib/node/modules/node-mcp-server-module.js.map +1 -0
- package/lib/node/reexport.d.ts +17 -0
- package/lib/node/reexport.d.ts.map +1 -0
- package/lib/{prompts/index.js → node/reexport.js} +17 -18
- package/lib/node/reexport.js.map +1 -0
- package/lib/node/server/node-mcp-request-context.d.ts +24 -0
- package/lib/node/server/node-mcp-request-context.d.ts.map +1 -0
- package/lib/node/server/node-mcp-request-context.js +43 -0
- package/lib/node/server/node-mcp-request-context.js.map +1 -0
- package/lib/node/server/node-mcp-server-launcher.d.ts +55 -0
- package/lib/node/server/node-mcp-server-launcher.d.ts.map +1 -0
- package/lib/node/server/node-mcp-server-launcher.js +123 -0
- package/lib/node/server/node-mcp-server-launcher.js.map +1 -0
- package/node.d.ts +16 -0
- package/{src/util/index.ts → node.js} +2 -2
- package/package.json +19 -13
- package/src/{resources → browser}/index.ts +5 -4
- package/src/browser/modules/browser-mcp-server-module.ts +54 -0
- package/src/browser/reexport.ts +16 -0
- package/src/browser/server/browser-mcp-request-context.ts +59 -0
- package/src/browser/server/mcp-worker-bridge.ts +200 -0
- package/src/browser/server/web-mcp-server-launcher.ts +39 -0
- package/src/common/index.ts +65 -0
- package/src/{server/mcp-server-module.ts → common/modules/abstract-mcp-server-module.ts} +65 -77
- package/src/{server → common/modules}/mcp-diagram-module.ts +27 -28
- package/src/{prompts → common/prompts}/handlers/describe-diagram-mcp-prompt-handler.ts +8 -9
- package/src/{prompts → common/prompts}/handlers/suggest-improvements-mcp-prompt-handler.ts +6 -7
- package/src/{resources → common/resources}/handlers/diagram-png-mcp-resource-handler.ts +5 -9
- package/src/{resources → common/resources}/handlers/diagram-svg-mcp-resource-handler.ts +5 -9
- package/src/{resources → common/resources}/services/mcp-model-serializer.ts +1 -1
- package/src/common/server/abstract-mcp-server-launcher.spec.ts +458 -0
- package/src/common/server/abstract-mcp-server-launcher.ts +524 -0
- package/src/{server → common/server}/glsp-mcp-server.ts +7 -2
- package/src/{server → common/server}/lru-event-store.ts +1 -1
- package/src/{server → common/server}/mcp-diagram-handler-dispatcher.ts +13 -9
- package/src/{server → common/server}/mcp-diagram-resource-handler-registry.ts +4 -1
- package/src/{server → common/server}/mcp-diagram-tool-handler-registry.ts +3 -1
- package/src/{server → common/server}/mcp-input-schemas.ts +13 -0
- package/src/{server → common/server}/mcp-log-level-registry.ts +1 -1
- package/src/{server → common/server}/mcp-logger.spec.ts +26 -18
- package/src/{server → common/server}/mcp-logger.ts +9 -5
- package/src/{server → common/server}/mcp-options.ts +1 -1
- package/src/{server → common/server}/mcp-progress-reporter.spec.ts +19 -9
- package/src/{server → common/server}/mcp-progress-reporter.ts +9 -5
- package/src/{server → common/server}/mcp-prompt-handler.ts +8 -4
- package/src/{server → common/server}/mcp-request-context.ts +20 -16
- package/src/{server → common/server}/mcp-resource-handler.ts +11 -7
- package/src/{server → common/server}/mcp-tool-handler.spec.ts +4 -4
- package/src/{server → common/server}/mcp-tool-handler.ts +8 -4
- package/src/{tools → common/tools}/handlers/count-elements-mcp-tool-handler.spec.ts +3 -1
- package/src/{tools → common/tools}/handlers/count-elements-mcp-tool-handler.ts +3 -1
- package/src/{tools → common/tools}/handlers/create-edges-mcp-tool-handler.spec.ts +3 -1
- package/src/{tools → common/tools}/handlers/create-edges-mcp-tool-handler.ts +7 -5
- package/src/{tools → common/tools}/handlers/create-nodes-mcp-tool-handler.spec.ts +3 -1
- package/src/{tools → common/tools}/handlers/create-nodes-mcp-tool-handler.ts +7 -5
- package/src/{tools → common/tools}/handlers/delete-elements-mcp-tool-handler.ts +7 -9
- package/src/{tools → common/tools}/handlers/diagram-model-mcp-tool-handler.ts +3 -1
- package/src/{tools → common/tools}/handlers/element-types-mcp-tool-handler.ts +2 -1
- package/src/{tools → common/tools}/handlers/get-selection-mcp-tool-handler.ts +3 -1
- package/src/{tools → common/tools}/handlers/layout-mcp-tool-handler.ts +6 -3
- package/src/{tools → common/tools}/handlers/modify-edges-mcp-tool-handler.ts +6 -6
- package/src/{tools → common/tools}/handlers/modify-nodes-mcp-tool-handler.ts +6 -6
- package/src/{tools → common/tools}/handlers/query-elements-mcp-tool-handler.spec.ts +3 -1
- package/src/{tools → common/tools}/handlers/query-elements-mcp-tool-handler.ts +3 -7
- package/src/{tools → common/tools}/handlers/redo-mcp-tool-handler.ts +3 -1
- package/src/{tools → common/tools}/handlers/save-model-mcp-tool-handler.ts +4 -1
- package/src/{tools → common/tools}/handlers/session-info-mcp-tool-handler.spec.ts +1 -1
- package/src/{tools → common/tools}/handlers/session-info-mcp-tool-handler.ts +2 -1
- package/src/{tools → common/tools}/handlers/set-selection-mcp-tool-handler.spec.ts +3 -1
- package/src/{tools → common/tools}/handlers/set-selection-mcp-tool-handler.ts +3 -1
- package/src/{tools → common/tools}/handlers/set-view-mcp-tool-handler.ts +3 -9
- package/src/{tools → common/tools}/handlers/undo-mcp-tool-handler.ts +3 -1
- package/src/{tools → common/tools}/handlers/validate-diagram-mcp-tool-handler.ts +0 -0
- package/src/{prompts → node}/index.ts +4 -2
- package/src/node/modules/node-mcp-server-module.ts +56 -0
- package/src/node/reexport.ts +16 -0
- package/src/node/server/mcp-http-transport-e2e.spec.ts +297 -0
- package/src/node/server/node-mcp-request-context.ts +33 -0
- package/src/{server/mcp-server-launcher.spec.ts → node/server/node-mcp-server-launcher.spec.ts} +19 -8
- package/src/node/server/node-mcp-server-launcher.ts +130 -0
- package/lib/index.d.ts +0 -23
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/prompts/handlers/describe-diagram-mcp-prompt-handler.d.ts.map +0 -1
- package/lib/prompts/handlers/describe-diagram-mcp-prompt-handler.js.map +0 -1
- package/lib/prompts/handlers/suggest-improvements-mcp-prompt-handler.d.ts.map +0 -1
- package/lib/prompts/handlers/suggest-improvements-mcp-prompt-handler.js.map +0 -1
- package/lib/prompts/index.d.ts.map +0 -1
- package/lib/prompts/index.js.map +0 -1
- package/lib/resources/handlers/diagram-png-mcp-resource-handler.d.ts.map +0 -1
- package/lib/resources/handlers/diagram-png-mcp-resource-handler.js.map +0 -1
- package/lib/resources/handlers/diagram-svg-mcp-resource-handler.d.ts.map +0 -1
- package/lib/resources/handlers/diagram-svg-mcp-resource-handler.js.map +0 -1
- package/lib/resources/index.d.ts.map +0 -1
- package/lib/resources/index.js.map +0 -1
- package/lib/resources/services/element-types-provider.d.ts.map +0 -1
- package/lib/resources/services/element-types-provider.js.map +0 -1
- package/lib/resources/services/mcp-model-serializer.d.ts.map +0 -1
- package/lib/resources/services/mcp-model-serializer.js.map +0 -1
- package/lib/server/glsp-mcp-server.d.ts.map +0 -1
- package/lib/server/glsp-mcp-server.js.map +0 -1
- package/lib/server/index.d.ts +0 -37
- package/lib/server/index.d.ts.map +0 -1
- package/lib/server/index.js +0 -57
- package/lib/server/index.js.map +0 -1
- package/lib/server/lru-event-store.d.ts.map +0 -1
- package/lib/server/lru-event-store.js.map +0 -1
- package/lib/server/mcp-diagram-handler-dispatcher.d.ts.map +0 -1
- package/lib/server/mcp-diagram-handler-dispatcher.js.map +0 -1
- package/lib/server/mcp-diagram-module.d.ts.map +0 -1
- package/lib/server/mcp-diagram-module.js.map +0 -1
- package/lib/server/mcp-diagram-prompt-handler-registry.d.ts.map +0 -1
- package/lib/server/mcp-diagram-prompt-handler-registry.js.map +0 -1
- package/lib/server/mcp-diagram-resource-handler-registry.d.ts.map +0 -1
- package/lib/server/mcp-diagram-resource-handler-registry.js.map +0 -1
- package/lib/server/mcp-diagram-tool-handler-registry.d.ts.map +0 -1
- package/lib/server/mcp-diagram-tool-handler-registry.js.map +0 -1
- package/lib/server/mcp-handler-shared.d.ts.map +0 -1
- package/lib/server/mcp-handler-shared.js.map +0 -1
- package/lib/server/mcp-http-transport.d.ts +0 -93
- package/lib/server/mcp-http-transport.d.ts.map +0 -1
- package/lib/server/mcp-http-transport.js +0 -350
- package/lib/server/mcp-http-transport.js.map +0 -1
- package/lib/server/mcp-id-alias-service.d.ts.map +0 -1
- package/lib/server/mcp-id-alias-service.js.map +0 -1
- package/lib/server/mcp-input-schemas.d.ts.map +0 -1
- package/lib/server/mcp-input-schemas.js.map +0 -1
- package/lib/server/mcp-label-provider.d.ts.map +0 -1
- package/lib/server/mcp-label-provider.js.map +0 -1
- package/lib/server/mcp-log-level-registry.d.ts.map +0 -1
- package/lib/server/mcp-log-level-registry.js.map +0 -1
- package/lib/server/mcp-logger.d.ts.map +0 -1
- package/lib/server/mcp-logger.js.map +0 -1
- package/lib/server/mcp-mime-types.d.ts.map +0 -1
- package/lib/server/mcp-mime-types.js.map +0 -1
- package/lib/server/mcp-options.d.ts.map +0 -1
- package/lib/server/mcp-options.js.map +0 -1
- package/lib/server/mcp-progress-reporter.d.ts.map +0 -1
- package/lib/server/mcp-progress-reporter.js.map +0 -1
- package/lib/server/mcp-prompt-handler.d.ts.map +0 -1
- package/lib/server/mcp-prompt-handler.js.map +0 -1
- package/lib/server/mcp-request-context.d.ts +0 -37
- package/lib/server/mcp-request-context.d.ts.map +0 -1
- package/lib/server/mcp-request-context.js +0 -37
- package/lib/server/mcp-request-context.js.map +0 -1
- package/lib/server/mcp-resource-handler.d.ts.map +0 -1
- package/lib/server/mcp-resource-handler.js.map +0 -1
- package/lib/server/mcp-server-launcher.d.ts +0 -143
- package/lib/server/mcp-server-launcher.d.ts.map +0 -1
- package/lib/server/mcp-server-launcher.js.map +0 -1
- package/lib/server/mcp-server-module.d.ts.map +0 -1
- package/lib/server/mcp-server-module.js.map +0 -1
- package/lib/server/mcp-session.d.ts.map +0 -1
- package/lib/server/mcp-session.js.map +0 -1
- package/lib/server/mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/count-elements-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/count-elements-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/create-edges-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/create-edges-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/create-nodes-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/create-nodes-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/delete-elements-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/delete-elements-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/diagram-model-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/diagram-model-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/element-types-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/element-types-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/get-selection-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/get-selection-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/layout-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/layout-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/modify-edges-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/modify-edges-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/modify-nodes-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/modify-nodes-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/query-elements-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/query-elements-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/redo-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/redo-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/save-model-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/save-model-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/session-info-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/session-info-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/set-selection-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/set-selection-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/set-view-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/set-view-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/undo-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/undo-mcp-tool-handler.js.map +0 -1
- package/lib/tools/handlers/validate-diagram-mcp-tool-handler.d.ts.map +0 -1
- package/lib/tools/handlers/validate-diagram-mcp-tool-handler.js.map +0 -1
- package/lib/tools/index.d.ts +0 -34
- package/lib/tools/index.d.ts.map +0 -1
- package/lib/tools/index.js +0 -50
- package/lib/tools/index.js.map +0 -1
- package/lib/util/index.d.ts.map +0 -1
- package/lib/util/index.js.map +0 -1
- package/lib/util/markdown-util.d.ts.map +0 -1
- package/lib/util/markdown-util.js.map +0 -1
- package/lib/util/mcp-util.d.ts.map +0 -1
- package/lib/util/mcp-util.js.map +0 -1
- package/src/index.ts +0 -24
- package/src/server/index.ts +0 -42
- package/src/server/mcp-http-transport-e2e.spec.ts +0 -151
- package/src/server/mcp-http-transport.spec.ts +0 -385
- package/src/server/mcp-http-transport.ts +0 -368
- package/src/server/mcp-server-launcher.ts +0 -369
- package/src/tools/index.ts +0 -34
- /package/lib/{resources → common/resources}/services/element-types-provider.d.ts +0 -0
- /package/lib/{resources → common/resources}/services/element-types-provider.js +0 -0
- /package/lib/{resources → common/resources}/services/mcp-model-serializer.d.ts +0 -0
- /package/lib/{server → common/server}/lru-event-store.js +0 -0
- /package/lib/{server → common/server}/mcp-diagram-prompt-handler-registry.d.ts +0 -0
- /package/lib/{server → common/server}/mcp-diagram-prompt-handler-registry.js +0 -0
- /package/lib/{server → common/server}/mcp-diagram-resource-handler-registry.d.ts +0 -0
- /package/lib/{server → common/server}/mcp-diagram-tool-handler-registry.d.ts +0 -0
- /package/lib/{server → common/server}/mcp-handler-shared.d.ts +0 -0
- /package/lib/{server → common/server}/mcp-handler-shared.js +0 -0
- /package/lib/{server → common/server}/mcp-id-alias-service.d.ts +0 -0
- /package/lib/{server → common/server}/mcp-id-alias-service.js +0 -0
- /package/lib/{server → common/server}/mcp-label-provider.d.ts +0 -0
- /package/lib/{server → common/server}/mcp-label-provider.js +0 -0
- /package/lib/{server → common/server}/mcp-log-level-registry.js +0 -0
- /package/lib/{server → common/server}/mcp-mime-types.d.ts +0 -0
- /package/lib/{server → common/server}/mcp-mime-types.js +0 -0
- /package/lib/{server → common/server}/mcp-session.d.ts +0 -0
- /package/lib/{server → common/server}/mcp-session.js +0 -0
- /package/lib/{util → common/util}/markdown-util.d.ts +0 -0
- /package/lib/{util → common/util}/markdown-util.js +0 -0
- /package/lib/{util → common/util}/mcp-util.d.ts +0 -0
- /package/lib/{util → common/util}/mcp-util.js +0 -0
- /package/src/{resources → common/resources}/services/element-types-provider.ts +0 -0
- /package/src/{server → common/server}/glsp-mcp-server.spec.ts +0 -0
- /package/src/{server → common/server}/lru-event-store.spec.ts +0 -0
- /package/src/{server → common/server}/mcp-diagram-handler-dispatcher.spec.ts +0 -0
- /package/src/{server → common/server}/mcp-diagram-prompt-handler-registry.ts +0 -0
- /package/src/{server → common/server}/mcp-handler-shared.spec.ts +0 -0
- /package/src/{server → common/server}/mcp-handler-shared.ts +0 -0
- /package/src/{server → common/server}/mcp-id-alias-service.spec.ts +0 -0
- /package/src/{server → common/server}/mcp-id-alias-service.ts +0 -0
- /package/src/{server → common/server}/mcp-label-provider.ts +0 -0
- /package/src/{server → common/server}/mcp-log-level-registry.spec.ts +0 -0
- /package/src/{server → common/server}/mcp-mime-types.ts +0 -0
- /package/src/{server → common/server}/mcp-session.ts +0 -0
- /package/src/{tools → common/tools}/tool-annotations.spec.ts +0 -0
- /package/src/{util → common/util}/markdown-util.ts +0 -0
- /package/src/{util → common/util}/mcp-util.ts +0 -0
- /package/src/{server → node/server}/raw-http.spec.ts +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
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 * as http from 'http';
|
|
17
|
+
import { AddressInfo } from 'net';
|
|
18
|
+
import { AbstractMcpServerLauncher, FullMcpServerConfiguration, TransportEndpoint } from '../../common/server/abstract-mcp-server-launcher';
|
|
19
|
+
export { FullMcpServerConfiguration, TransportEndpoint } from '../../common/server/abstract-mcp-server-launcher';
|
|
20
|
+
/**
|
|
21
|
+
* Stdout tag used to announce the started MCP server so IDE integrations can pick up the URL
|
|
22
|
+
* automatically. The full line is `MCP_SERVER_READY_MSG + JSON.stringify({name, url, route})`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const MCP_SERVER_READY_MSG = "[GLSP-MCP-Server]:Ready. ";
|
|
25
|
+
/**
|
|
26
|
+
* Returns true iff `host` is a loopback bind: `localhost`, `::1`, or any IPv4 in
|
|
27
|
+
* `127.0.0.0/8`. Any other value (`0.0.0.0`, `::`, LAN/public addresses) is non-loopback.
|
|
28
|
+
* Used by {@link assertLoopbackOrAcknowledged} for the auth-footgun runtime check.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isLoopbackHost(host: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Refuse to bind on a non-loopback host unless the operator has acknowledged that traffic is
|
|
33
|
+
* authenticated externally (reverse proxy, mTLS, ACL). The MCP server has no built-in auth.
|
|
34
|
+
* Exported for regression tests only; not part of the public surface.
|
|
35
|
+
*/
|
|
36
|
+
export declare function assertLoopbackOrAcknowledged(host: string, acknowledgedNoAuth: boolean | undefined): void;
|
|
37
|
+
/**
|
|
38
|
+
* Boots the embedded MCP HTTP server when a GLSP `initialize` call carries an `mcpServer`
|
|
39
|
+
* configuration. Runs in-process via the {@link GLSPServerInitializer} lifecycle. The portable
|
|
40
|
+
* per-session multiplexer + handler dispatch lives on {@link AbstractMcpServerLauncher}; this
|
|
41
|
+
* subclass only binds the Node HTTP listener via `@hono/node-server`, runs the loopback-auth
|
|
42
|
+
* guard, and announces the URL via {@link MCP_SERVER_READY_MSG}.
|
|
43
|
+
*/
|
|
44
|
+
export declare class NodeMcpServerLauncher extends AbstractMcpServerLauncher {
|
|
45
|
+
protected bindTransport(config: FullMcpServerConfiguration): Promise<TransportEndpoint>;
|
|
46
|
+
/**
|
|
47
|
+
* Start the Hono-on-Node listener, returning the underlying Node `http.Server` once it is
|
|
48
|
+
* listening. Translates `EADDRINUSE` into an actionable error naming the offending port
|
|
49
|
+
* and the override path adopters reach for first (`mcpServer.port` in `initialize`).
|
|
50
|
+
*/
|
|
51
|
+
protected startListener(handler: (req: Request) => Promise<Response>, config: FullMcpServerConfiguration): Promise<http.Server>;
|
|
52
|
+
protected resolveAddress(server: http.Server): AddressInfo;
|
|
53
|
+
protected toServerUrl({ address, family, port }: AddressInfo, route: string, protocol?: string): string;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=node-mcp-server-launcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-mcp-server-launcher.d.ts","sourceRoot":"","sources":["../../../src/node/server/node-mcp-server-launcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAKlF,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAClC,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAC;AAG5I,OAAO,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAC;AAEjH;;;GAGG;AACH,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAEhE;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,kBAAkB,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAWxG;AAED;;;;;;GAMG;AACH,qBACa,qBAAsB,SAAQ,yBAAyB;cAChD,aAAa,CAAC,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAuB7F;;;;OAIG;IACH,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;IAqB/H,SAAS,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,WAAW;IAQ1D,SAAS,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAS,GAAG,MAAM;CAI1G"}
|
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.NodeMcpServerLauncher = exports.MCP_SERVER_READY_MSG = void 0;
|
|
25
|
+
exports.isLoopbackHost = isLoopbackHost;
|
|
26
|
+
exports.assertLoopbackOrAcknowledged = assertLoopbackOrAcknowledged;
|
|
27
|
+
const server_1 = require("@eclipse-glsp/server");
|
|
28
|
+
const node_server_1 = require("@hono/node-server");
|
|
29
|
+
const inversify_1 = require("inversify");
|
|
30
|
+
const abstract_mcp_server_launcher_1 = require("../../common/server/abstract-mcp-server-launcher");
|
|
31
|
+
/**
|
|
32
|
+
* Stdout tag used to announce the started MCP server so IDE integrations can pick up the URL
|
|
33
|
+
* automatically. The full line is `MCP_SERVER_READY_MSG + JSON.stringify({name, url, route})`.
|
|
34
|
+
*/
|
|
35
|
+
exports.MCP_SERVER_READY_MSG = '[GLSP-MCP-Server]:Ready. ';
|
|
36
|
+
/**
|
|
37
|
+
* Returns true iff `host` is a loopback bind: `localhost`, `::1`, or any IPv4 in
|
|
38
|
+
* `127.0.0.0/8`. Any other value (`0.0.0.0`, `::`, LAN/public addresses) is non-loopback.
|
|
39
|
+
* Used by {@link assertLoopbackOrAcknowledged} for the auth-footgun runtime check.
|
|
40
|
+
*/
|
|
41
|
+
function isLoopbackHost(host) {
|
|
42
|
+
return host === 'localhost' || host === '::1' || /^127\./.test(host);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Refuse to bind on a non-loopback host unless the operator has acknowledged that traffic is
|
|
46
|
+
* authenticated externally (reverse proxy, mTLS, ACL). The MCP server has no built-in auth.
|
|
47
|
+
* Exported for regression tests only; not part of the public surface.
|
|
48
|
+
*/
|
|
49
|
+
function assertLoopbackOrAcknowledged(host, acknowledgedNoAuth) {
|
|
50
|
+
if (isLoopbackHost(host) || acknowledgedNoAuth === true) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
throw new Error(`Refusing to bind MCP server to non-loopback host '${host}' without authentication. ` +
|
|
54
|
+
'The MCP server has no built-in auth; binding to a non-loopback interface exposes an ' +
|
|
55
|
+
'unauthenticated MCP endpoint to the network. If this is intentional (e.g., the endpoint ' +
|
|
56
|
+
'is fronted by a reverse proxy, mTLS, or a network ACL that authenticates traffic), set ' +
|
|
57
|
+
'`acknowledgedNoAuth: true` on the McpServerDefaults you pass to the server module.');
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Boots the embedded MCP HTTP server when a GLSP `initialize` call carries an `mcpServer`
|
|
61
|
+
* configuration. Runs in-process via the {@link GLSPServerInitializer} lifecycle. The portable
|
|
62
|
+
* per-session multiplexer + handler dispatch lives on {@link AbstractMcpServerLauncher}; this
|
|
63
|
+
* subclass only binds the Node HTTP listener via `@hono/node-server`, runs the loopback-auth
|
|
64
|
+
* guard, and announces the URL via {@link MCP_SERVER_READY_MSG}.
|
|
65
|
+
*/
|
|
66
|
+
let NodeMcpServerLauncher = class NodeMcpServerLauncher extends abstract_mcp_server_launcher_1.AbstractMcpServerLauncher {
|
|
67
|
+
async bindTransport(config) {
|
|
68
|
+
// Auth-footgun guard: refuse non-loopback bind unless the operator opted in via
|
|
69
|
+
// `acknowledgedNoAuth`. Runs BEFORE the listener binds so a careless `host: '0.0.0.0'`
|
|
70
|
+
// doesn't get a chance to expose an unauthenticated endpoint.
|
|
71
|
+
assertLoopbackOrAcknowledged(config.host, config.options.acknowledgedNoAuth);
|
|
72
|
+
const handler = this.getRequestHandler();
|
|
73
|
+
const server = await this.startListener(handler, config);
|
|
74
|
+
// Disable the per-request timeout so long-lived SSE GET streams aren't killed during
|
|
75
|
+
// chat idle periods. Node's default 5-minute `requestTimeout` (>=18.1) treats SSE as
|
|
76
|
+
// a single in-progress request and tears the socket whenever no events flow for ≥5 min.
|
|
77
|
+
server.requestTimeout = 0;
|
|
78
|
+
const addressInfo = this.resolveAddress(server);
|
|
79
|
+
const url = this.toServerUrl(addressInfo, config.route);
|
|
80
|
+
this.toDispose.push(server_1.Disposable.create(() => server.close()));
|
|
81
|
+
// stdout ready-marker for parent processes to discover the URL. Uses `console.log`
|
|
82
|
+
// (not the GLSP logger) so adopter logger config can never hide it.
|
|
83
|
+
console.log(exports.MCP_SERVER_READY_MSG + JSON.stringify({ name: config.name, url, route: config.route }));
|
|
84
|
+
return { url };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Start the Hono-on-Node listener, returning the underlying Node `http.Server` once it is
|
|
88
|
+
* listening. Translates `EADDRINUSE` into an actionable error naming the offending port
|
|
89
|
+
* and the override path adopters reach for first (`mcpServer.port` in `initialize`).
|
|
90
|
+
*/
|
|
91
|
+
startListener(handler, config) {
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
const server = (0, node_server_1.serve)({ fetch: handler, port: config.port, hostname: config.host });
|
|
94
|
+
server.once('error', err => {
|
|
95
|
+
const nodeErr = err;
|
|
96
|
+
if (nodeErr.code === 'EADDRINUSE') {
|
|
97
|
+
const portLabel = config.port === 0 ? 'requested address' : `${config.host}:${config.port}`;
|
|
98
|
+
reject(new Error(`MCP server cannot bind ${portLabel}: address already in use. ` +
|
|
99
|
+
'Pass a different `mcpServer.port` in the GLSP `initialize` call, or omit the port to get a random one.'));
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
reject(err);
|
|
103
|
+
});
|
|
104
|
+
server.once('listening', () => resolve(server));
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
resolveAddress(server) {
|
|
108
|
+
const address = server.address();
|
|
109
|
+
if (!address || typeof address === 'string') {
|
|
110
|
+
throw new Error(`MCP server unexpectedly bound to ${String(address)} — expected an AddressInfo.`);
|
|
111
|
+
}
|
|
112
|
+
return address;
|
|
113
|
+
}
|
|
114
|
+
toServerUrl({ address, family, port }, route, protocol = 'http') {
|
|
115
|
+
const host = address === '::' || address === '0.0.0.0' ? 'localhost' : family === 'IPv6' ? `[${address}]` : address;
|
|
116
|
+
return `${protocol}://${host}:${port}${route}`;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
exports.NodeMcpServerLauncher = NodeMcpServerLauncher;
|
|
120
|
+
exports.NodeMcpServerLauncher = NodeMcpServerLauncher = __decorate([
|
|
121
|
+
(0, inversify_1.injectable)()
|
|
122
|
+
], NodeMcpServerLauncher);
|
|
123
|
+
//# sourceMappingURL=node-mcp-server-launcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-mcp-server-launcher.js","sourceRoot":"","sources":["../../../src/node/server/node-mcp-server-launcher.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;AAuBlF,wCAEC;AAOD,oEAWC;AAzCD,iDAAkD;AAClD,mDAA0C;AAC1C,yCAAuC;AAGvC,mGAA4I;AAK5I;;;GAGG;AACU,QAAA,oBAAoB,GAAG,2BAA2B,CAAC;AAEhE;;;;GAIG;AACH,SAAgB,cAAc,CAAC,IAAY;IACvC,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,KAAK,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzE,CAAC;AAED;;;;GAIG;AACH,SAAgB,4BAA4B,CAAC,IAAY,EAAE,kBAAuC;IAC9F,IAAI,cAAc,CAAC,IAAI,CAAC,IAAI,kBAAkB,KAAK,IAAI,EAAE,CAAC;QACtD,OAAO;IACX,CAAC;IACD,MAAM,IAAI,KAAK,CACX,qDAAqD,IAAI,4BAA4B;QACjF,sFAAsF;QACtF,0FAA0F;QAC1F,yFAAyF;QACzF,oFAAoF,CAC3F,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,wDAAyB;IACtD,KAAK,CAAC,aAAa,CAAC,MAAkC;QAC5D,gFAAgF;QAChF,uFAAuF;QACvF,8DAA8D;QAC9D,4BAA4B,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAE7E,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACzD,qFAAqF;QACrF,qFAAqF;QACrF,wFAAwF;QACxF,MAAM,CAAC,cAAc,GAAG,CAAC,CAAC;QAE1B,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAChD,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QACxD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,mBAAU,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAE7D,mFAAmF;QACnF,oEAAoE;QACpE,OAAO,CAAC,GAAG,CAAC,4BAAoB,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACpG,OAAO,EAAE,GAAG,EAAE,CAAC;IACnB,CAAC;IAED;;;;OAIG;IACO,aAAa,CAAC,OAA4C,EAAE,MAAkC;QACpG,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnC,MAAM,MAAM,GAAG,IAAA,mBAAK,EAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,EAAE,CAAgB,CAAC;YAClG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,EAAE;gBACvB,MAAM,OAAO,GAAG,GAA4B,CAAC;gBAC7C,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;oBAChC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;oBAC5F,MAAM,CACF,IAAI,KAAK,CACL,0BAA0B,SAAS,4BAA4B;wBAC3D,wGAAwG,CAC/G,CACJ,CAAC;oBACF,OAAO;gBACX,CAAC;gBACD,MAAM,CAAC,GAAG,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;YACH,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACP,CAAC;IAES,cAAc,CAAC,MAAmB;QACxC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;QACjC,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CAAC,oCAAoC,MAAM,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC;QACtG,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;IAES,WAAW,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAe,EAAE,KAAa,EAAE,QAAQ,GAAG,MAAM;QAC1F,MAAM,IAAI,GAAG,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC;QACpH,OAAO,GAAG,QAAQ,MAAM,IAAI,IAAI,IAAI,GAAG,KAAK,EAAE,CAAC;IACnD,CAAC;CACJ,CAAA;AA9DY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,sBAAU,GAAE;GACA,qBAAqB,CA8DjC"}
|
package/node.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
export * from './lib/node/index';
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
*
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
|
+
'use strict';
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
export * from './mcp-util';
|
|
18
|
+
module.exports = require('./lib/node/index');
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-glsp/server-mcp",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.8.0-next.0+bb0b4e8",
|
|
4
|
+
"description": "Model Context Protocol (MCP) server for the GLSP TypeScript server — runs on Node, browser, and Fetch-API runtimes",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eclipse",
|
|
7
7
|
"graphics",
|
|
@@ -29,16 +29,25 @@
|
|
|
29
29
|
"url": "https://projects.eclipse.org/projects/ecd.glsp"
|
|
30
30
|
}
|
|
31
31
|
],
|
|
32
|
-
"main": "lib/index",
|
|
33
|
-
"
|
|
32
|
+
"main": "lib/node/index",
|
|
33
|
+
"browser": {
|
|
34
|
+
"lib/node/index": "./lib/browser/index"
|
|
35
|
+
},
|
|
36
|
+
"types": "lib/common/index",
|
|
34
37
|
"files": [
|
|
35
38
|
"lib",
|
|
36
|
-
"src"
|
|
39
|
+
"src",
|
|
40
|
+
"node.js",
|
|
41
|
+
"node.d.ts",
|
|
42
|
+
"browser.js",
|
|
43
|
+
"browser.d.ts",
|
|
44
|
+
"common.js",
|
|
45
|
+
"common.d.ts"
|
|
37
46
|
],
|
|
38
47
|
"scripts": {
|
|
39
48
|
"build": "tsc -b",
|
|
40
49
|
"clean": "rimraf lib *.tsbuildinfo coverage .nyc_output",
|
|
41
|
-
"generate:index": "glsp generateIndex src -f -s",
|
|
50
|
+
"generate:index": "glsp generateIndex src/browser src/common src/node -f -s",
|
|
42
51
|
"lint": "eslint --ext .ts,.tsx ./src",
|
|
43
52
|
"test": "mocha --config ../../.mocharc \"./src/**/*.spec.?(ts|tsx)\"",
|
|
44
53
|
"test:ci": "yarn test --reporter mocha-ctrf-json-reporter",
|
|
@@ -46,12 +55,9 @@
|
|
|
46
55
|
"watch": "tsc -w"
|
|
47
56
|
},
|
|
48
57
|
"dependencies": {
|
|
49
|
-
"@eclipse-glsp/server": "2.
|
|
50
|
-
"@
|
|
51
|
-
"
|
|
52
|
-
},
|
|
53
|
-
"devDependencies": {
|
|
54
|
-
"@types/express": "^5.0.6"
|
|
58
|
+
"@eclipse-glsp/server": "2.8.0-next.0+bb0b4e8",
|
|
59
|
+
"@hono/node-server": "^1.19.9",
|
|
60
|
+
"@modelcontextprotocol/sdk": "^1.29.0"
|
|
55
61
|
},
|
|
56
62
|
"peerDependencies": {
|
|
57
63
|
"inversify": "^6.1.3"
|
|
@@ -59,5 +65,5 @@
|
|
|
59
65
|
"publishConfig": {
|
|
60
66
|
"access": "public"
|
|
61
67
|
},
|
|
62
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "bb0b4e86909b0c6ea8ba805a9aba68e4afd2decb"
|
|
63
69
|
}
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
|
-
export * from './
|
|
18
|
-
export * from './
|
|
19
|
-
export * from './
|
|
20
|
-
export * from './
|
|
17
|
+
export * from './modules/browser-mcp-server-module';
|
|
18
|
+
export * from './reexport';
|
|
19
|
+
export * from './server/browser-mcp-request-context';
|
|
20
|
+
export * from './server/mcp-worker-bridge';
|
|
21
|
+
export * from './server/web-mcp-server-launcher';
|
|
@@ -0,0 +1,54 @@
|
|
|
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 { BindingTarget } from '@eclipse-glsp/server';
|
|
18
|
+
import { AbstractMcpServerModule, DEFAULT_MCP_OPTIONS } from '../../common/modules/abstract-mcp-server-module';
|
|
19
|
+
import { AbstractMcpServerLauncher } from '../../common/server/abstract-mcp-server-launcher';
|
|
20
|
+
import { McpServerDefaults } from '../../common/server/mcp-options';
|
|
21
|
+
import { McpRequestContext } from '../../common/server/mcp-request-context';
|
|
22
|
+
import { BrowserMcpRequestContext } from '../server/browser-mcp-request-context';
|
|
23
|
+
import { WebMcpServerLauncher } from '../server/web-mcp-server-launcher';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Default {@link AbstractMcpServerModule} entry point for browser/web hosts (Bun, Deno, Cloudflare
|
|
27
|
+
* Worker, Service Worker, in-page Worker). Ships GLSP-default option values (see
|
|
28
|
+
* {@link BrowserMcpServerModule.DEFAULT_OPTIONS}) on top of the abstract module's hook defaults,
|
|
29
|
+
* and binds the web {@link WebMcpServerLauncher} + {@link BrowserMcpRequestContext}. Adopter-provided
|
|
30
|
+
* overrides via the constructor merge on top.
|
|
31
|
+
*
|
|
32
|
+
* Node-only deploy-side fields (`host`, `allowedHosts`, `allowedOrigins`, `acknowledgedNoAuth`)
|
|
33
|
+
* are intentionally omitted from defaults — adopters set these for their deployment, or run their
|
|
34
|
+
* own auth middleware around {@link AbstractMcpServerLauncher.getRequestHandler}.
|
|
35
|
+
*
|
|
36
|
+
* @experimental The MCP integration is under active development. Option names, schema shapes,
|
|
37
|
+
* and handler contracts MAY change in minor releases until the feature graduates from
|
|
38
|
+
* experimental status.
|
|
39
|
+
*/
|
|
40
|
+
export class BrowserMcpServerModule extends AbstractMcpServerModule {
|
|
41
|
+
static readonly DEFAULT_OPTIONS: McpServerDefaults = { ...DEFAULT_MCP_OPTIONS };
|
|
42
|
+
|
|
43
|
+
constructor(overrides: McpServerDefaults = {}) {
|
|
44
|
+
super({ ...BrowserMcpServerModule.DEFAULT_OPTIONS, ...overrides });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
protected override bindMcpServerLauncher(): BindingTarget<AbstractMcpServerLauncher> {
|
|
48
|
+
return WebMcpServerLauncher;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected override bindMcpRequestContext(): BindingTarget<McpRequestContext> {
|
|
52
|
+
return BrowserMcpRequestContext;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
export * from '../common';
|
|
@@ -0,0 +1,59 @@
|
|
|
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 { injectable } from 'inversify';
|
|
18
|
+
import { McpRequestContext, McpRequestExtra } from '../../common/server/mcp-request-context';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Browser-compatible {@link McpRequestContext} that holds one request context at a time.
|
|
22
|
+
* Hosts must serialise dispatches so they don't overwrite each other (e.g. via {@link McpWorkerBridge}).
|
|
23
|
+
*/
|
|
24
|
+
@injectable()
|
|
25
|
+
export class BrowserMcpRequestContext implements McpRequestContext {
|
|
26
|
+
protected current: McpRequestExtra | undefined;
|
|
27
|
+
protected concurrencyWarned = false;
|
|
28
|
+
|
|
29
|
+
run<R>(extra: McpRequestExtra, callback: () => R): R {
|
|
30
|
+
// Warn once if an adopter forgot to serialise dispatches — silent context corruption would be hard to debug.
|
|
31
|
+
if (this.current !== undefined && !this.concurrencyWarned) {
|
|
32
|
+
this.concurrencyWarned = true;
|
|
33
|
+
console.warn(
|
|
34
|
+
'BrowserMcpRequestContext: concurrent run() detected — request contexts will overwrite each other. ' +
|
|
35
|
+
'Serialise MCP dispatches (e.g. via McpWorkerBridge or an adopter-side queue around launcher.handleRequest).'
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
const prior = this.current;
|
|
39
|
+
this.current = extra;
|
|
40
|
+
let result: R;
|
|
41
|
+
try {
|
|
42
|
+
result = callback();
|
|
43
|
+
} catch (error) {
|
|
44
|
+
this.current = prior;
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
if (result instanceof Promise) {
|
|
48
|
+
return result.finally(() => {
|
|
49
|
+
this.current = prior;
|
|
50
|
+
}) as unknown as R;
|
|
51
|
+
}
|
|
52
|
+
this.current = prior;
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getStore(): McpRequestExtra | undefined {
|
|
57
|
+
return this.current;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
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 { Disposable } from '@eclipse-glsp/server';
|
|
18
|
+
import { AbstractMcpServerLauncher } from '../../common/server/abstract-mcp-server-launcher';
|
|
19
|
+
import { McpServerDefaults } from '../../common/server/mcp-options';
|
|
20
|
+
import { BrowserMcpServerModule } from '../modules/browser-mcp-server-module';
|
|
21
|
+
|
|
22
|
+
export const MCP_REQUEST_MESSAGE_TYPE = 'mcp-request';
|
|
23
|
+
export const MCP_RESPONSE_MESSAGE_TYPE = 'mcp-response';
|
|
24
|
+
export const MCP_INIT_PORT_MESSAGE_TYPE = 'mcp-init-port';
|
|
25
|
+
|
|
26
|
+
export interface McpRequestMessage {
|
|
27
|
+
type: typeof MCP_REQUEST_MESSAGE_TYPE;
|
|
28
|
+
id: string;
|
|
29
|
+
url: string;
|
|
30
|
+
method: string;
|
|
31
|
+
headers: Record<string, string>;
|
|
32
|
+
body?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface McpResponseMessage {
|
|
36
|
+
type: typeof MCP_RESPONSE_MESSAGE_TYPE;
|
|
37
|
+
id: string;
|
|
38
|
+
status: number;
|
|
39
|
+
statusText: string;
|
|
40
|
+
headers: Record<string, string>;
|
|
41
|
+
/** `ReadableStream` on Chromium (streams SSE); buffered `ArrayBuffer` on browsers without transferable streams. */
|
|
42
|
+
body: ReadableStream<Uint8Array> | ArrayBuffer | null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Carries the SW↔Worker `MessagePort` transfer that wires MCP traffic over a dedicated channel. */
|
|
46
|
+
export interface McpInitPortMessage {
|
|
47
|
+
type: typeof MCP_INIT_PORT_MESSAGE_TYPE;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function isMcpRequestMessage(value: unknown): value is McpRequestMessage {
|
|
51
|
+
return Object(value) === value && (value as { type?: unknown }).type === MCP_REQUEST_MESSAGE_TYPE;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function isMcpInitPortMessage(value: unknown): value is McpInitPortMessage {
|
|
55
|
+
return Object(value) === value && (value as { type?: unknown }).type === MCP_INIT_PORT_MESSAGE_TYPE;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Probes whether the current realm can transfer `ReadableStream` via `postMessage` (Chromium yes; Firefox / Safari no). */
|
|
59
|
+
export function canTransferReadableStream(): boolean {
|
|
60
|
+
try {
|
|
61
|
+
const probe = new ReadableStream();
|
|
62
|
+
structuredClone(probe, { transfer: [probe] });
|
|
63
|
+
return true;
|
|
64
|
+
} catch {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Minimal Worker scope contract — defined locally so the package compiles without the `webworker` lib. */
|
|
70
|
+
export interface McpBridgeScope {
|
|
71
|
+
addEventListener(type: 'message', listener: (event: MessageEvent) => void): void;
|
|
72
|
+
removeEventListener(type: 'message', listener: (event: MessageEvent) => void): void;
|
|
73
|
+
postMessage(message: unknown, transfer?: Transferable[]): void;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Bridges `postMessage` traffic to an {@link AbstractMcpServerLauncher} for browser / Web Worker
|
|
78
|
+
* adopters that proxy MCP requests via Service-Worker → Web-Worker plumbing.
|
|
79
|
+
* See `ARCHITECTURE.md` (Portable handler) for the message protocol and queueing semantics.
|
|
80
|
+
*/
|
|
81
|
+
export class McpWorkerBridge implements Disposable {
|
|
82
|
+
protected resolveLauncher!: (launcher: AbstractMcpServerLauncher) => void;
|
|
83
|
+
protected readonly launcherReady: Promise<AbstractMcpServerLauncher>;
|
|
84
|
+
protected readonly listener = (event: MessageEvent): void => this.onMessage(event);
|
|
85
|
+
/** Serialise dispatches — `BrowserMcpRequestContext` is a single-slot store, not concurrency-safe. */
|
|
86
|
+
protected dispatchChain: Promise<void> = Promise.resolve();
|
|
87
|
+
protected readonly streamTransferable: boolean = canTransferReadableStream();
|
|
88
|
+
protected bufferingWarned = false;
|
|
89
|
+
|
|
90
|
+
constructor(protected readonly scope: McpBridgeScope = self as unknown as McpBridgeScope) {
|
|
91
|
+
this.launcherReady = new Promise<AbstractMcpServerLauncher>(resolve => {
|
|
92
|
+
this.resolveLauncher = resolve;
|
|
93
|
+
});
|
|
94
|
+
this.scope.addEventListener('message', this.listener);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
dispose(): void {
|
|
98
|
+
this.scope.removeEventListener('message', this.listener);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Returns a {@link BrowserMcpServerModule} that registers its launcher with this bridge on DI activation. */
|
|
102
|
+
createServerModule(overrides?: McpServerDefaults): BrowserMcpServerModule {
|
|
103
|
+
const bridge = this;
|
|
104
|
+
class BridgedBrowserMcpServerModule extends BrowserMcpServerModule {
|
|
105
|
+
protected override onMcpServerLauncherActivated(launcher: AbstractMcpServerLauncher): void {
|
|
106
|
+
bridge.bindLauncher(launcher);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return new BridgedBrowserMcpServerModule(overrides);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** First call binds; subsequent calls are no-ops. */
|
|
113
|
+
bindLauncher(launcher: AbstractMcpServerLauncher): void {
|
|
114
|
+
this.resolveLauncher(launcher);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
protected onMessage(event: MessageEvent): void {
|
|
118
|
+
const data: unknown = event.data;
|
|
119
|
+
if (isMcpRequestMessage(data)) {
|
|
120
|
+
this.enqueueDispatch(data, event.ports[0]);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (isMcpInitPortMessage(data)) {
|
|
124
|
+
const port = event.ports[0];
|
|
125
|
+
if (!port) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
port.onmessage = portEvent => {
|
|
129
|
+
const portData: unknown = portEvent.data;
|
|
130
|
+
if (isMcpRequestMessage(portData)) {
|
|
131
|
+
this.enqueueDispatch(portData, port);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
port.start();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
protected enqueueDispatch(request: McpRequestMessage, port: MessagePort | undefined): void {
|
|
139
|
+
this.dispatchChain = this.dispatchChain
|
|
140
|
+
.then(() => this.dispatch(request, port))
|
|
141
|
+
.catch(err => console.error('MCP worker bridge failed:', err));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
protected async dispatch(request: McpRequestMessage, port: MessagePort | undefined): Promise<void> {
|
|
145
|
+
try {
|
|
146
|
+
const launcher = await this.launcherReady;
|
|
147
|
+
const init: RequestInit = { method: request.method, headers: request.headers };
|
|
148
|
+
if (typeof request.body === 'string') {
|
|
149
|
+
init.body = request.body;
|
|
150
|
+
}
|
|
151
|
+
const response = await launcher.handleRequest(new Request(request.url, init));
|
|
152
|
+
const headers: Record<string, string> = {};
|
|
153
|
+
response.headers.forEach((value, key) => {
|
|
154
|
+
headers[key] = value;
|
|
155
|
+
});
|
|
156
|
+
this.reply(port, {
|
|
157
|
+
type: MCP_RESPONSE_MESSAGE_TYPE,
|
|
158
|
+
id: request.id,
|
|
159
|
+
status: response.status,
|
|
160
|
+
statusText: response.statusText,
|
|
161
|
+
headers,
|
|
162
|
+
body: await this.encodeBody(response)
|
|
163
|
+
});
|
|
164
|
+
} catch (err: unknown) {
|
|
165
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
166
|
+
this.reply(port, {
|
|
167
|
+
type: MCP_RESPONSE_MESSAGE_TYPE,
|
|
168
|
+
id: request.id,
|
|
169
|
+
status: 500,
|
|
170
|
+
statusText: 'Internal Server Error',
|
|
171
|
+
headers: { 'content-type': 'text/plain' },
|
|
172
|
+
body: await this.encodeBody(new Response(`MCP worker bridge error: ${message}`))
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Stream on Chromium; buffer to `ArrayBuffer` (still transferable) on browsers without transferable streams. */
|
|
178
|
+
protected async encodeBody(response: Response): Promise<ReadableStream<Uint8Array> | ArrayBuffer | null> {
|
|
179
|
+
if (this.streamTransferable) {
|
|
180
|
+
return response.body;
|
|
181
|
+
}
|
|
182
|
+
if (!this.bufferingWarned) {
|
|
183
|
+
this.bufferingWarned = true;
|
|
184
|
+
console.warn(
|
|
185
|
+
'McpWorkerBridge: ReadableStream is not transferable in this browser — buffering MCP response bodies. ' +
|
|
186
|
+
'Chunked / SSE streaming will deliver as a single chunk; non-streaming MCP calls are unaffected.'
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
return response.arrayBuffer();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
protected reply(port: MessagePort | undefined, message: McpResponseMessage): void {
|
|
193
|
+
const transfer: Transferable[] = message.body ? [message.body] : [];
|
|
194
|
+
if (port) {
|
|
195
|
+
port.postMessage(message, transfer);
|
|
196
|
+
} else {
|
|
197
|
+
this.scope.postMessage(message, transfer);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|