@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.
Files changed (303) hide show
  1. package/LICENSE +642 -0
  2. package/README.md +57 -0
  3. package/lib/index.d.ts +23 -0
  4. package/lib/index.d.ts.map +1 -0
  5. package/lib/index.js +41 -0
  6. package/lib/index.js.map +1 -0
  7. package/lib/prompts/handlers/describe-diagram-mcp-prompt-handler.d.ts +43 -0
  8. package/lib/prompts/handlers/describe-diagram-mcp-prompt-handler.d.ts.map +1 -0
  9. package/lib/prompts/handlers/describe-diagram-mcp-prompt-handler.js +96 -0
  10. package/lib/prompts/handlers/describe-diagram-mcp-prompt-handler.js.map +1 -0
  11. package/lib/prompts/handlers/suggest-improvements-mcp-prompt-handler.d.ts +43 -0
  12. package/lib/prompts/handlers/suggest-improvements-mcp-prompt-handler.d.ts.map +1 -0
  13. package/lib/prompts/handlers/suggest-improvements-mcp-prompt-handler.js +95 -0
  14. package/lib/prompts/handlers/suggest-improvements-mcp-prompt-handler.js.map +1 -0
  15. package/lib/prompts/index.d.ts +18 -0
  16. package/lib/prompts/index.d.ts.map +1 -0
  17. package/lib/prompts/index.js +34 -0
  18. package/lib/prompts/index.js.map +1 -0
  19. package/lib/resources/handlers/diagram-png-mcp-resource-handler.d.ts +81 -0
  20. package/lib/resources/handlers/diagram-png-mcp-resource-handler.d.ts.map +1 -0
  21. package/lib/resources/handlers/diagram-png-mcp-resource-handler.js +174 -0
  22. package/lib/resources/handlers/diagram-png-mcp-resource-handler.js.map +1 -0
  23. package/lib/resources/handlers/diagram-svg-mcp-resource-handler.d.ts +52 -0
  24. package/lib/resources/handlers/diagram-svg-mcp-resource-handler.d.ts.map +1 -0
  25. package/lib/resources/handlers/diagram-svg-mcp-resource-handler.js +96 -0
  26. package/lib/resources/handlers/diagram-svg-mcp-resource-handler.js.map +1 -0
  27. package/lib/resources/index.d.ts +20 -0
  28. package/lib/resources/index.d.ts.map +1 -0
  29. package/lib/resources/index.js +36 -0
  30. package/lib/resources/index.js.map +1 -0
  31. package/lib/resources/services/element-types-provider.d.ts +65 -0
  32. package/lib/resources/services/element-types-provider.d.ts.map +1 -0
  33. package/lib/resources/services/element-types-provider.js +81 -0
  34. package/lib/resources/services/element-types-provider.js.map +1 -0
  35. package/lib/resources/services/mcp-model-serializer.d.ts +78 -0
  36. package/lib/resources/services/mcp-model-serializer.d.ts.map +1 -0
  37. package/lib/resources/services/mcp-model-serializer.js +188 -0
  38. package/lib/resources/services/mcp-model-serializer.js.map +1 -0
  39. package/lib/server/glsp-mcp-server.d.ts +82 -0
  40. package/lib/server/glsp-mcp-server.d.ts.map +1 -0
  41. package/lib/server/glsp-mcp-server.js +140 -0
  42. package/lib/server/glsp-mcp-server.js.map +1 -0
  43. package/lib/server/index.d.ts +37 -0
  44. package/lib/server/index.d.ts.map +1 -0
  45. package/lib/server/index.js +57 -0
  46. package/lib/server/index.js.map +1 -0
  47. package/lib/server/lru-event-store.d.ts +53 -0
  48. package/lib/server/lru-event-store.d.ts.map +1 -0
  49. package/lib/server/lru-event-store.js +100 -0
  50. package/lib/server/lru-event-store.js.map +1 -0
  51. package/lib/server/mcp-diagram-handler-dispatcher.d.ts +144 -0
  52. package/lib/server/mcp-diagram-handler-dispatcher.d.ts.map +1 -0
  53. package/lib/server/mcp-diagram-handler-dispatcher.js +382 -0
  54. package/lib/server/mcp-diagram-handler-dispatcher.js.map +1 -0
  55. package/lib/server/mcp-diagram-module.d.ts +123 -0
  56. package/lib/server/mcp-diagram-module.d.ts.map +1 -0
  57. package/lib/server/mcp-diagram-module.js +186 -0
  58. package/lib/server/mcp-diagram-module.js.map +1 -0
  59. package/lib/server/mcp-diagram-prompt-handler-registry.d.ts +33 -0
  60. package/lib/server/mcp-diagram-prompt-handler-registry.d.ts.map +1 -0
  61. package/lib/server/mcp-diagram-prompt-handler-registry.js +76 -0
  62. package/lib/server/mcp-diagram-prompt-handler-registry.js.map +1 -0
  63. package/lib/server/mcp-diagram-resource-handler-registry.d.ts +35 -0
  64. package/lib/server/mcp-diagram-resource-handler-registry.d.ts.map +1 -0
  65. package/lib/server/mcp-diagram-resource-handler-registry.js +94 -0
  66. package/lib/server/mcp-diagram-resource-handler-registry.js.map +1 -0
  67. package/lib/server/mcp-diagram-tool-handler-registry.d.ts +57 -0
  68. package/lib/server/mcp-diagram-tool-handler-registry.d.ts.map +1 -0
  69. package/lib/server/mcp-diagram-tool-handler-registry.js +111 -0
  70. package/lib/server/mcp-diagram-tool-handler-registry.js.map +1 -0
  71. package/lib/server/mcp-handler-shared.d.ts +142 -0
  72. package/lib/server/mcp-handler-shared.d.ts.map +1 -0
  73. package/lib/server/mcp-handler-shared.js +199 -0
  74. package/lib/server/mcp-handler-shared.js.map +1 -0
  75. package/lib/server/mcp-http-transport.d.ts +93 -0
  76. package/lib/server/mcp-http-transport.d.ts.map +1 -0
  77. package/lib/server/mcp-http-transport.js +350 -0
  78. package/lib/server/mcp-http-transport.js.map +1 -0
  79. package/lib/server/mcp-id-alias-service.d.ts +70 -0
  80. package/lib/server/mcp-id-alias-service.d.ts.map +1 -0
  81. package/lib/server/mcp-id-alias-service.js +85 -0
  82. package/lib/server/mcp-id-alias-service.js.map +1 -0
  83. package/lib/server/mcp-input-schemas.d.ts +73 -0
  84. package/lib/server/mcp-input-schemas.d.ts.map +1 -0
  85. package/lib/server/mcp-input-schemas.js +67 -0
  86. package/lib/server/mcp-input-schemas.js.map +1 -0
  87. package/lib/server/mcp-label-provider.d.ts +45 -0
  88. package/lib/server/mcp-label-provider.d.ts.map +1 -0
  89. package/lib/server/mcp-label-provider.js +42 -0
  90. package/lib/server/mcp-label-provider.js.map +1 -0
  91. package/lib/server/mcp-log-level-registry.d.ts +54 -0
  92. package/lib/server/mcp-log-level-registry.d.ts.map +1 -0
  93. package/lib/server/mcp-log-level-registry.js +80 -0
  94. package/lib/server/mcp-log-level-registry.js.map +1 -0
  95. package/lib/server/mcp-logger.d.ts +59 -0
  96. package/lib/server/mcp-logger.d.ts.map +1 -0
  97. package/lib/server/mcp-logger.js +104 -0
  98. package/lib/server/mcp-logger.js.map +1 -0
  99. package/lib/server/mcp-mime-types.d.ts +28 -0
  100. package/lib/server/mcp-mime-types.d.ts.map +1 -0
  101. package/lib/server/mcp-mime-types.js +18 -0
  102. package/lib/server/mcp-mime-types.js.map +1 -0
  103. package/lib/server/mcp-options.d.ts +39 -0
  104. package/lib/server/mcp-options.d.ts.map +1 -0
  105. package/lib/server/mcp-options.js +53 -0
  106. package/lib/server/mcp-options.js.map +1 -0
  107. package/lib/server/mcp-progress-reporter.d.ts +48 -0
  108. package/lib/server/mcp-progress-reporter.d.ts.map +1 -0
  109. package/lib/server/mcp-progress-reporter.js +66 -0
  110. package/lib/server/mcp-progress-reporter.js.map +1 -0
  111. package/lib/server/mcp-prompt-handler.d.ts +120 -0
  112. package/lib/server/mcp-prompt-handler.d.ts.map +1 -0
  113. package/lib/server/mcp-prompt-handler.js +131 -0
  114. package/lib/server/mcp-prompt-handler.js.map +1 -0
  115. package/lib/server/mcp-request-context.d.ts +37 -0
  116. package/lib/server/mcp-request-context.d.ts.map +1 -0
  117. package/lib/server/mcp-request-context.js +37 -0
  118. package/lib/server/mcp-request-context.js.map +1 -0
  119. package/lib/server/mcp-resource-handler.d.ts +212 -0
  120. package/lib/server/mcp-resource-handler.d.ts.map +1 -0
  121. package/lib/server/mcp-resource-handler.js +298 -0
  122. package/lib/server/mcp-resource-handler.js.map +1 -0
  123. package/lib/server/mcp-server-launcher.d.ts +143 -0
  124. package/lib/server/mcp-server-launcher.d.ts.map +1 -0
  125. package/lib/server/mcp-server-launcher.js +355 -0
  126. package/lib/server/mcp-server-launcher.js.map +1 -0
  127. package/lib/server/mcp-server-module.d.ts +143 -0
  128. package/lib/server/mcp-server-module.d.ts.map +1 -0
  129. package/lib/server/mcp-server-module.js +249 -0
  130. package/lib/server/mcp-server-module.js.map +1 -0
  131. package/lib/server/mcp-session.d.ts +44 -0
  132. package/lib/server/mcp-session.d.ts.map +1 -0
  133. package/lib/server/mcp-session.js +18 -0
  134. package/lib/server/mcp-session.js.map +1 -0
  135. package/lib/server/mcp-tool-handler.d.ts +259 -0
  136. package/lib/server/mcp-tool-handler.d.ts.map +1 -0
  137. package/lib/server/mcp-tool-handler.js +355 -0
  138. package/lib/server/mcp-tool-handler.js.map +1 -0
  139. package/lib/tools/handlers/count-elements-mcp-tool-handler.d.ts +46 -0
  140. package/lib/tools/handlers/count-elements-mcp-tool-handler.d.ts.map +1 -0
  141. package/lib/tools/handlers/count-elements-mcp-tool-handler.js +76 -0
  142. package/lib/tools/handlers/count-elements-mcp-tool-handler.js.map +1 -0
  143. package/lib/tools/handlers/create-edges-mcp-tool-handler.d.ts +112 -0
  144. package/lib/tools/handlers/create-edges-mcp-tool-handler.d.ts.map +1 -0
  145. package/lib/tools/handlers/create-edges-mcp-tool-handler.js +190 -0
  146. package/lib/tools/handlers/create-edges-mcp-tool-handler.js.map +1 -0
  147. package/lib/tools/handlers/create-nodes-mcp-tool-handler.d.ts +81 -0
  148. package/lib/tools/handlers/create-nodes-mcp-tool-handler.d.ts.map +1 -0
  149. package/lib/tools/handlers/create-nodes-mcp-tool-handler.js +123 -0
  150. package/lib/tools/handlers/create-nodes-mcp-tool-handler.js.map +1 -0
  151. package/lib/tools/handlers/delete-elements-mcp-tool-handler.d.ts +52 -0
  152. package/lib/tools/handlers/delete-elements-mcp-tool-handler.d.ts.map +1 -0
  153. package/lib/tools/handlers/delete-elements-mcp-tool-handler.js +73 -0
  154. package/lib/tools/handlers/delete-elements-mcp-tool-handler.js.map +1 -0
  155. package/lib/tools/handlers/diagram-model-mcp-tool-handler.d.ts +59 -0
  156. package/lib/tools/handlers/diagram-model-mcp-tool-handler.d.ts.map +1 -0
  157. package/lib/tools/handlers/diagram-model-mcp-tool-handler.js +78 -0
  158. package/lib/tools/handlers/diagram-model-mcp-tool-handler.js.map +1 -0
  159. package/lib/tools/handlers/element-types-mcp-tool-handler.d.ts +97 -0
  160. package/lib/tools/handlers/element-types-mcp-tool-handler.d.ts.map +1 -0
  161. package/lib/tools/handlers/element-types-mcp-tool-handler.js +155 -0
  162. package/lib/tools/handlers/element-types-mcp-tool-handler.js.map +1 -0
  163. package/lib/tools/handlers/get-selection-mcp-tool-handler.d.ts +43 -0
  164. package/lib/tools/handlers/get-selection-mcp-tool-handler.d.ts.map +1 -0
  165. package/lib/tools/handlers/get-selection-mcp-tool-handler.js +68 -0
  166. package/lib/tools/handlers/get-selection-mcp-tool-handler.js.map +1 -0
  167. package/lib/tools/handlers/layout-mcp-tool-handler.d.ts +43 -0
  168. package/lib/tools/handlers/layout-mcp-tool-handler.d.ts.map +1 -0
  169. package/lib/tools/handlers/layout-mcp-tool-handler.js +71 -0
  170. package/lib/tools/handlers/layout-mcp-tool-handler.js.map +1 -0
  171. package/lib/tools/handlers/modify-edges-mcp-tool-handler.d.ts +78 -0
  172. package/lib/tools/handlers/modify-edges-mcp-tool-handler.d.ts.map +1 -0
  173. package/lib/tools/handlers/modify-edges-mcp-tool-handler.js +136 -0
  174. package/lib/tools/handlers/modify-edges-mcp-tool-handler.js.map +1 -0
  175. package/lib/tools/handlers/modify-nodes-mcp-tool-handler.d.ts +92 -0
  176. package/lib/tools/handlers/modify-nodes-mcp-tool-handler.d.ts.map +1 -0
  177. package/lib/tools/handlers/modify-nodes-mcp-tool-handler.js +125 -0
  178. package/lib/tools/handlers/modify-nodes-mcp-tool-handler.js.map +1 -0
  179. package/lib/tools/handlers/query-elements-mcp-tool-handler.d.ts +102 -0
  180. package/lib/tools/handlers/query-elements-mcp-tool-handler.d.ts.map +1 -0
  181. package/lib/tools/handlers/query-elements-mcp-tool-handler.js +158 -0
  182. package/lib/tools/handlers/query-elements-mcp-tool-handler.js.map +1 -0
  183. package/lib/tools/handlers/redo-mcp-tool-handler.d.ts +45 -0
  184. package/lib/tools/handlers/redo-mcp-tool-handler.d.ts.map +1 -0
  185. package/lib/tools/handlers/redo-mcp-tool-handler.js +73 -0
  186. package/lib/tools/handlers/redo-mcp-tool-handler.js.map +1 -0
  187. package/lib/tools/handlers/save-model-mcp-tool-handler.d.ts +55 -0
  188. package/lib/tools/handlers/save-model-mcp-tool-handler.d.ts.map +1 -0
  189. package/lib/tools/handlers/save-model-mcp-tool-handler.js +91 -0
  190. package/lib/tools/handlers/save-model-mcp-tool-handler.js.map +1 -0
  191. package/lib/tools/handlers/session-info-mcp-tool-handler.d.ts +65 -0
  192. package/lib/tools/handlers/session-info-mcp-tool-handler.d.ts.map +1 -0
  193. package/lib/tools/handlers/session-info-mcp-tool-handler.js +108 -0
  194. package/lib/tools/handlers/session-info-mcp-tool-handler.js.map +1 -0
  195. package/lib/tools/handlers/set-selection-mcp-tool-handler.d.ts +60 -0
  196. package/lib/tools/handlers/set-selection-mcp-tool-handler.d.ts.map +1 -0
  197. package/lib/tools/handlers/set-selection-mcp-tool-handler.js +103 -0
  198. package/lib/tools/handlers/set-selection-mcp-tool-handler.js.map +1 -0
  199. package/lib/tools/handlers/set-view-mcp-tool-handler.d.ts +110 -0
  200. package/lib/tools/handlers/set-view-mcp-tool-handler.d.ts.map +1 -0
  201. package/lib/tools/handlers/set-view-mcp-tool-handler.js +142 -0
  202. package/lib/tools/handlers/set-view-mcp-tool-handler.js.map +1 -0
  203. package/lib/tools/handlers/undo-mcp-tool-handler.d.ts +45 -0
  204. package/lib/tools/handlers/undo-mcp-tool-handler.d.ts.map +1 -0
  205. package/lib/tools/handlers/undo-mcp-tool-handler.js +74 -0
  206. package/lib/tools/handlers/undo-mcp-tool-handler.js.map +1 -0
  207. package/lib/tools/handlers/validate-diagram-mcp-tool-handler.d.ts +66 -0
  208. package/lib/tools/handlers/validate-diagram-mcp-tool-handler.d.ts.map +1 -0
  209. package/lib/tools/handlers/validate-diagram-mcp-tool-handler.js +0 -0
  210. package/lib/tools/handlers/validate-diagram-mcp-tool-handler.js.map +1 -0
  211. package/lib/tools/index.d.ts +34 -0
  212. package/lib/tools/index.d.ts.map +1 -0
  213. package/lib/tools/index.js +50 -0
  214. package/lib/tools/index.js.map +1 -0
  215. package/lib/util/index.d.ts +18 -0
  216. package/lib/util/index.d.ts.map +1 -0
  217. package/lib/util/index.js +34 -0
  218. package/lib/util/index.js.map +1 -0
  219. package/lib/util/markdown-util.d.ts +20 -0
  220. package/lib/util/markdown-util.d.ts.map +1 -0
  221. package/lib/util/markdown-util.js +45 -0
  222. package/lib/util/markdown-util.js.map +1 -0
  223. package/lib/util/mcp-util.d.ts +22 -0
  224. package/lib/util/mcp-util.d.ts.map +1 -0
  225. package/lib/util/mcp-util.js +29 -0
  226. package/lib/util/mcp-util.js.map +1 -0
  227. package/package.json +63 -0
  228. package/src/index.ts +24 -0
  229. package/src/prompts/handlers/describe-diagram-mcp-prompt-handler.ts +89 -0
  230. package/src/prompts/handlers/suggest-improvements-mcp-prompt-handler.ts +86 -0
  231. package/src/prompts/index.ts +18 -0
  232. package/src/resources/handlers/diagram-png-mcp-resource-handler.ts +181 -0
  233. package/src/resources/handlers/diagram-svg-mcp-resource-handler.ts +89 -0
  234. package/src/resources/index.ts +20 -0
  235. package/src/resources/services/element-types-provider.ts +105 -0
  236. package/src/resources/services/mcp-model-serializer.ts +211 -0
  237. package/src/server/glsp-mcp-server.spec.ts +73 -0
  238. package/src/server/glsp-mcp-server.ts +196 -0
  239. package/src/server/index.ts +42 -0
  240. package/src/server/lru-event-store.spec.ts +121 -0
  241. package/src/server/lru-event-store.ts +112 -0
  242. package/src/server/mcp-diagram-handler-dispatcher.spec.ts +231 -0
  243. package/src/server/mcp-diagram-handler-dispatcher.ts +459 -0
  244. package/src/server/mcp-diagram-module.ts +248 -0
  245. package/src/server/mcp-diagram-prompt-handler-registry.ts +59 -0
  246. package/src/server/mcp-diagram-resource-handler-registry.ts +73 -0
  247. package/src/server/mcp-diagram-tool-handler-registry.ts +97 -0
  248. package/src/server/mcp-handler-shared.spec.ts +53 -0
  249. package/src/server/mcp-handler-shared.ts +247 -0
  250. package/src/server/mcp-http-transport-e2e.spec.ts +151 -0
  251. package/src/server/mcp-http-transport.spec.ts +385 -0
  252. package/src/server/mcp-http-transport.ts +368 -0
  253. package/src/server/mcp-id-alias-service.spec.ts +106 -0
  254. package/src/server/mcp-id-alias-service.ts +104 -0
  255. package/src/server/mcp-input-schemas.ts +82 -0
  256. package/src/server/mcp-label-provider.ts +52 -0
  257. package/src/server/mcp-log-level-registry.spec.ts +75 -0
  258. package/src/server/mcp-log-level-registry.ts +90 -0
  259. package/src/server/mcp-logger.spec.ts +227 -0
  260. package/src/server/mcp-logger.ts +91 -0
  261. package/src/server/mcp-mime-types.ts +31 -0
  262. package/src/server/mcp-options.ts +43 -0
  263. package/src/server/mcp-progress-reporter.spec.ts +93 -0
  264. package/src/server/mcp-progress-reporter.ts +67 -0
  265. package/src/server/mcp-prompt-handler.ts +157 -0
  266. package/src/server/mcp-request-context.ts +39 -0
  267. package/src/server/mcp-resource-handler.ts +389 -0
  268. package/src/server/mcp-server-launcher.spec.ts +173 -0
  269. package/src/server/mcp-server-launcher.ts +369 -0
  270. package/src/server/mcp-server-module.ts +287 -0
  271. package/src/server/mcp-session.ts +45 -0
  272. package/src/server/mcp-tool-handler.spec.ts +182 -0
  273. package/src/server/mcp-tool-handler.ts +431 -0
  274. package/src/server/raw-http.spec.ts +59 -0
  275. package/src/tools/handlers/count-elements-mcp-tool-handler.spec.ts +99 -0
  276. package/src/tools/handlers/count-elements-mcp-tool-handler.ts +66 -0
  277. package/src/tools/handlers/create-edges-mcp-tool-handler.spec.ts +196 -0
  278. package/src/tools/handlers/create-edges-mcp-tool-handler.ts +205 -0
  279. package/src/tools/handlers/create-nodes-mcp-tool-handler.spec.ts +197 -0
  280. package/src/tools/handlers/create-nodes-mcp-tool-handler.ts +131 -0
  281. package/src/tools/handlers/delete-elements-mcp-tool-handler.ts +73 -0
  282. package/src/tools/handlers/diagram-model-mcp-tool-handler.ts +66 -0
  283. package/src/tools/handlers/element-types-mcp-tool-handler.ts +151 -0
  284. package/src/tools/handlers/get-selection-mcp-tool-handler.ts +54 -0
  285. package/src/tools/handlers/layout-mcp-tool-handler.ts +56 -0
  286. package/src/tools/handlers/modify-edges-mcp-tool-handler.ts +148 -0
  287. package/src/tools/handlers/modify-nodes-mcp-tool-handler.ts +140 -0
  288. package/src/tools/handlers/query-elements-mcp-tool-handler.spec.ts +210 -0
  289. package/src/tools/handlers/query-elements-mcp-tool-handler.ts +161 -0
  290. package/src/tools/handlers/redo-mcp-tool-handler.ts +62 -0
  291. package/src/tools/handlers/save-model-mcp-tool-handler.ts +71 -0
  292. package/src/tools/handlers/session-info-mcp-tool-handler.spec.ts +152 -0
  293. package/src/tools/handlers/session-info-mcp-tool-handler.ts +97 -0
  294. package/src/tools/handlers/set-selection-mcp-tool-handler.spec.ts +118 -0
  295. package/src/tools/handlers/set-selection-mcp-tool-handler.ts +90 -0
  296. package/src/tools/handlers/set-view-mcp-tool-handler.ts +162 -0
  297. package/src/tools/handlers/undo-mcp-tool-handler.ts +61 -0
  298. package/src/tools/handlers/validate-diagram-mcp-tool-handler.ts +0 -0
  299. package/src/tools/index.ts +34 -0
  300. package/src/tools/tool-annotations.spec.ts +141 -0
  301. package/src/util/index.ts +18 -0
  302. package/src/util/markdown-util.ts +44 -0
  303. package/src/util/mcp-util.ts +25 -0
@@ -0,0 +1,350 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
27
+ return function (target, key) { decorator(target, key, paramIndex); }
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.McpHttpTransport = void 0;
31
+ const server_1 = require("@eclipse-glsp/server");
32
+ const express_js_1 = require("@modelcontextprotocol/sdk/server/express.js");
33
+ const streamableHttp_js_1 = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
34
+ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
35
+ const inversify_1 = require("inversify");
36
+ const node_crypto_1 = require("node:crypto");
37
+ const lru_event_store_1 = require("./lru-event-store");
38
+ const mcp_options_1 = require("./mcp-options");
39
+ let McpHttpTransport = class McpHttpTransport {
40
+ constructor(logger) {
41
+ this.logger = logger;
42
+ this._addressInfo = new server_1.Deferred();
43
+ this.sessions = new Map();
44
+ this.onSessionInitializedEmitter = new server_1.Emitter();
45
+ this.onSessionInitialized = this.onSessionInitializedEmitter.event;
46
+ this.onSessionClosedEmitter = new server_1.Emitter();
47
+ this.onSessionClosed = this.onSessionClosedEmitter.event;
48
+ }
49
+ get app() {
50
+ return this._app;
51
+ }
52
+ get server() {
53
+ return this._server;
54
+ }
55
+ getAddress() {
56
+ return this._addressInfo.promise;
57
+ }
58
+ async start(config) {
59
+ const { route, host, port } = config;
60
+ // `createMcpExpressApp` gives us (a) a base Express app, (b) `express.json()` body
61
+ // parsing — load-bearing; without it `req.body` is undefined and `isInitializeRequest`
62
+ // can't tell init from non-init — and (c) DNS-rebinding host-header validation for
63
+ // the configured allowlist. We forward our `allowedHosts` so the SDK's validator and
64
+ // any explicit policy share one source of truth.
65
+ this._app = (0, express_js_1.createMcpExpressApp)({ host, allowedHosts: this.serverOptions.values.allowedHosts });
66
+ // Allow subclasses to install Express middleware (auth, CORS, rate-limiting,
67
+ // request logging) before the MCP routes are registered. Default: origin allowlist.
68
+ this.configureExpressApp(this._app);
69
+ // MCP-Protocol-Version validation runs after subclass middleware so adopter-installed
70
+ // gates (auth, CORS) get first cut, but before the SDK route handlers so an unsupported
71
+ // header rejects with HTTP 400 cleanly per spec.
72
+ this._app.use(route, this.validateProtocolVersionHeader.bind(this));
73
+ this._app.post(route, this.handlePostRequest.bind(this));
74
+ this._app.get(route, this.handleGetRequest.bind(this));
75
+ this._app.delete(route, this.handleDeleteRequest.bind(this));
76
+ this._server = this._app.listen(port, host);
77
+ // Disable the per-request timeout so long-lived SSE GET streams aren't killed during
78
+ // chat idle periods. From Node's perspective an SSE response is a single in-progress
79
+ // request that lasts as long as the client stays connected, so the default 5-minute
80
+ // `requestTimeout` (Node 18.1+) terminates the socket whenever no events flow for
81
+ // ≥5 min — the client surfaces this as `TypeError: terminated`. We rely on the MCP
82
+ // session-id handshake + `onclose` to detect gone clients.
83
+ this._server.requestTimeout = 0;
84
+ this._server.on('listening', () => this.listening());
85
+ // Pre-listen errors (typically `EADDRINUSE`) fire on the http.Server. Without a
86
+ // listener the deferred address never resolves and `start()` hangs; with it we
87
+ // surface an actionable message naming the offending port + the override path.
88
+ this._server.on('error', err => this.handleListenError(err, host, port));
89
+ const addressInfo = await this.getAddress();
90
+ return { url: this.toServerUrl(addressInfo, route) };
91
+ }
92
+ /**
93
+ * Translate a pre-listen failure into an actionable error and reject the address-info
94
+ * deferred so `start()` propagates it to the caller. `EADDRINUSE` gets a tailored hint
95
+ * about overriding via `mcpServer.port`; other codes pass through unchanged.
96
+ */
97
+ handleListenError(err, host, port) {
98
+ if (err.code === 'EADDRINUSE') {
99
+ const portLabel = port === 0 ? 'requested address' : `${host}:${port}`;
100
+ this._addressInfo.reject(new Error(`MCP server cannot bind ${portLabel}: address already in use. ` +
101
+ 'Pass a different `mcpServer.port` in the GLSP `initialize` call, or omit the port to get a random one.'));
102
+ return;
103
+ }
104
+ this._addressInfo.reject(err);
105
+ }
106
+ /**
107
+ * Hook for subclasses to register middleware on the Express app before the MCP routes
108
+ * are mounted. Called once during {@link start}, after the app is created and before
109
+ * `POST` / `GET` / `DELETE` handlers are added.
110
+ *
111
+ * Default behavior: install an Origin allowlist if one is configured. Host-header
112
+ * validation is already wired by the SDK's `createMcpExpressApp` (using the same
113
+ * `allowedHosts` we forward in {@link start}); we don't duplicate it here. Subclasses
114
+ * that override SHOULD `super.configureExpressApp(app)` to keep the origin gate in place;
115
+ * pre-existing security middleware can run before or after by calling super at the
116
+ * appropriate point.
117
+ */
118
+ configureExpressApp(app) {
119
+ const allowedOrigins = this.serverOptions.values.allowedOrigins;
120
+ if (!allowedOrigins) {
121
+ return;
122
+ }
123
+ app.use((req, res, next) => {
124
+ const origin = req.headers.origin;
125
+ if (origin && !allowedOrigins.includes(origin)) {
126
+ res.status(403).json({ error: `Forbidden: Origin '${origin}' not allowed` });
127
+ return;
128
+ }
129
+ next();
130
+ });
131
+ }
132
+ /**
133
+ * Validate the `MCP-Protocol-Version` header per the Streamable HTTP transport spec.
134
+ * Initialize POSTs negotiate the version in the body — the header isn't expected there.
135
+ * For every other request: absent header → pass through (the spec mandates the server
136
+ * default to `2025-03-26`); present-but-unsupported → respond `400` with a JSON-RPC error
137
+ * envelope so the client knows which versions to retry with.
138
+ */
139
+ validateProtocolVersionHeader(req, res, next) {
140
+ if (req.method === 'POST' && (0, types_js_1.isInitializeRequest)(req.body)) {
141
+ return next();
142
+ }
143
+ const headerValue = req.headers['mcp-protocol-version'];
144
+ const version = Array.isArray(headerValue) ? headerValue[0] : headerValue;
145
+ if (version === undefined) {
146
+ return next();
147
+ }
148
+ if (!types_js_1.SUPPORTED_PROTOCOL_VERSIONS.includes(version)) {
149
+ res.status(400).json({
150
+ jsonrpc: '2.0',
151
+ error: {
152
+ code: -32000,
153
+ message: `Unsupported MCP-Protocol-Version: '${version}'. ` +
154
+ `Supported versions: ${types_js_1.SUPPORTED_PROTOCOL_VERSIONS.join(', ')}.`
155
+ },
156
+ id: JSON_RPC_NULL_ID
157
+ });
158
+ return;
159
+ }
160
+ next();
161
+ }
162
+ toServerUrl({ address, family, port }, route, protocol = 'http') {
163
+ const host = address === '::' || address === '0.0.0.0' ? 'localhost' : family === 'IPv6' ? `[${address}]` : address;
164
+ return `${protocol}://${host}:${port}${route}`;
165
+ }
166
+ listening() {
167
+ var _a, _b, _c;
168
+ const addressInfo = (_a = this.server) === null || _a === void 0 ? void 0 : _a.address();
169
+ if (!addressInfo) {
170
+ this.logger.error('Could not resolve MCP Server address info. Shutting down.');
171
+ (_b = this._server) === null || _b === void 0 ? void 0 : _b.close();
172
+ return;
173
+ }
174
+ else if (typeof addressInfo === 'string') {
175
+ this.logger.error(`MCP Server is unexpectedly listening to pipe or domain socket "${addressInfo}". Shutting down.`);
176
+ (_c = this._server) === null || _c === void 0 ? void 0 : _c.close();
177
+ return;
178
+ }
179
+ this._addressInfo.resolve(addressInfo);
180
+ }
181
+ async handlePostRequest(req, res) {
182
+ const client = this.getOrCreateClient(req, res);
183
+ if (!client) {
184
+ return;
185
+ }
186
+ this.logger.debug(`Handling POST request for session ${client.sessionId}`);
187
+ try {
188
+ await client.handleRequest(req, res, req.body);
189
+ }
190
+ catch (err) {
191
+ this.logger.error('Error handling MCP request:', err);
192
+ if (!res.headersSent) {
193
+ res.status(500).json({ jsonrpc: '2.0', error: { code: -32603, message: 'Internal server error' }, id: JSON_RPC_NULL_ID });
194
+ }
195
+ }
196
+ }
197
+ /**
198
+ * Handle GET requests for SSE streams (using built-in support from StreamableHTTP)
199
+ */
200
+ async handleGetRequest(req, res) {
201
+ const client = this.getClient(req, res);
202
+ if (!client) {
203
+ return;
204
+ }
205
+ // Check for Last-Event-ID header for resumability
206
+ const lastEventId = req.headers['last-event-id'];
207
+ if (lastEventId) {
208
+ this.logger.info(`Client reconnecting with Last-Event-ID: ${lastEventId}`);
209
+ }
210
+ else {
211
+ this.logger.info(`Establishing new SSE stream for session ${client.sessionId}`);
212
+ }
213
+ await client.handleRequest(req, res);
214
+ }
215
+ /**
216
+ * Handle DELETE requests for session termination (according to MCP spec).
217
+ */
218
+ async handleDeleteRequest(req, res) {
219
+ const client = this.getClient(req, res);
220
+ if (!client) {
221
+ return;
222
+ }
223
+ this.logger.info(`Received session termination request for session ${client.sessionId}`);
224
+ try {
225
+ // SDK transport closes the session as part of handleRequest.
226
+ await client.handleRequest(req, res);
227
+ }
228
+ catch (err) {
229
+ this.logger.error('Error handling session termination:', err);
230
+ if (!res.headersSent) {
231
+ res.status(500).json({ jsonrpc: '2.0', error: { code: -32603, message: 'Internal server error' }, id: JSON_RPC_NULL_ID });
232
+ }
233
+ }
234
+ }
235
+ getOrCreateClient(req, res) {
236
+ // A brand-new session is born on an initialize POST that doesn't assert a session id.
237
+ // Every other case falls through to `getClient`, which enforces the spec-mandated
238
+ // 400/404 errors — including the case where an initialize POST carries an unknown
239
+ // session id (§ #3 — must not silently mint a replacement).
240
+ if (!getSessionIdHeader(req) && (0, types_js_1.isInitializeRequest)(req.body)) {
241
+ return this.createClient();
242
+ }
243
+ return this.getClient(req, res);
244
+ }
245
+ getClient(req, res) {
246
+ const sessionId = getSessionIdHeader(req);
247
+ if (!sessionId) {
248
+ // MCP Streamable HTTP § Session Management #2: a non-initialize request without
249
+ // a session id MUST be rejected with HTTP 400.
250
+ res.status(400).json({
251
+ jsonrpc: '2.0',
252
+ error: { code: -32000, message: 'Bad Request: No valid session ID provided' },
253
+ id: JSON_RPC_NULL_ID
254
+ });
255
+ return undefined;
256
+ }
257
+ const client = this.sessions.get(sessionId);
258
+ if (!client) {
259
+ // MCP Streamable HTTP § Session Management #3: requests bearing an unknown or
260
+ // terminated session id MUST be answered with HTTP 404 so the client knows to
261
+ // re-initialize.
262
+ res.status(404).json({
263
+ jsonrpc: '2.0',
264
+ error: { code: -32001, message: 'Session not found' },
265
+ id: JSON_RPC_NULL_ID
266
+ });
267
+ return undefined;
268
+ }
269
+ return client;
270
+ }
271
+ createClient() {
272
+ const client = new streamableHttp_js_1.StreamableHTTPServerTransport({
273
+ sessionIdGenerator: () => (0, node_crypto_1.randomUUID)(),
274
+ // Bounded LRU store so resumability via `Last-Event-ID` works without leaking
275
+ // memory in long-running deployments. Cap configurable via `eventStoreLimit`.
276
+ eventStore: new lru_event_store_1.LruEventStore(this.serverOptions.values.eventStoreLimit, this.logger),
277
+ onsessioninitialized: sessionId => {
278
+ // Store the transport by session ID when session is initialized
279
+ // This avoids race conditions where requests might come in before the session is stored
280
+ this.logger.info(`Session initialized with ID: ${sessionId}`);
281
+ this.sessions.set(sessionId, client);
282
+ this.onSessionInitializedEmitter.fire(client);
283
+ }
284
+ });
285
+ client.onclose = () => this.closeClient(client.sessionId);
286
+ // Surface transport errors to the GLSP logger. SDK 1.27.1 routes previously-swallowed
287
+ // errors here; without an explicit handler they go undiagnosed.
288
+ client.onerror = err => { var _a; return this.logger.error(`MCP transport error (session ${(_a = client.sessionId) !== null && _a !== void 0 ? _a : '<pre-init>'}):`, err); };
289
+ return client;
290
+ }
291
+ closeClient(sessionId) {
292
+ if (!sessionId) {
293
+ return;
294
+ }
295
+ const client = this.sessions.get(sessionId);
296
+ if (client) {
297
+ this.sessions.delete(sessionId);
298
+ client.close();
299
+ this.logger.info(`Closed and removed client with session ID ${sessionId}`);
300
+ this.onSessionClosedEmitter.fire(sessionId);
301
+ }
302
+ }
303
+ dispose() {
304
+ var _a;
305
+ // Close session transports first so their SSE responses end cleanly. `http.Server.close()`
306
+ // only stops accepting new connections — existing sockets stay open until they drain — so
307
+ // closing the server first would leave streams hanging until the per-session `client.close()`
308
+ // catches up.
309
+ // `Transport.close()` is async (returns Promise<void>) but `Disposable.dispose()` is sync,
310
+ // so we attach a catch handler to keep stray rejections out of the unhandled-rejection log.
311
+ Array.from(this.sessions.values()).forEach(client => client.close().catch(err => this.logger.warn(`Error closing MCP session ${client.sessionId}: ${err}`)));
312
+ this.sessions.clear();
313
+ (_a = this._server) === null || _a === void 0 ? void 0 : _a.close();
314
+ // Reset transient state so a subsequent `start()` call boots cleanly. Required because
315
+ // the transport is bound `inSingletonScope()` — without the reset, dispose-then-restart
316
+ // (e.g., GLSP server shutdown followed by a fresh `initializeServer`) would reuse the
317
+ // dead `_addressInfo` deferred and the closed Express app.
318
+ this._app = undefined;
319
+ this._server = undefined;
320
+ this._addressInfo = new server_1.Deferred();
321
+ this.logger.info('Server shutdown complete');
322
+ }
323
+ };
324
+ exports.McpHttpTransport = McpHttpTransport;
325
+ __decorate([
326
+ (0, inversify_1.inject)(mcp_options_1.McpServerOptions),
327
+ __metadata("design:type", mcp_options_1.McpServerOptions)
328
+ ], McpHttpTransport.prototype, "serverOptions", void 0);
329
+ exports.McpHttpTransport = McpHttpTransport = __decorate([
330
+ (0, inversify_1.injectable)(),
331
+ __param(0, (0, inversify_1.inject)(server_1.Logger)),
332
+ __metadata("design:paramtypes", [server_1.Logger])
333
+ ], McpHttpTransport);
334
+ /**
335
+ * Read the `mcp-session-id` header. Node's `IncomingHttpHeaders` types unknown headers as
336
+ * `string | string[] | undefined`; if a misbehaving client sends the header twice we pick
337
+ * the first value rather than coercing the array to `"a,b"` and silently failing the lookup.
338
+ */
339
+ function getSessionIdHeader(req) {
340
+ const value = req.headers['mcp-session-id'];
341
+ return Array.isArray(value) ? value[0] : value;
342
+ }
343
+ /**
344
+ * JSON-RPC 2.0 § 5 mandates `null` for error responses where the request id cannot be
345
+ * determined (e.g., parse errors, batch-level rejection, missing session id). Centralised so
346
+ * the unavoidable `null` literal lives behind one eslint exception instead of many.
347
+ */
348
+ // eslint-disable-next-line no-null/no-null
349
+ const JSON_RPC_NULL_ID = null;
350
+ //# sourceMappingURL=mcp-http-transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-http-transport.js","sourceRoot":"","sources":["../../src/server/mcp-http-transport.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;;;;;;;AAElF,iDAA6E;AAC7E,4EAAkF;AAClF,0FAAmG;AACnG,iEAAsG;AAItG,yCAA+C;AAE/C,6CAAyC;AACzC,uDAAkD;AAClD,+CAAiD;AAc1C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAazB,YAA4B,MAAwB;QAAd,WAAM,GAAN,MAAM,CAAQ;QAV1C,iBAAY,GAAG,IAAI,iBAAQ,EAAe,CAAC;QAE3C,aAAQ,GAAG,IAAI,GAAG,EAAyC,CAAC;QAC5D,gCAA2B,GAAG,IAAI,gBAAO,EAAc,CAAC;QAClE,yBAAoB,GAAG,IAAI,CAAC,2BAA2B,CAAC,KAAK,CAAC;QACpD,2BAAsB,GAAG,IAAI,gBAAO,EAAgB,CAAC;QAC/D,oBAAe,GAAG,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC;IAIG,CAAC;IAExD,IAAI,GAAG;QACH,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,IAAI,MAAM;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,UAAU;QACN,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,MAAkC;QAC1C,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;QACrC,mFAAmF;QACnF,uFAAuF;QACvF,mFAAmF;QACnF,qFAAqF;QACrF,iDAAiD;QACjD,IAAI,CAAC,IAAI,GAAG,IAAA,gCAAmB,EAAC,EAAE,IAAI,EAAE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DAAC;2BAX3D,gBAAgB;IAD5B,IAAA,sBAAU,GAAE;IAcI,WAAA,IAAA,kBAAM,EAAC,eAAM,CAAC,CAAA;qCAAmB,eAAM;GAb3C,gBAAgB,CAoT5B;AAED;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,GAAoB;IAC5C,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC5C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AACnD,CAAC;AAED;;;;GAIG;AACH,2CAA2C;AAC3C,MAAM,gBAAgB,GAAG,IAAI,CAAC"}
@@ -0,0 +1,70 @@
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 declare const McpIdAliasService: unique symbol;
17
+ /**
18
+ * Maps real GLSP element ids to a shorter, more LLM-friendly form on the wire. Tool/resource
19
+ * handlers `alias` real ids before emitting them and `lookup` incoming aliases before passing
20
+ * them to the model.
21
+ *
22
+ * Bound per GLSP client session — alias state is shared across MCP clients connected to the
23
+ * same GLSP session (id↔alias round-tripping must be consistent across clients). Adopters
24
+ * who want raw ids on the wire bind {@link NullMcpIdAliasService} via
25
+ * {@link DefaultMcpDiagramModule.bindIdAliasService}.
26
+ *
27
+ * @experimental
28
+ */
29
+ export interface McpIdAliasService {
30
+ /**
31
+ * Returns the alias for the given real id, allocating one on first call. Stable across
32
+ * subsequent calls within the same session.
33
+ */
34
+ alias(realId: string): string;
35
+ /**
36
+ * Resolves an alias back to its real id. Falls back to the input verbatim when no mapping
37
+ * exists, so callers can pass either an alias or a real id without branching: aliased ids
38
+ * round-trip; real ids (manual user input, copy-paste, ids surfaced from earlier
39
+ * server-side state) pass through. Downstream existence checks
40
+ * (`modelState.index.find`, the operation handler) decide validity.
41
+ */
42
+ lookup(aliasOrRealId: string): string;
43
+ }
44
+ /**
45
+ * Default {@link McpIdAliasService} — sequential integer aliases per session.
46
+ *
47
+ * Collision avoidance: every real id passed to {@link alias} is also recorded in a known-real
48
+ * set. When minting, candidate alias strings that collide with a known real id are skipped, so
49
+ * a model element whose actual id is e.g. `"1"` cannot be shadowed by an alias mapped to a
50
+ * different real id. This is conditional on the existing convention that every real id
51
+ * surfaced to the LLM flows through `alias()` at least once before the LLM can refer to it —
52
+ * adopter-written handlers that bypass `alias()` re-open the corner case.
53
+ */
54
+ export declare class DefaultMcpIdAliasService implements McpIdAliasService {
55
+ protected idToAlias: Map<string, string>;
56
+ protected aliasToId: Map<string, string>;
57
+ protected realIds: Set<string>;
58
+ protected counter: number;
59
+ alias(realId: string): string;
60
+ lookup(aliasOrRealId: string): string;
61
+ }
62
+ /**
63
+ * Null-object {@link McpIdAliasService} — passes ids through unchanged. Bind this in
64
+ * {@link DefaultMcpDiagramModule.bindIdAliasService} to expose raw GLSP ids on the wire.
65
+ */
66
+ export declare class NullMcpIdAliasService implements McpIdAliasService {
67
+ alias(realId: string): string;
68
+ lookup(aliasOrRealId: string): string;
69
+ }
70
+ //# sourceMappingURL=mcp-id-alias-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-id-alias-service.d.ts","sourceRoot":"","sources":["../../src/server/mcp-id-alias-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAIlF,eAAO,MAAM,iBAAiB,eAA8B,CAAC;AAE7D;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;;OAGG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B;;;;;;OAMG;IACH,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC;CACzC;AAED;;;;;;;;;GASG;AACH,qBACa,wBAAyB,YAAW,iBAAiB;IAC9D,SAAS,CAAC,SAAS,sBAA6B;IAChD,SAAS,CAAC,SAAS,sBAA6B;IAChD,SAAS,CAAC,OAAO,cAAqB;IACtC,SAAS,CAAC,OAAO,SAAK;IAEtB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAoB7B,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;CAGxC;AAED;;;GAGG;AACH,qBACa,qBAAsB,YAAW,iBAAiB;IAC3D,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAI7B,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM;CAGxC"}
@@ -0,0 +1,85 @@
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.NullMcpIdAliasService = exports.DefaultMcpIdAliasService = exports.McpIdAliasService = void 0;
25
+ const inversify_1 = require("inversify");
26
+ exports.McpIdAliasService = Symbol('McpIdAliasService');
27
+ /**
28
+ * Default {@link McpIdAliasService} — sequential integer aliases per session.
29
+ *
30
+ * Collision avoidance: every real id passed to {@link alias} is also recorded in a known-real
31
+ * set. When minting, candidate alias strings that collide with a known real id are skipped, so
32
+ * a model element whose actual id is e.g. `"1"` cannot be shadowed by an alias mapped to a
33
+ * different real id. This is conditional on the existing convention that every real id
34
+ * surfaced to the LLM flows through `alias()` at least once before the LLM can refer to it —
35
+ * adopter-written handlers that bypass `alias()` re-open the corner case.
36
+ */
37
+ let DefaultMcpIdAliasService = class DefaultMcpIdAliasService {
38
+ constructor() {
39
+ this.idToAlias = new Map();
40
+ this.aliasToId = new Map();
41
+ this.realIds = new Set();
42
+ this.counter = 1;
43
+ }
44
+ alias(realId) {
45
+ this.realIds.add(realId);
46
+ const existingAlias = this.idToAlias.get(realId);
47
+ if (existingAlias) {
48
+ return existingAlias;
49
+ }
50
+ let candidate = this.counter.toString();
51
+ while (this.realIds.has(candidate)) {
52
+ this.counter += 1;
53
+ candidate = this.counter.toString();
54
+ }
55
+ this.counter += 1;
56
+ this.idToAlias.set(realId, candidate);
57
+ this.aliasToId.set(candidate, realId);
58
+ return candidate;
59
+ }
60
+ lookup(aliasOrRealId) {
61
+ var _a;
62
+ return (_a = this.aliasToId.get(aliasOrRealId)) !== null && _a !== void 0 ? _a : aliasOrRealId;
63
+ }
64
+ };
65
+ exports.DefaultMcpIdAliasService = DefaultMcpIdAliasService;
66
+ exports.DefaultMcpIdAliasService = DefaultMcpIdAliasService = __decorate([
67
+ (0, inversify_1.injectable)()
68
+ ], DefaultMcpIdAliasService);
69
+ /**
70
+ * Null-object {@link McpIdAliasService} — passes ids through unchanged. Bind this in
71
+ * {@link DefaultMcpDiagramModule.bindIdAliasService} to expose raw GLSP ids on the wire.
72
+ */
73
+ let NullMcpIdAliasService = class NullMcpIdAliasService {
74
+ alias(realId) {
75
+ return realId;
76
+ }
77
+ lookup(aliasOrRealId) {
78
+ return aliasOrRealId;
79
+ }
80
+ };
81
+ exports.NullMcpIdAliasService = NullMcpIdAliasService;
82
+ exports.NullMcpIdAliasService = NullMcpIdAliasService = __decorate([
83
+ (0, inversify_1.injectable)()
84
+ ], NullMcpIdAliasService);
85
+ //# sourceMappingURL=mcp-id-alias-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-id-alias-service.js","sourceRoot":"","sources":["../../src/server/mcp-id-alias-service.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;AAElF,yCAAuC;AAE1B,QAAA,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AA8B7D;;;;;;;;;GASG;AAEI,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAA9B;QACO,cAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;QACtC,cAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;QACtC,YAAO,GAAG,IAAI,GAAG,EAAU,CAAC;QAC5B,YAAO,GAAG,CAAC,CAAC;IAyB1B,CAAC;IAvBG,KAAK,CAAC,MAAc;QAChB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACzB,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,aAAa,EAAE,CAAC;YAChB,OAAO,aAAa,CAAC;QACzB,CAAC;QAED,IAAI,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACxC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;YAClB,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACxC,CAAC;QACD,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC;QAElB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACtC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAEtC,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,aAAqB;;QACxB,OAAO,MAAA,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,mCAAI,aAAa,CAAC;IAC9D,CAAC;CACJ,CAAA;AA7BY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,sBAAU,GAAE;GACA,wBAAwB,CA6BpC;AAED;;;GAGG;AAEI,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAC9B,KAAK,CAAC,MAAc;QAChB,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,aAAqB;QACxB,OAAO,aAAa,CAAC;IACzB,CAAC;CACJ,CAAA;AARY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,sBAAU,GAAE;GACA,qBAAqB,CAQjC"}
@@ -0,0 +1,73 @@
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 * as z from 'zod/v4';
17
+ /**
18
+ * Common Zod input-schema fragments shared across MCP tool / resource / prompt handlers.
19
+ * Adopters compose these via `z.object({ ... })` or `McpDiagramScopedInputSchema.extend(...)`
20
+ * — Zod's modifiers (`.describe`, `.optional`, `.min`, ...) return new schemas without mutating
21
+ * the exports, so the shared fragments can be safely adapted at the call site.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { McpDiagramScopedInputSchema, elementIds } from '@eclipse-glsp/server-mcp';
26
+ *
27
+ * // Use as-is — the tool's `description` field already conveys the action context:
28
+ * const inputSchema = McpDiagramScopedInputSchema.extend({ elementIds });
29
+ *
30
+ * // Override `describe` only when there's genuinely new info (defaults, conditional applicability):
31
+ * const inputSchema = McpDiagramScopedInputSchema.extend({
32
+ * elementIds: elementIds.optional().describe('If not provided, validates entire model.')
33
+ * });
34
+ * ```
35
+ */
36
+ /** GLSP client session id (open diagram). Resolved by the launcher dispatcher via `ClientSessionManager`. */
37
+ export declare const sessionId: z.ZodString;
38
+ /** Single element id — alias or real; handlers translate via `resolveIds` on the diagram base. */
39
+ export declare const elementId: z.ZodString;
40
+ /** One or more element ids. Empty arrays are rejected. */
41
+ export declare const elementIds: z.ZodArray<z.ZodString>;
42
+ /** Cartesian position used by node-creation / -modification tools. */
43
+ export declare const position: z.ZodObject<{
44
+ x: z.ZodNumber;
45
+ y: z.ZodNumber;
46
+ }, z.core.$strict>;
47
+ /**
48
+ * Base schema for diagram-scope tool / prompt / resource-tool-alternative input. Adopter
49
+ * schemas extend this via {@link z.ZodObject.extend} and add their tool-specific fields.
50
+ */
51
+ export declare const McpDiagramScopedInputSchema: z.ZodObject<{
52
+ sessionId: z.ZodString;
53
+ }, z.core.$strip>;
54
+ /**
55
+ * Compact identity echoed by mutating tools (create / modify / delete) so the LLM has enough
56
+ * context to refer to the element by label or type in user-facing prose without a follow-up
57
+ * `query-elements`. The `id` is the alias.
58
+ */
59
+ export declare const ElementIdentitySchema: z.ZodObject<{
60
+ id: z.ZodString;
61
+ elementTypeId: z.ZodString;
62
+ label: z.ZodOptional<z.ZodString>;
63
+ }, z.core.$strip>;
64
+ /** Inferred shape of {@link ElementIdentitySchema} — see its docstring for usage. */
65
+ export type ElementIdentity = z.infer<typeof ElementIdentitySchema>;
66
+ /**
67
+ * Inferred shape of {@link McpDiagramScopedInputSchema} — `{ sessionId: string }`. Any
68
+ * adopter input schema that extends `McpDiagramScopedInputSchema` infers a type structurally
69
+ * assignable to this; used as the upper bound on diagram-scope handler generics
70
+ * (`<T extends McpDiagramScopedInput = McpDiagramScopedInput>`).
71
+ */
72
+ export type McpDiagramScopedInput = z.infer<typeof McpDiagramScopedInputSchema>;
73
+ //# sourceMappingURL=mcp-input-schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-input-schemas.d.ts","sourceRoot":"","sources":["../../src/server/mcp-input-schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B;;;;;;;;;;;;;;;;;;GAkBG;AAEH,6GAA6G;AAC7G,eAAO,MAAM,SAAS,aAAgE,CAAC;AAEvF,kGAAkG;AAClG,eAAO,MAAM,SAAS,aAAa,CAAC;AAEpC,0DAA0D;AAC1D,eAAO,MAAM,UAAU,yBAA6B,CAAC;AAErD,sEAAsE;AACtE,eAAO,MAAM,QAAQ;;;kBAKR,CAAC;AAEd;;;GAGG;AACH,eAAO,MAAM,2BAA2B;;iBAA0B,CAAC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;;;;iBAIhC,CAAC;AAEH,qFAAqF;AACrF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}