@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,212 @@
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 { ActionDispatcher, Logger, MaybePromise, ModelState, RequestAction, ResponseAction } from '@eclipse-glsp/server';
17
+ import { CompleteResourceTemplateCallback, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
18
+ import { Variables } from '@modelcontextprotocol/sdk/shared/uriTemplate.js';
19
+ import { Annotations, ListResourcesResult, Role } from '@modelcontextprotocol/sdk/types.js';
20
+ import { interfaces } from 'inversify';
21
+ import { ZodObject, ZodRawShape } from 'zod/v4';
22
+ import { GLSPMcpServer } from './glsp-mcp-server';
23
+ import { McpResourceContent, McpResourceResult, McpToolResult } from './mcp-handler-shared';
24
+ import { McpIdAliasService } from './mcp-id-alias-service';
25
+ import { McpDiagramScopedInput } from './mcp-input-schemas';
26
+ import { McpMimeType } from './mcp-mime-types';
27
+ /**
28
+ * Multi-binding key for **server-scope** resource handlers — singletons that don't target a
29
+ * specific GLSP client session. For diagram-scope resources see
30
+ * {@link McpDiagramResourceHandlerConstructor}.
31
+ *
32
+ * @experimental
33
+ */
34
+ export interface McpResourceHandler {
35
+ registerResource(server: GLSPMcpServer): void;
36
+ /** Optional tool fallback for clients that don't speak the resources protocol. */
37
+ registerToolAlternative?(server: GLSPMcpServer): void;
38
+ }
39
+ export declare const McpResourceHandler: unique symbol;
40
+ /** Static URI (string) or templated URI (`{ template: string }`). The base branches on shape. */
41
+ export type McpResourceUri = string | {
42
+ template: string;
43
+ };
44
+ /** Shared infrastructure for both server- and diagram-scope resource handlers. */
45
+ declare abstract class BaseMcpResourceHandler {
46
+ protected logger: Logger;
47
+ /**
48
+ * Resource identifier exposed to the MCP client. Also used to reference this resource from
49
+ * other handlers' prompt or description text — wire via `static readonly NAME = '…'` and
50
+ * `readonly name = ClassName.NAME` so those cross-references survive renames.
51
+ */
52
+ abstract readonly name: string;
53
+ /** LLM-facing explanation surfaced in the resource catalog. Keep concise — clients pass this verbatim to the model. */
54
+ abstract readonly description: string;
55
+ /** MIME type of the resource body. Adopters typically use one of {@link McpMimeType}'s common values; any string the MCP SDK accepts is valid. */
56
+ abstract readonly mimeType: McpMimeType;
57
+ /** Static URI string for fixed resources, or `{ template: string }` for templated URIs (e.g. `glsp://diagrams/{sessionId}/model`). */
58
+ abstract readonly uri: McpResourceUri;
59
+ /** Optional human-friendly display name for UIs that render a friendlier label than `name`. */
60
+ readonly title?: string;
61
+ /**
62
+ * Intended audience(s) — `"user"` (display the rendered content), `"assistant"` (use as model
63
+ * context), or both. Clients use it to filter/route the resource.
64
+ */
65
+ readonly audience?: Role[];
66
+ /** Importance, 0.0–1.0. Clients use it to prioritize inclusion in context. */
67
+ readonly priority?: number;
68
+ /** ISO 8601 timestamp of last meaningful change. Omit when the server has no clean freshness signal. */
69
+ readonly lastModified?: string;
70
+ /**
71
+ * Assembles the {@link Annotations} object the SDK expects from the flat-field surface.
72
+ * Returns `undefined` when no field is set so `resources/list` entries don't carry an
73
+ * empty `annotations: {}`.
74
+ */
75
+ toAnnotations(): Annotations | undefined;
76
+ /**
77
+ * Set to a `z.object({...})` schema to also expose the resource as a tool fallback (for MCP
78
+ * clients that don't speak the resources protocol). Field shape mirrors `inputSchema` on
79
+ * tool handlers — declarative, no extra method.
80
+ */
81
+ readonly toolAlternativeInputSchema?: ZodObject<ZodRawShape>;
82
+ /**
83
+ * Optional dual-emit output schema applied **only** in tool-alternative mode (when
84
+ * {@link toolAlternativeInputSchema} is set). When declared, the handler should populate
85
+ * `structured` on the returned {@link McpResourceContent} so the framework can forward it
86
+ * to `CallToolResult.structuredContent`. Resource-protocol reads ignore this — the spec
87
+ * has no equivalent slot on `ReadResourceResult`.
88
+ */
89
+ readonly toolAlternativeOutputSchema?: ZodObject<ZodRawShape>;
90
+ /** Override for templated URIs — enumerate matching resources. */
91
+ list?(): MaybePromise<ListResourcesResult>;
92
+ /** Override for templated URIs — completers per template variable. */
93
+ complete?(): Record<string, CompleteResourceTemplateCallback>;
94
+ /** Resolve `this.uri` (which may be a fixed string or a template object) to a template string. */
95
+ protected uriTemplate(): string;
96
+ /**
97
+ * Replace `{key}` placeholders in the URI template with the supplied values, single-pass
98
+ * (no re-expansion of substituted text) and `encodeURIComponent`-escaped. Unmatched keys
99
+ * pass through verbatim so the caller can spot them.
100
+ */
101
+ protected expandUriTemplate(vars: Record<string, string>): string;
102
+ /** Catches `McpToolError` (→ surfaced as text content + isError) and unexpected errors. */
103
+ protected execute(producer: () => MaybePromise<McpResourceContent>): Promise<ResourceExecutionResult>;
104
+ /** Wraps the body returned by {@link createResult} with `uri` + `mimeType` for the SDK. */
105
+ toResourceResult(uri: string, result: ResourceExecutionResult): McpResourceResult;
106
+ /** Converts the body to a `CallToolResult` for tool-alternative mode. Image MIMEs render as `image` content. */
107
+ toToolResult(result: ResourceExecutionResult): McpToolResult;
108
+ /** Builds the SDK `ResourceTemplate` for templated URIs (server-scope path). */
109
+ protected buildResourceTemplate(template: string): ResourceTemplate;
110
+ }
111
+ export type ResourceExecutionResult = {
112
+ ok: true;
113
+ body: McpResourceContent;
114
+ } | {
115
+ ok: false;
116
+ message: string;
117
+ };
118
+ /**
119
+ * Server-scope resource base — for resources that don't target a specific GLSP client session
120
+ * (e.g., a hypothetical adopter-supplied "global config" resource that returns the same data
121
+ * regardless of which diagram is open). The instance exists at boot, so `list`/`complete` can
122
+ * `@inject` server-scope deps directly. Bound under {@link McpResourceHandler}; the launcher
123
+ * invokes `registerResource(server)` once per MCP session.
124
+ *
125
+ * @experimental
126
+ */
127
+ export declare abstract class AbstractMcpResourceHandler<T = Record<string, unknown>> extends BaseMcpResourceHandler implements McpResourceHandler {
128
+ /** Throw {@link McpToolError} for expected errors; the base wraps. */
129
+ protected abstract createResult(params: T): MaybePromise<McpResourceContent>;
130
+ registerResource(server: GLSPMcpServer): void;
131
+ /** No-op when no {@link toolAlternativeInputSchema} is declared; otherwise registers as a tool. */
132
+ registerToolAlternative(server: GLSPMcpServer): void;
133
+ protected doRegisterToolAlternative(server: GLSPMcpServer): void;
134
+ }
135
+ /**
136
+ * Diagram-scope resource base — for resources whose URI templates carry a `sessionId` (e.g.,
137
+ * `glsp://diagrams/{sessionId}/model`).
138
+ *
139
+ * Unlike the server-scope base, the diagram-scope handler does not register itself with the
140
+ * SDK. The launcher's dispatcher reads the per-diagram-type constructor list, registers a
141
+ * single resource entry per `name`, and routes incoming reads to the matching per-GLSP-session
142
+ * handler instance via {@link handleRead}. For `list`/`complete`, the launcher walks all open
143
+ * GLSP sessions and aggregates each instance's slice — see {@link glspSessionScopedComplete}
144
+ * for the cross-GLSP-session-pollution auto-guard.
145
+ *
146
+ * @experimental
147
+ */
148
+ export declare abstract class AbstractMcpDiagramResourceHandler<T extends McpDiagramScopedInput = McpDiagramScopedInput> extends BaseMcpResourceHandler {
149
+ protected clientId: string;
150
+ protected modelState: ModelState;
151
+ protected aliasService: McpIdAliasService;
152
+ protected actionDispatcher: ActionDispatcher;
153
+ /** Throw {@link McpToolError} for expected errors; the base wraps. */
154
+ protected abstract createResult(params: T): MaybePromise<McpResourceContent>;
155
+ /**
156
+ * Convenience for resource handlers that fulfil a read by initiating a `RequestAction`
157
+ * round-trip to the client (today: `diagram-png` → `RequestExportAction`). Wraps
158
+ * {@link requestActionOrFail} with `this.actionDispatcher` and a default label of
159
+ * `this.name`. Pass an explicit label only to disambiguate between multiple round-trips.
160
+ */
161
+ protected requestAction<R extends ResponseAction>(request: RequestAction<R>, timeoutMs: number, label?: string): Promise<R>;
162
+ /** Override to opt out of registration when a runtime dependency is missing. Default: `true`. */
163
+ canRegister(): boolean;
164
+ /**
165
+ * Default `list()` for the per-session-single-resource case (diagram-model, diagram-png).
166
+ * Emits one entry resolved against the URI template, named with the handler's title and
167
+ * the GLSP session id, described with the handler's `description`. Multi-resource
168
+ * handlers (e.g. `element-types`, which lists once per diagram type) override.
169
+ */
170
+ list(): ListResourcesResult;
171
+ /**
172
+ * Default `complete()` for templated URIs that include `{sessionId}`. Returns a single
173
+ * completer that resolves to the current GLSP session's id. Handlers with other template
174
+ * variables (e.g. `{diagramType}` on `element-types`) override.
175
+ */
176
+ complete(): Record<string, CompleteResourceTemplateCallback>;
177
+ /** Default per-session entry built from the handler's metadata. Override to customize. */
178
+ protected toListingEntry(): ListResourcesResult['resources'][number];
179
+ /**
180
+ * Public dispatch entry point invoked by {@link McpServerLauncher}'s SDK callback for
181
+ * resource reads. The launcher passes the URI it received from the SDK plus the URI-template
182
+ * variable values normalized into a flat record.
183
+ */
184
+ handleRead(uri: string, params: T): Promise<McpResourceResult>;
185
+ /**
186
+ * Public dispatch entry point invoked by the launcher when the resource is exposed as a
187
+ * tool fallback (`McpServerOptions.resources === false`).
188
+ */
189
+ handleAsTool(params: T): Promise<McpToolResult>;
190
+ /**
191
+ * Wraps adopter-provided {@link complete} callbacks with the cross-GLSP-session-pollution
192
+ * auto-guard: when a templated URI carries `{sessionId}` and the LLM has bound a specific
193
+ * session id, completers for OTHER variables should not leak data from sessions whose ids
194
+ * don't match. The wrapper auto-returns `[]` from a GLSP session whose id doesn't match
195
+ * `ctx.arguments.sessionId`. Adopters write completers as if they only see their own GLSP
196
+ * session's data — the framework enforces the guard.
197
+ *
198
+ * Invoked by the launcher's aggregator, not by adopters directly.
199
+ */
200
+ glspSessionScopedComplete(): Record<string, CompleteResourceTemplateCallback>;
201
+ }
202
+ /** Normalizes SDK `Variables` (each value is `string | string[]`) to a flat `Record<string, string>`. */
203
+ export declare function toParams(variables: Variables): Record<string, string>;
204
+ /**
205
+ * Multi-binding identifier for diagram-scope resource handler constructors. See
206
+ * {@link McpDiagramToolHandlerConstructor} for the lifecycle pattern — same shape, applied to
207
+ * resource handlers.
208
+ */
209
+ export type McpDiagramResourceHandlerConstructor = interfaces.Newable<AbstractMcpDiagramResourceHandler<any>>;
210
+ export declare const McpDiagramResourceHandlerConstructor: unique symbol;
211
+ export {};
212
+ //# sourceMappingURL=mcp-resource-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-resource-handler.d.ts","sourceRoot":"","sources":["../../src/server/mcp-resource-handler.ts"],"names":[],"mappings":"AAAA;;;;;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CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,GAAE,MAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;IAItI,iGAAiG;IACjG,WAAW,IAAI,OAAO;IAItB;;;;;OAKG;IACM,IAAI,IAAI,mBAAmB;IAIpC;;;;OAIG;IACM,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,gCAAgC,CAAC;IAOrE,0FAA0F;IAC1F,SAAS,CAAC,cAAc,IAAI,mBAAmB,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;IAWpE;;;;OAIG;IACG,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIpE;;;OAGG;IACG,YAAY,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAIrD;;;;;;;;;OASG;IACH,yBAAyB,IAAI,MAAM,CAAC,MAAM,EAAE,gCAAgC,CAAC;CAahF;AAED,yGAAyG;AACzG,wBAAgB,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMrE;AAED;;;;GAIG;AACH,MAAM,MAAM,oCAAoC,GAAG,UAAU,CAAC,OAAO,CAAC,iCAAiC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9G,eAAO,MAAM,oCAAoC,eAAiD,CAAC"}
@@ -0,0 +1,298 @@
1
+ "use strict";
2
+ /********************************************************************************
3
+ * Copyright (c) 2025-2026 EclipseSource and others.
4
+ *
5
+ * This program and the accompanying materials are made available under the
6
+ * terms of the Eclipse Public License v. 2.0 which is available at
7
+ * http://www.eclipse.org/legal/epl-2.0.
8
+ *
9
+ * This Source Code may also be made available under the following Secondary
10
+ * Licenses when the conditions for such availability set forth in the Eclipse
11
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ * with the GNU Classpath Exception which is available at
13
+ * https://www.gnu.org/software/classpath/license.html.
14
+ *
15
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
+ ********************************************************************************/
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.McpDiagramResourceHandlerConstructor = exports.AbstractMcpDiagramResourceHandler = exports.AbstractMcpResourceHandler = exports.McpResourceHandler = void 0;
28
+ exports.toParams = toParams;
29
+ const server_1 = require("@eclipse-glsp/server");
30
+ const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
31
+ const inversify_1 = require("inversify");
32
+ const mcp_handler_shared_1 = require("./mcp-handler-shared");
33
+ const mcp_id_alias_service_1 = require("./mcp-id-alias-service");
34
+ const mcp_request_context_1 = require("./mcp-request-context");
35
+ exports.McpResourceHandler = Symbol('McpResourceHandler');
36
+ /** Shared infrastructure for both server- and diagram-scope resource handlers. */
37
+ let BaseMcpResourceHandler = class BaseMcpResourceHandler {
38
+ /**
39
+ * Assembles the {@link Annotations} object the SDK expects from the flat-field surface.
40
+ * Returns `undefined` when no field is set so `resources/list` entries don't carry an
41
+ * empty `annotations: {}`.
42
+ */
43
+ toAnnotations() {
44
+ if (this.audience === undefined && this.priority === undefined && this.lastModified === undefined) {
45
+ return undefined;
46
+ }
47
+ return {
48
+ ...(this.audience !== undefined ? { audience: this.audience } : {}),
49
+ ...(this.priority !== undefined ? { priority: this.priority } : {}),
50
+ ...(this.lastModified !== undefined ? { lastModified: this.lastModified } : {})
51
+ };
52
+ }
53
+ /** Resolve `this.uri` (which may be a fixed string or a template object) to a template string. */
54
+ uriTemplate() {
55
+ return typeof this.uri === 'string' ? this.uri : this.uri.template;
56
+ }
57
+ /**
58
+ * Replace `{key}` placeholders in the URI template with the supplied values, single-pass
59
+ * (no re-expansion of substituted text) and `encodeURIComponent`-escaped. Unmatched keys
60
+ * pass through verbatim so the caller can spot them.
61
+ */
62
+ expandUriTemplate(vars) {
63
+ return this.uriTemplate().replace(/\{(\w+)\}/g, (placeholder, key) => {
64
+ const value = vars[key];
65
+ return value === undefined ? placeholder : encodeURIComponent(value);
66
+ });
67
+ }
68
+ /** Catches `McpToolError` (→ surfaced as text content + isError) and unexpected errors. */
69
+ async execute(producer) {
70
+ try {
71
+ return { ok: true, body: await producer() };
72
+ }
73
+ catch (err) {
74
+ if (err instanceof mcp_handler_shared_1.McpToolError) {
75
+ return { ok: false, message: err.message };
76
+ }
77
+ const message = (0, mcp_handler_shared_1.extractErrorMessage)(err);
78
+ this.logger.error(`Unexpected error in resource '${this.name}': ${message}`, err);
79
+ return { ok: false, message };
80
+ }
81
+ }
82
+ /** Wraps the body returned by {@link createResult} with `uri` + `mimeType` for the SDK. */
83
+ toResourceResult(uri, result) {
84
+ if (!result.ok) {
85
+ return { contents: [{ uri, mimeType: 'text/plain', text: result.message }], isError: true };
86
+ }
87
+ const content = 'text' in result.body
88
+ ? { uri, mimeType: this.mimeType, text: result.body.text }
89
+ : { uri, mimeType: this.mimeType, blob: result.body.blob };
90
+ return { contents: [content], isError: false };
91
+ }
92
+ /** Converts the body to a `CallToolResult` for tool-alternative mode. Image MIMEs render as `image` content. */
93
+ toToolResult(result) {
94
+ if (!result.ok) {
95
+ return { isError: true, content: [{ type: 'text', text: result.message }] };
96
+ }
97
+ const structuredContent = result.body.structured;
98
+ const baseContent = 'text' in result.body
99
+ ? { isError: false, content: [{ type: 'text', text: result.body.text }] }
100
+ : { isError: false, content: [{ type: 'image', data: result.body.blob, mimeType: this.mimeType }] };
101
+ return structuredContent ? { ...baseContent, structuredContent } : baseContent;
102
+ }
103
+ /** Builds the SDK `ResourceTemplate` for templated URIs (server-scope path). */
104
+ buildResourceTemplate(template) {
105
+ var _a;
106
+ return new mcp_js_1.ResourceTemplate(template, {
107
+ list: this.list ? async (extra) => mcp_request_context_1.mcpRequestContext.run(extra, () => this.list()) : undefined,
108
+ complete: (_a = this.complete) === null || _a === void 0 ? void 0 : _a.call(this)
109
+ });
110
+ }
111
+ };
112
+ __decorate([
113
+ (0, inversify_1.inject)(server_1.Logger),
114
+ __metadata("design:type", server_1.Logger)
115
+ ], BaseMcpResourceHandler.prototype, "logger", void 0);
116
+ BaseMcpResourceHandler = __decorate([
117
+ (0, inversify_1.injectable)()
118
+ ], BaseMcpResourceHandler);
119
+ /**
120
+ * Server-scope resource base — for resources that don't target a specific GLSP client session
121
+ * (e.g., a hypothetical adopter-supplied "global config" resource that returns the same data
122
+ * regardless of which diagram is open). The instance exists at boot, so `list`/`complete` can
123
+ * `@inject` server-scope deps directly. Bound under {@link McpResourceHandler}; the launcher
124
+ * invokes `registerResource(server)` once per MCP session.
125
+ *
126
+ * @experimental
127
+ */
128
+ let AbstractMcpResourceHandler = class AbstractMcpResourceHandler extends BaseMcpResourceHandler {
129
+ registerResource(server) {
130
+ const annotations = this.toAnnotations();
131
+ const config = {
132
+ title: this.title,
133
+ description: this.description,
134
+ mimeType: this.mimeType,
135
+ ...(annotations ? { annotations } : {})
136
+ };
137
+ if (typeof this.uri === 'string') {
138
+ const uri = this.uri;
139
+ server.registerResource(this.name, uri, config, async (_uri, extra) => mcp_request_context_1.mcpRequestContext.run(extra, async () => this.toResourceResult(uri, await this.execute(() => this.createResult({})))));
140
+ }
141
+ else {
142
+ server.registerResource(this.name, this.buildResourceTemplate(this.uri.template), config, async (uri, params, extra) => mcp_request_context_1.mcpRequestContext.run(extra, async () => this.toResourceResult(uri.toString(), await this.execute(() => this.createResult(toParams(params))))));
143
+ }
144
+ }
145
+ /** No-op when no {@link toolAlternativeInputSchema} is declared; otherwise registers as a tool. */
146
+ registerToolAlternative(server) {
147
+ if (!this.toolAlternativeInputSchema) {
148
+ return;
149
+ }
150
+ this.doRegisterToolAlternative(server);
151
+ }
152
+ doRegisterToolAlternative(server) {
153
+ const inputSchema = this.toolAlternativeInputSchema;
154
+ // `.strict()` matches the tool-handler policy — see `BaseMcpToolHandler.toRegistrationConfig`
155
+ // for the full rationale (LLM-typoed fields surface as JSON-RPC validation errors instead
156
+ // of being silently stripped).
157
+ server.registerTool(this.name, {
158
+ title: this.title,
159
+ description: this.description,
160
+ inputSchema: inputSchema.strict(),
161
+ outputSchema: this.toolAlternativeOutputSchema
162
+ }, async (params, extra) => mcp_request_context_1.mcpRequestContext.run(extra, async () => this.toToolResult(await this.execute(() => this.createResult(params)))));
163
+ }
164
+ };
165
+ exports.AbstractMcpResourceHandler = AbstractMcpResourceHandler;
166
+ exports.AbstractMcpResourceHandler = AbstractMcpResourceHandler = __decorate([
167
+ (0, inversify_1.injectable)()
168
+ ], AbstractMcpResourceHandler);
169
+ /**
170
+ * Diagram-scope resource base — for resources whose URI templates carry a `sessionId` (e.g.,
171
+ * `glsp://diagrams/{sessionId}/model`).
172
+ *
173
+ * Unlike the server-scope base, the diagram-scope handler does not register itself with the
174
+ * SDK. The launcher's dispatcher reads the per-diagram-type constructor list, registers a
175
+ * single resource entry per `name`, and routes incoming reads to the matching per-GLSP-session
176
+ * handler instance via {@link handleRead}. For `list`/`complete`, the launcher walks all open
177
+ * GLSP sessions and aggregates each instance's slice — see {@link glspSessionScopedComplete}
178
+ * for the cross-GLSP-session-pollution auto-guard.
179
+ *
180
+ * @experimental
181
+ */
182
+ let AbstractMcpDiagramResourceHandler = class AbstractMcpDiagramResourceHandler extends BaseMcpResourceHandler {
183
+ /**
184
+ * Convenience for resource handlers that fulfil a read by initiating a `RequestAction`
185
+ * round-trip to the client (today: `diagram-png` → `RequestExportAction`). Wraps
186
+ * {@link requestActionOrFail} with `this.actionDispatcher` and a default label of
187
+ * `this.name`. Pass an explicit label only to disambiguate between multiple round-trips.
188
+ */
189
+ requestAction(request, timeoutMs, label = this.name) {
190
+ return (0, mcp_handler_shared_1.requestActionOrFail)(this.actionDispatcher, request, timeoutMs, label);
191
+ }
192
+ /** Override to opt out of registration when a runtime dependency is missing. Default: `true`. */
193
+ canRegister() {
194
+ return true;
195
+ }
196
+ /**
197
+ * Default `list()` for the per-session-single-resource case (diagram-model, diagram-png).
198
+ * Emits one entry resolved against the URI template, named with the handler's title and
199
+ * the GLSP session id, described with the handler's `description`. Multi-resource
200
+ * handlers (e.g. `element-types`, which lists once per diagram type) override.
201
+ */
202
+ list() {
203
+ return { resources: [this.toListingEntry()] };
204
+ }
205
+ /**
206
+ * Default `complete()` for templated URIs that include `{sessionId}`. Returns a single
207
+ * completer that resolves to the current GLSP session's id. Handlers with other template
208
+ * variables (e.g. `{diagramType}` on `element-types`) override.
209
+ */
210
+ complete() {
211
+ if (this.uriTemplate().includes('{sessionId}')) {
212
+ return { sessionId: async () => [this.clientId] };
213
+ }
214
+ return {};
215
+ }
216
+ /** Default per-session entry built from the handler's metadata. Override to customize. */
217
+ toListingEntry() {
218
+ var _a;
219
+ const annotations = this.toAnnotations();
220
+ return {
221
+ uri: this.expandUriTemplate({ sessionId: this.clientId }),
222
+ name: `${(_a = this.title) !== null && _a !== void 0 ? _a : this.name}: ${this.clientId}`,
223
+ description: this.description,
224
+ mimeType: this.mimeType,
225
+ ...(annotations ? { annotations } : {})
226
+ };
227
+ }
228
+ /**
229
+ * Public dispatch entry point invoked by {@link McpServerLauncher}'s SDK callback for
230
+ * resource reads. The launcher passes the URI it received from the SDK plus the URI-template
231
+ * variable values normalized into a flat record.
232
+ */
233
+ async handleRead(uri, params) {
234
+ return this.toResourceResult(uri, await this.execute(() => this.createResult(params)));
235
+ }
236
+ /**
237
+ * Public dispatch entry point invoked by the launcher when the resource is exposed as a
238
+ * tool fallback (`McpServerOptions.resources === false`).
239
+ */
240
+ async handleAsTool(params) {
241
+ return this.toToolResult(await this.execute(() => this.createResult(params)));
242
+ }
243
+ /**
244
+ * Wraps adopter-provided {@link complete} callbacks with the cross-GLSP-session-pollution
245
+ * auto-guard: when a templated URI carries `{sessionId}` and the LLM has bound a specific
246
+ * session id, completers for OTHER variables should not leak data from sessions whose ids
247
+ * don't match. The wrapper auto-returns `[]` from a GLSP session whose id doesn't match
248
+ * `ctx.arguments.sessionId`. Adopters write completers as if they only see their own GLSP
249
+ * session's data — the framework enforces the guard.
250
+ *
251
+ * Invoked by the launcher's aggregator, not by adopters directly.
252
+ */
253
+ glspSessionScopedComplete() {
254
+ var _a, _b;
255
+ const raw = (_b = (_a = this.complete) === null || _a === void 0 ? void 0 : _a.call(this)) !== null && _b !== void 0 ? _b : {};
256
+ const myId = this.clientId;
257
+ const isGlspSessionScoped = typeof this.uri === 'object' && this.uri.template.includes('{sessionId}');
258
+ const wrapped = {};
259
+ for (const [variable, completer] of Object.entries(raw)) {
260
+ wrapped[variable] =
261
+ variable === 'sessionId' || !isGlspSessionScoped
262
+ ? completer
263
+ : async (value, ctx) => { var _a; return (((_a = ctx === null || ctx === void 0 ? void 0 : ctx.arguments) === null || _a === void 0 ? void 0 : _a.sessionId) === myId ? completer(value, ctx) : []); };
264
+ }
265
+ return wrapped;
266
+ }
267
+ };
268
+ exports.AbstractMcpDiagramResourceHandler = AbstractMcpDiagramResourceHandler;
269
+ __decorate([
270
+ (0, inversify_1.inject)(server_1.ClientId),
271
+ __metadata("design:type", String)
272
+ ], AbstractMcpDiagramResourceHandler.prototype, "clientId", void 0);
273
+ __decorate([
274
+ (0, inversify_1.inject)(server_1.ModelState),
275
+ __metadata("design:type", Object)
276
+ ], AbstractMcpDiagramResourceHandler.prototype, "modelState", void 0);
277
+ __decorate([
278
+ (0, inversify_1.inject)(mcp_id_alias_service_1.McpIdAliasService),
279
+ __metadata("design:type", Object)
280
+ ], AbstractMcpDiagramResourceHandler.prototype, "aliasService", void 0);
281
+ __decorate([
282
+ (0, inversify_1.inject)(server_1.ActionDispatcher),
283
+ __metadata("design:type", Object)
284
+ ], AbstractMcpDiagramResourceHandler.prototype, "actionDispatcher", void 0);
285
+ exports.AbstractMcpDiagramResourceHandler = AbstractMcpDiagramResourceHandler = __decorate([
286
+ (0, inversify_1.injectable)()
287
+ ], AbstractMcpDiagramResourceHandler);
288
+ /** Normalizes SDK `Variables` (each value is `string | string[]`) to a flat `Record<string, string>`. */
289
+ function toParams(variables) {
290
+ var _a;
291
+ const out = {};
292
+ for (const [key, value] of Object.entries(variables)) {
293
+ out[key] = Array.isArray(value) ? (_a = value[0]) !== null && _a !== void 0 ? _a : '' : value;
294
+ }
295
+ return out;
296
+ }
297
+ exports.McpDiagramResourceHandlerConstructor = Symbol('McpDiagramResourceHandlerConstructor');
298
+ //# sourceMappingURL=mcp-resource-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-resource-handler.js","sourceRoot":"","sources":["../../src/server/mcp-resource-handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;;;;AAwWlF,4BAMC;AA5WD,iDAAmI;AACnI,oEAA6G;AAG7G,yCAA2D;AAG3D,6DAQ8B;AAC9B,iEAA2D;AAG3D,+DAA0D;AAc7C,QAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAK/D,kFAAkF;AAElF,IAAe,sBAAsB,GAArC,MAAe,sBAAsB;IAkCjC;;;;OAIG;IACH,aAAa;QACT,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YAChG,OAAO,SAAS,CAAC;QACrB,CAAC;QACD,OAAO;YACH,GAAG,CAAC,IAAI,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAA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