@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,259 @@
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, GModelElement, Logger, MaybePromise, ModelState, RequestAction, ResponseAction } from '@eclipse-glsp/server';
17
+ import { ToolAnnotations } from '@modelcontextprotocol/sdk/types';
18
+ import { interfaces } from 'inversify';
19
+ import { ZodObject, ZodRawShape } from 'zod/v4';
20
+ import { GLSPMcpServer } from './glsp-mcp-server';
21
+ import { McpStructuredContent, McpToolErrorCode, McpToolResult } from './mcp-handler-shared';
22
+ import { McpIdAliasService } from './mcp-id-alias-service';
23
+ import { ElementIdentity, McpDiagramScopedInput } from './mcp-input-schemas';
24
+ import { McpLabelProvider } from './mcp-label-provider';
25
+ /**
26
+ * Multi-binding key for **server-scope** tool handlers — singletons that don't target a
27
+ * specific GLSP client session. Adopters extend {@link AbstractMcpToolHandler} and bind their
28
+ * subclass against this symbol; the launcher invokes `registerTool(server)` on each at
29
+ * MCP-session-init.
30
+ *
31
+ * Diagram-scope tools (one instance per open diagram) use the separate
32
+ * {@link McpDiagramToolHandlerConstructor} multi-binding instead — see `mcp-session.ts` for
33
+ * the MCP-session vs GLSP-session terminology.
34
+ *
35
+ * @experimental
36
+ */
37
+ export interface McpToolHandler {
38
+ registerTool(server: GLSPMcpServer): void;
39
+ }
40
+ export declare const McpToolHandler: unique symbol;
41
+ /**
42
+ * Shared infrastructure for both server- and diagram-scope tool handlers — exported so adopters
43
+ * who want to factor common helpers across server-scope and diagram-scope tools can extend a
44
+ * single ancestor instead of duplicating logic. Most adopters extend the more specific siblings
45
+ * ({@link AbstractMcpToolHandler}, {@link AbstractMcpDiagramToolHandler},
46
+ * {@link OperationMcpDiagramToolHandler}); reach for this base only when a helper is genuinely
47
+ * scope-agnostic.
48
+ *
49
+ * @experimental
50
+ */
51
+ export declare abstract class BaseMcpToolHandler {
52
+ protected logger: Logger;
53
+ /**
54
+ * Tool identifier exposed to the MCP client. Also used to reference this tool from other
55
+ * handlers' prompt or description text — wire via `static readonly NAME = '…'` and
56
+ * `readonly name = ClassName.NAME` so those cross-references survive renames.
57
+ */
58
+ abstract readonly name: string;
59
+ /** LLM-facing explanation surfaced in the tool catalog — clients pass this verbatim to the model. Keep concise and behavioral. */
60
+ abstract readonly description: string;
61
+ /** Adopter writes `z.object({ ... })`; the base passes `.shape` to the SDK. */
62
+ abstract readonly inputSchema: ZodObject<ZodRawShape>;
63
+ /**
64
+ * Optional dual-emit schema. When set, pass the matching `structured` payload to
65
+ * {@link success} so the framework forwards it as `structuredContent` alongside the
66
+ * human-readable text. The MCP spec says clients SHOULD validate `structuredContent`
67
+ * against the declared schema, so the two MUST stay in sync.
68
+ */
69
+ readonly outputSchema?: ZodObject<ZodRawShape>;
70
+ /** Optional human-friendly display name for UIs that render a friendlier label than `name`. */
71
+ readonly title?: string;
72
+ /**
73
+ * Tool does not modify its environment. Defaults to `true` here on the common base;
74
+ * overridden to `false` on {@link OperationMcpDiagramToolHandler} since write-style tools
75
+ * dispatch model-mutating operations.
76
+ */
77
+ readonly readOnlyHint: boolean;
78
+ /**
79
+ * Tool may perform destructive *updates* (irreversible deletion, data loss). Only meaningful
80
+ * when `readOnlyHint: false`. Set explicitly on the concrete handler when it applies (e.g.
81
+ * `delete-elements`).
82
+ */
83
+ readonly destructiveHint?: boolean;
84
+ /**
85
+ * Repeated calls with the same arguments have no additional effect. Only meaningful when
86
+ * `readOnlyHint: false`.
87
+ */
88
+ readonly idempotentHint?: boolean;
89
+ /**
90
+ * Tool interacts with an "open world" of external entities (web search, external APIs).
91
+ * Default in this codebase: `false` — diagram ops are bounded to the GLSP client. Set
92
+ * `true` for tools that reach off-process.
93
+ */
94
+ readonly openWorldHint: boolean;
95
+ /**
96
+ * SDK-facing registration config; consumed by both the server-scope `registerTool` flow and
97
+ * the launcher's diagram-scope dispatcher. Assembles the {@link ToolAnnotations} object from
98
+ * the flat-field surface so adopters compose annotations via field overrides, not by
99
+ * redeclaring the whole annotations literal.
100
+ */
101
+ toRegistrationConfig(): {
102
+ title?: string;
103
+ description: string;
104
+ inputSchema: ZodObject<ZodRawShape>;
105
+ outputSchema?: ZodObject<ZodRawShape>;
106
+ annotations: ToolAnnotations;
107
+ };
108
+ protected error(message: string, code?: McpToolErrorCode): McpToolResult;
109
+ /**
110
+ * Convention: `message` is a short, referenceable summary (ids, types, counts); `structured`
111
+ * carries the full payload. The two complement rather than duplicate — balancing token usage
112
+ * across the heterogeneous client landscape.
113
+ *
114
+ * The MCP spec (2025-06-18) recommends mirroring `structuredContent` into a TextContent
115
+ * block, but in-flight discussion is softening that — `content` and `structuredContent` are
116
+ * increasingly model-oriented vs. machine-oriented surfaces that should be semantically
117
+ * equivalent, not byte-identical.
118
+ *
119
+ * Client behavior is uneven, so summary-in-content + payload-in-structured is a deliberate
120
+ * hedge: some clients only forward `structuredContent`, some only `content`, some forward
121
+ * both verbatim and double the per-call context budget.
122
+ *
123
+ * Pass `structured` whenever {@link outputSchema} is declared (the spec says clients SHOULD
124
+ * validate against the declared shape). Omit for plain text-only responses.
125
+ */
126
+ protected success(message: string, structured?: McpStructuredContent): McpToolResult;
127
+ /** Catches `McpToolError` (→ `isError: true` result) and unexpected errors; tags known errors via {@link errorCodeFor}. */
128
+ protected execute(producer: () => MaybePromise<McpToolResult>): Promise<McpToolResult>;
129
+ }
130
+ /**
131
+ * Server-scope tool base — for tools that don't target a specific GLSP client session
132
+ * (e.g., listing all sessions). Bound under {@link McpToolHandler} as a server-scope singleton;
133
+ * the launcher invokes `registerTool(server)` once per MCP session.
134
+ *
135
+ * @experimental
136
+ */
137
+ export declare abstract class AbstractMcpToolHandler<T = Record<string, unknown>> extends BaseMcpToolHandler implements McpToolHandler {
138
+ /** Throw {@link McpToolError} for expected, user-facing errors; the base wraps. */
139
+ protected abstract createResult(params: T): MaybePromise<McpToolResult>;
140
+ registerTool(server: GLSPMcpServer): void;
141
+ }
142
+ /**
143
+ * Shared per-session implementation for diagram-scope tool handlers. Adopters don't extend this
144
+ * directly — extend {@link AbstractMcpDiagramToolHandler} (read) or {@link OperationMcpDiagramToolHandler}
145
+ * (write). Exported only as the upper bound for the {@link McpDiagramToolHandlerConstructor}
146
+ * multi-binding.
147
+ *
148
+ * `@inject(...)` fields resolve against the live `ClientSession.container` because instances are
149
+ * created at GLSP-session-open by `McpDiagramToolHandlerRegistryInitializer`.
150
+ *
151
+ * Read-side handlers access `modelState.index` directly. Synchronous reads are atomic, but a
152
+ * concurrent tool that awaits `actionDispatcher.dispatch(...)` may expose a half-committed
153
+ * model — write-then-read tool sequences must serialize the write before the read.
154
+ *
155
+ * @experimental
156
+ */
157
+ export declare abstract class BaseMcpDiagramToolHandler<T extends McpDiagramScopedInput = McpDiagramScopedInput> extends BaseMcpToolHandler {
158
+ protected clientId: string;
159
+ protected modelState: ModelState;
160
+ protected aliasService: McpIdAliasService;
161
+ protected labelProvider: McpLabelProvider;
162
+ /** Throw {@link McpToolError} for expected errors; the base wraps. */
163
+ protected abstract createResult(params: T): MaybePromise<McpToolResult>;
164
+ /**
165
+ * Public dispatch entry point invoked by {@link McpServerLauncher}'s registered SDK
166
+ * callback. Each sibling sets its own policy — {@link AbstractMcpDiagramToolHandler}
167
+ * passes through; {@link OperationMcpDiagramToolHandler} enforces the readonly gate.
168
+ * Adopters don't call this directly.
169
+ */
170
+ abstract handle(params: T): Promise<McpToolResult>;
171
+ /** Override to opt out of registration when a runtime dependency is missing. Default: `true`. */
172
+ canRegister(): boolean;
173
+ /** Translates (alias-or-real) ids to real ids; partitions ids absent from the model into `missingIds`. */
174
+ protected resolveIds(ids: string[]): {
175
+ realIds: string[];
176
+ missingIds: string[];
177
+ };
178
+ /** Like {@link resolveIds} but throws {@link McpElementsNotFoundError} when any input id is absent. */
179
+ protected resolveExistingIds(ids: string[] | undefined): string[];
180
+ /**
181
+ * Resolves a list of structured inputs against the model: each input's id is looked up via the
182
+ * alias service and the resolved element is retrieved from the index. Throws
183
+ * {@link McpElementsNotFoundError} if any input's id is absent. The returned tuples preserve
184
+ * caller's input/element pairing for downstream processing (e.g. type-checks per kind).
185
+ */
186
+ protected lookupElements<I>(inputs: I[], extractId: (input: I) => string): Array<[I, GModelElement]>;
187
+ /** Encodes real ids to alias ids (passthrough when {@link NullMcpIdAliasService} is bound). */
188
+ protected encodeIds(ids: string[]): string[];
189
+ /**
190
+ * Compact identity for an element — `{ id, elementTypeId, label? }`. Mutating tools (create
191
+ * / modify / delete) echo this so the LLM can refer to the element by label or type in
192
+ * user-facing prose without a follow-up `query-elements` call. Returns `undefined` when
193
+ * the element is no longer in the model (e.g. just deleted).
194
+ */
195
+ protected describeElement(aliasOrRealId: string): ElementIdentity | undefined;
196
+ /** Describe an already-resolved {@link GModelElement} — skips the model-lookup round-trip. */
197
+ protected describeResolvedElement(element: GModelElement): ElementIdentity;
198
+ }
199
+ /**
200
+ * Diagram-scope tool base for **query-style** tools that read the model without mutating it
201
+ * (validate, get-selection, set-view, query-elements). Sibling of
202
+ * {@link OperationMcpDiagramToolHandler} — extend that one when the tool dispatches a
203
+ * model-mutating Operation.
204
+ *
205
+ * @experimental
206
+ */
207
+ export declare abstract class AbstractMcpDiagramToolHandler<T extends McpDiagramScopedInput = McpDiagramScopedInput> extends BaseMcpDiagramToolHandler<T> {
208
+ handle(params: T): Promise<McpToolResult>;
209
+ }
210
+ /**
211
+ * Diagram-scope tool base for **operation-style** tools that mutate the model by dispatching a
212
+ * GLSP `Operation` (or other model-mutating `Action` like `UndoAction` / `RedoAction`) on
213
+ * behalf of the LLM — create, modify, delete, undo, redo. Sibling of
214
+ * {@link AbstractMcpDiagramToolHandler}.
215
+ *
216
+ * The base bakes in two pieces beyond the read sibling:
217
+ * - `@inject(ActionDispatcher)`. Every adopter extending this base dispatches, so the
218
+ * dispatcher belongs on the base, not in per-handler boilerplate.
219
+ * - Throws {@link McpReadOnlyError} when `modelState.isReadonly`, surfacing a hard failure
220
+ * to the LLM. The MCP-side gate is necessary even though core's `OperationActionHandler`
221
+ * checks readonly itself: core's gate is a *soft* warning (returns a `MessageAction`, the
222
+ * dispatch resolves successfully and the tool body would otherwise report success while
223
+ * nothing changed), and `UndoRedoActionHandler` doesn't gate readonly at all.
224
+ *
225
+ * Parallels core's `OperationHandler` (sibling to `ActionHandler`, not a refinement) — but
226
+ * note the role flip: core's `OperationHandler` is downstream of dispatch and only needs
227
+ * `ModelState`; ours is upstream of dispatch (the LLM-side handler that triggers the Operation)
228
+ * and so additionally injects `ActionDispatcher`.
229
+ *
230
+ * @experimental
231
+ */
232
+ export declare abstract class OperationMcpDiagramToolHandler<T extends McpDiagramScopedInput = McpDiagramScopedInput> extends BaseMcpDiagramToolHandler<T> {
233
+ protected actionDispatcher: ActionDispatcher;
234
+ readonly readOnlyHint = false;
235
+ readonly destructiveHint: boolean;
236
+ readonly idempotentHint: boolean;
237
+ handle(params: T): Promise<McpToolResult>;
238
+ /**
239
+ * Convenience for tools that initiate a `RequestAction` round-trip (rather than the
240
+ * fire-and-forget operation dispatch this base is named for) — wraps
241
+ * {@link requestActionOrFail} with `this.actionDispatcher` and a default label of
242
+ * `this.name`. Pass an explicit label only when the tool handles multiple distinct
243
+ * round-trips and wants to disambiguate them in error messages.
244
+ */
245
+ protected requestAction<R extends ResponseAction>(request: RequestAction<R>, timeoutMs: number, label?: string): Promise<R>;
246
+ }
247
+ /**
248
+ * Multi-binding identifier for diagram-scope tool handler constructors — covers both
249
+ * {@link AbstractMcpDiagramToolHandler} and {@link OperationMcpDiagramToolHandler}. Bound via
250
+ * `AbstractMcpDiagramModule.configureToolHandlers`; the per-GLSP-session registry initializer
251
+ * reads the list at session-open and resolves each constructor against the session container.
252
+ *
253
+ * Mirrors core's `OperationHandlerConstructor` pattern: instance fields (`readonly name = '…'`)
254
+ * are read off `new Constructor()` at MCP-session-init for SDK catalog registration, the same
255
+ * trick `bindOperations` uses to read `operationType`.
256
+ */
257
+ export type McpDiagramToolHandlerConstructor = interfaces.Newable<BaseMcpDiagramToolHandler<any>>;
258
+ export declare const McpDiagramToolHandlerConstructor: unique symbol;
259
+ //# sourceMappingURL=mcp-tool-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"m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/C,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,CACzD,SAAQ,yBAAyB,CAAC,CAAC,CAAC;IAClC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;CAG5C;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,8BACsB,8BAA8B,CAChD,CAAC,SAAS,qBAAqB,GAAG,qBAAqB,CACzD,SAAQ,yBAAyB,CAAC,CAAC,CAAC;IACR,SAAS,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAMvE,SAAkB,YAAY,SAAS;IACvC,SAAkB,eAAe,EAAE,OAAO,CAAS;IACnD,SAAkB,cAAc,EAAE,OAAO,CAAS;IAElD,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IASzC;;;;;;OAMG;IACH,SAAS,CAAC,aAAa,CAAC,CAAC,SAAS,cAAc,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,GAAE,MAAkB,GAAG,OAAO,CAAC,CAAC,CAAC;CAGzI;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,gCAAgC,GAAG,UAAU,CAAC,OAAO,CAAC,yBAAyB,CAAC,GAAG,CAAC,CAAC,CAAC;AAClG,eAAO,MAAM,gCAAgC,eAA6C,CAAC"}
@@ -0,0 +1,355 @@
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.McpDiagramToolHandlerConstructor = exports.OperationMcpDiagramToolHandler = exports.AbstractMcpDiagramToolHandler = exports.BaseMcpDiagramToolHandler = exports.AbstractMcpToolHandler = exports.BaseMcpToolHandler = exports.McpToolHandler = void 0;
28
+ const server_1 = require("@eclipse-glsp/server");
29
+ const inversify_1 = require("inversify");
30
+ const mcp_handler_shared_1 = require("./mcp-handler-shared");
31
+ const mcp_id_alias_service_1 = require("./mcp-id-alias-service");
32
+ const mcp_label_provider_1 = require("./mcp-label-provider");
33
+ const mcp_request_context_1 = require("./mcp-request-context");
34
+ exports.McpToolHandler = Symbol('McpToolHandler');
35
+ /**
36
+ * Shared infrastructure for both server- and diagram-scope tool handlers — exported so adopters
37
+ * who want to factor common helpers across server-scope and diagram-scope tools can extend a
38
+ * single ancestor instead of duplicating logic. Most adopters extend the more specific siblings
39
+ * ({@link AbstractMcpToolHandler}, {@link AbstractMcpDiagramToolHandler},
40
+ * {@link OperationMcpDiagramToolHandler}); reach for this base only when a helper is genuinely
41
+ * scope-agnostic.
42
+ *
43
+ * @experimental
44
+ */
45
+ let BaseMcpToolHandler = class BaseMcpToolHandler {
46
+ constructor() {
47
+ // ─── Tool annotations (MCP spec: server/tools) ───────────────────────────────
48
+ // Surfaced as flat fields rather than a nested `annotations` object so adopters can
49
+ // override one hint with a one-line `override readonly destructiveHint = true;` instead of
50
+ // re-declaring the whole quartet. **Untrusted** unless from a trusted server — clients
51
+ // MUST treat these as advisory.
52
+ /**
53
+ * Tool does not modify its environment. Defaults to `true` here on the common base;
54
+ * overridden to `false` on {@link OperationMcpDiagramToolHandler} since write-style tools
55
+ * dispatch model-mutating operations.
56
+ */
57
+ this.readOnlyHint = true;
58
+ /**
59
+ * Tool interacts with an "open world" of external entities (web search, external APIs).
60
+ * Default in this codebase: `false` — diagram ops are bounded to the GLSP client. Set
61
+ * `true` for tools that reach off-process.
62
+ */
63
+ this.openWorldHint = false;
64
+ }
65
+ /**
66
+ * SDK-facing registration config; consumed by both the server-scope `registerTool` flow and
67
+ * the launcher's diagram-scope dispatcher. Assembles the {@link ToolAnnotations} object from
68
+ * the flat-field surface so adopters compose annotations via field overrides, not by
69
+ * redeclaring the whole annotations literal.
70
+ */
71
+ toRegistrationConfig() {
72
+ // `.strict()` rejects unknown keys at the SDK boundary instead of silently stripping them
73
+ // — turns an LLM mis-typed field name into a self-correctable JSON-RPC validation error
74
+ // rather than a misleading "no-op success".
75
+ //
76
+ // The `as unknown as ZodObject<ZodRawShape>` bridge is needed because `.strict()` returns
77
+ // a `ZodObject<…, $strict>` whose `$strict` marker generic is not assignable to the
78
+ // shape-only `ZodObject<ZodRawShape>` expected here. The SDK accepts both shapes
79
+ // structurally, so the cast is type-only — no runtime mismatch.
80
+ return {
81
+ title: this.title,
82
+ description: this.description,
83
+ inputSchema: this.inputSchema.strict(),
84
+ outputSchema: this.outputSchema,
85
+ annotations: {
86
+ readOnlyHint: this.readOnlyHint,
87
+ destructiveHint: this.destructiveHint,
88
+ idempotentHint: this.idempotentHint,
89
+ openWorldHint: this.openWorldHint
90
+ }
91
+ };
92
+ }
93
+ error(message, code) {
94
+ return (0, mcp_handler_shared_1.toolErrorResult)(message, code);
95
+ }
96
+ /**
97
+ * Convention: `message` is a short, referenceable summary (ids, types, counts); `structured`
98
+ * carries the full payload. The two complement rather than duplicate — balancing token usage
99
+ * across the heterogeneous client landscape.
100
+ *
101
+ * The MCP spec (2025-06-18) recommends mirroring `structuredContent` into a TextContent
102
+ * block, but in-flight discussion is softening that — `content` and `structuredContent` are
103
+ * increasingly model-oriented vs. machine-oriented surfaces that should be semantically
104
+ * equivalent, not byte-identical.
105
+ *
106
+ * Client behavior is uneven, so summary-in-content + payload-in-structured is a deliberate
107
+ * hedge: some clients only forward `structuredContent`, some only `content`, some forward
108
+ * both verbatim and double the per-call context budget.
109
+ *
110
+ * Pass `structured` whenever {@link outputSchema} is declared (the spec says clients SHOULD
111
+ * validate against the declared shape). Omit for plain text-only responses.
112
+ */
113
+ success(message, structured) {
114
+ return { isError: false, content: [{ type: 'text', text: message }], structuredContent: structured };
115
+ }
116
+ /** Catches `McpToolError` (→ `isError: true` result) and unexpected errors; tags known errors via {@link errorCodeFor}. */
117
+ async execute(producer) {
118
+ try {
119
+ return await producer();
120
+ }
121
+ catch (err) {
122
+ const code = (0, mcp_handler_shared_1.errorCodeFor)(err);
123
+ if (err instanceof mcp_handler_shared_1.McpToolError) {
124
+ return this.error(err.message, code);
125
+ }
126
+ const message = (0, mcp_handler_shared_1.extractErrorMessage)(err);
127
+ // Session-disposed races aren't programming errors — log at warn so they don't drown the error feed.
128
+ if (code === mcp_handler_shared_1.McpToolErrorCodes.SessionDisposed) {
129
+ this.logger.warn(`Session disposed mid-call in tool '${this.name}': ${message}`);
130
+ }
131
+ else {
132
+ this.logger.error(`Unexpected error in tool '${this.name}': ${message}`, err);
133
+ }
134
+ return this.error(message, code);
135
+ }
136
+ }
137
+ };
138
+ exports.BaseMcpToolHandler = BaseMcpToolHandler;
139
+ __decorate([
140
+ (0, inversify_1.inject)(server_1.Logger),
141
+ __metadata("design:type", server_1.Logger)
142
+ ], BaseMcpToolHandler.prototype, "logger", void 0);
143
+ exports.BaseMcpToolHandler = BaseMcpToolHandler = __decorate([
144
+ (0, inversify_1.injectable)()
145
+ ], BaseMcpToolHandler);
146
+ /**
147
+ * Server-scope tool base — for tools that don't target a specific GLSP client session
148
+ * (e.g., listing all sessions). Bound under {@link McpToolHandler} as a server-scope singleton;
149
+ * the launcher invokes `registerTool(server)` once per MCP session.
150
+ *
151
+ * @experimental
152
+ */
153
+ let AbstractMcpToolHandler = class AbstractMcpToolHandler extends BaseMcpToolHandler {
154
+ registerTool(server) {
155
+ server.registerTool(this.name, this.toRegistrationConfig(), async (params, extra) => mcp_request_context_1.mcpRequestContext.run(extra, () => this.execute(() => this.createResult(params))));
156
+ }
157
+ };
158
+ exports.AbstractMcpToolHandler = AbstractMcpToolHandler;
159
+ exports.AbstractMcpToolHandler = AbstractMcpToolHandler = __decorate([
160
+ (0, inversify_1.injectable)()
161
+ ], AbstractMcpToolHandler);
162
+ /**
163
+ * Shared per-session implementation for diagram-scope tool handlers. Adopters don't extend this
164
+ * directly — extend {@link AbstractMcpDiagramToolHandler} (read) or {@link OperationMcpDiagramToolHandler}
165
+ * (write). Exported only as the upper bound for the {@link McpDiagramToolHandlerConstructor}
166
+ * multi-binding.
167
+ *
168
+ * `@inject(...)` fields resolve against the live `ClientSession.container` because instances are
169
+ * created at GLSP-session-open by `McpDiagramToolHandlerRegistryInitializer`.
170
+ *
171
+ * Read-side handlers access `modelState.index` directly. Synchronous reads are atomic, but a
172
+ * concurrent tool that awaits `actionDispatcher.dispatch(...)` may expose a half-committed
173
+ * model — write-then-read tool sequences must serialize the write before the read.
174
+ *
175
+ * @experimental
176
+ */
177
+ let BaseMcpDiagramToolHandler = class BaseMcpDiagramToolHandler extends BaseMcpToolHandler {
178
+ /** Override to opt out of registration when a runtime dependency is missing. Default: `true`. */
179
+ canRegister() {
180
+ return true;
181
+ }
182
+ /** Translates (alias-or-real) ids to real ids; partitions ids absent from the model into `missingIds`. */
183
+ resolveIds(ids) {
184
+ const realIds = [];
185
+ const missingIds = [];
186
+ for (const id of ids) {
187
+ const realId = this.aliasService.lookup(id);
188
+ if (this.modelState.index.find(realId)) {
189
+ realIds.push(realId);
190
+ }
191
+ else {
192
+ missingIds.push(id);
193
+ }
194
+ }
195
+ return { realIds, missingIds };
196
+ }
197
+ /** Like {@link resolveIds} but throws {@link McpElementsNotFoundError} when any input id is absent. */
198
+ resolveExistingIds(ids) {
199
+ if (!ids || ids.length === 0) {
200
+ return [];
201
+ }
202
+ const { realIds, missingIds } = this.resolveIds(ids);
203
+ if (missingIds.length > 0) {
204
+ throw new mcp_handler_shared_1.McpElementsNotFoundError(missingIds);
205
+ }
206
+ return realIds;
207
+ }
208
+ /**
209
+ * Resolves a list of structured inputs against the model: each input's id is looked up via the
210
+ * alias service and the resolved element is retrieved from the index. Throws
211
+ * {@link McpElementsNotFoundError} if any input's id is absent. The returned tuples preserve
212
+ * caller's input/element pairing for downstream processing (e.g. type-checks per kind).
213
+ */
214
+ lookupElements(inputs, extractId) {
215
+ const found = [];
216
+ const missing = [];
217
+ for (const input of inputs) {
218
+ const inputId = extractId(input);
219
+ const realId = this.aliasService.lookup(inputId);
220
+ const element = this.modelState.index.find(realId);
221
+ if (element) {
222
+ found.push([input, element]);
223
+ }
224
+ else {
225
+ missing.push(inputId);
226
+ }
227
+ }
228
+ if (missing.length > 0) {
229
+ throw new mcp_handler_shared_1.McpElementsNotFoundError(missing);
230
+ }
231
+ return found;
232
+ }
233
+ /** Encodes real ids to alias ids (passthrough when {@link NullMcpIdAliasService} is bound). */
234
+ encodeIds(ids) {
235
+ return ids.map(id => this.aliasService.alias(id));
236
+ }
237
+ /**
238
+ * Compact identity for an element — `{ id, elementTypeId, label? }`. Mutating tools (create
239
+ * / modify / delete) echo this so the LLM can refer to the element by label or type in
240
+ * user-facing prose without a follow-up `query-elements` call. Returns `undefined` when
241
+ * the element is no longer in the model (e.g. just deleted).
242
+ */
243
+ describeElement(aliasOrRealId) {
244
+ const realId = this.aliasService.lookup(aliasOrRealId);
245
+ const element = this.modelState.index.find(realId);
246
+ return element ? this.describeResolvedElement(element) : undefined;
247
+ }
248
+ /** Describe an already-resolved {@link GModelElement} — skips the model-lookup round-trip. */
249
+ describeResolvedElement(element) {
250
+ var _a;
251
+ const label = (_a = this.labelProvider.getLabel(element)) === null || _a === void 0 ? void 0 : _a.text;
252
+ // Conditional spread keeps `label` absent (not `undefined`) when the element has none —
253
+ // matches Zod's `.optional()` semantics so the structured payload is clean.
254
+ return { id: this.aliasService.alias(element.id), elementTypeId: element.type, ...(label !== undefined ? { label } : {}) };
255
+ }
256
+ };
257
+ exports.BaseMcpDiagramToolHandler = BaseMcpDiagramToolHandler;
258
+ __decorate([
259
+ (0, inversify_1.inject)(server_1.ClientId),
260
+ __metadata("design:type", String)
261
+ ], BaseMcpDiagramToolHandler.prototype, "clientId", void 0);
262
+ __decorate([
263
+ (0, inversify_1.inject)(server_1.ModelState),
264
+ __metadata("design:type", Object)
265
+ ], BaseMcpDiagramToolHandler.prototype, "modelState", void 0);
266
+ __decorate([
267
+ (0, inversify_1.inject)(mcp_id_alias_service_1.McpIdAliasService),
268
+ __metadata("design:type", Object)
269
+ ], BaseMcpDiagramToolHandler.prototype, "aliasService", void 0);
270
+ __decorate([
271
+ (0, inversify_1.inject)(mcp_label_provider_1.McpLabelProvider),
272
+ __metadata("design:type", Object)
273
+ ], BaseMcpDiagramToolHandler.prototype, "labelProvider", void 0);
274
+ exports.BaseMcpDiagramToolHandler = BaseMcpDiagramToolHandler = __decorate([
275
+ (0, inversify_1.injectable)()
276
+ ], BaseMcpDiagramToolHandler);
277
+ /**
278
+ * Diagram-scope tool base for **query-style** tools that read the model without mutating it
279
+ * (validate, get-selection, set-view, query-elements). Sibling of
280
+ * {@link OperationMcpDiagramToolHandler} — extend that one when the tool dispatches a
281
+ * model-mutating Operation.
282
+ *
283
+ * @experimental
284
+ */
285
+ let AbstractMcpDiagramToolHandler = class AbstractMcpDiagramToolHandler extends BaseMcpDiagramToolHandler {
286
+ handle(params) {
287
+ return this.execute(() => this.createResult(params));
288
+ }
289
+ };
290
+ exports.AbstractMcpDiagramToolHandler = AbstractMcpDiagramToolHandler;
291
+ exports.AbstractMcpDiagramToolHandler = AbstractMcpDiagramToolHandler = __decorate([
292
+ (0, inversify_1.injectable)()
293
+ ], AbstractMcpDiagramToolHandler);
294
+ /**
295
+ * Diagram-scope tool base for **operation-style** tools that mutate the model by dispatching a
296
+ * GLSP `Operation` (or other model-mutating `Action` like `UndoAction` / `RedoAction`) on
297
+ * behalf of the LLM — create, modify, delete, undo, redo. Sibling of
298
+ * {@link AbstractMcpDiagramToolHandler}.
299
+ *
300
+ * The base bakes in two pieces beyond the read sibling:
301
+ * - `@inject(ActionDispatcher)`. Every adopter extending this base dispatches, so the
302
+ * dispatcher belongs on the base, not in per-handler boilerplate.
303
+ * - Throws {@link McpReadOnlyError} when `modelState.isReadonly`, surfacing a hard failure
304
+ * to the LLM. The MCP-side gate is necessary even though core's `OperationActionHandler`
305
+ * checks readonly itself: core's gate is a *soft* warning (returns a `MessageAction`, the
306
+ * dispatch resolves successfully and the tool body would otherwise report success while
307
+ * nothing changed), and `UndoRedoActionHandler` doesn't gate readonly at all.
308
+ *
309
+ * Parallels core's `OperationHandler` (sibling to `ActionHandler`, not a refinement) — but
310
+ * note the role flip: core's `OperationHandler` is downstream of dispatch and only needs
311
+ * `ModelState`; ours is upstream of dispatch (the LLM-side handler that triggers the Operation)
312
+ * and so additionally injects `ActionDispatcher`.
313
+ *
314
+ * @experimental
315
+ */
316
+ let OperationMcpDiagramToolHandler = class OperationMcpDiagramToolHandler extends BaseMcpDiagramToolHandler {
317
+ constructor() {
318
+ super(...arguments);
319
+ // Operation tools mutate the model — flip the read defaults. Concrete handlers override
320
+ // `destructiveHint` / `idempotentHint` (one line each) where it applies; the explicit `false`
321
+ // defaults below override the MCP spec's "true if unset" semantics so non-destructive,
322
+ // non-idempotent writes don't trigger overzealous client-side confirmation prompts.
323
+ this.readOnlyHint = false;
324
+ this.destructiveHint = false;
325
+ this.idempotentHint = false;
326
+ }
327
+ handle(params) {
328
+ return this.execute(() => {
329
+ if (this.modelState.isReadonly) {
330
+ throw new mcp_handler_shared_1.McpReadOnlyError();
331
+ }
332
+ return this.createResult(params);
333
+ });
334
+ }
335
+ /**
336
+ * Convenience for tools that initiate a `RequestAction` round-trip (rather than the
337
+ * fire-and-forget operation dispatch this base is named for) — wraps
338
+ * {@link requestActionOrFail} with `this.actionDispatcher` and a default label of
339
+ * `this.name`. Pass an explicit label only when the tool handles multiple distinct
340
+ * round-trips and wants to disambiguate them in error messages.
341
+ */
342
+ requestAction(request, timeoutMs, label = this.name) {
343
+ return (0, mcp_handler_shared_1.requestActionOrFail)(this.actionDispatcher, request, timeoutMs, label);
344
+ }
345
+ };
346
+ exports.OperationMcpDiagramToolHandler = OperationMcpDiagramToolHandler;
347
+ __decorate([
348
+ (0, inversify_1.inject)(server_1.ActionDispatcher),
349
+ __metadata("design:type", Object)
350
+ ], OperationMcpDiagramToolHandler.prototype, "actionDispatcher", void 0);
351
+ exports.OperationMcpDiagramToolHandler = OperationMcpDiagramToolHandler = __decorate([
352
+ (0, inversify_1.injectable)()
353
+ ], OperationMcpDiagramToolHandler);
354
+ exports.McpDiagramToolHandlerConstructor = Symbol('McpDiagramToolHandlerConstructor');
355
+ //# sourceMappingURL=mcp-tool-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-tool-handler.js","sourceRoot":"","sources":["../../src/server/mcp-tool-handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;;;;AAElF,iDAS8B;AAE9B,yCAA2D;AAG3D,6DAY8B;AAC9B,iEAA2D;AAE3D,6DAAwD;AACxD,+DAA0D;AAiB7C,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEvD;;;;;;;;;GASG;AAEI,IAAe,kBAAkB,GAAjC,MAAe,kBAAkB;IAAjC;QAuBH,gFAAgF;QAChF,oFAAoF;QACpF,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