@structured-world/gitlab-mcp 10.1.0 → 12.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (387) hide show
  1. package/README.md +8 -8
  2. package/README.md.in +2 -2
  3. package/dist/src/accounts/chat-accounts.d.ts +17 -0
  4. package/dist/src/accounts/chat-accounts.js +245 -0
  5. package/dist/src/accounts/chat-accounts.js.map +1 -0
  6. package/dist/src/accounts/instance-tokens.d.ts +2 -0
  7. package/dist/src/accounts/instance-tokens.js +43 -0
  8. package/dist/src/accounts/instance-tokens.js.map +1 -0
  9. package/dist/src/accounts/link.d.ts +16 -0
  10. package/dist/src/accounts/link.js +469 -0
  11. package/dist/src/accounts/link.js.map +1 -0
  12. package/dist/src/accounts/token-account.d.ts +6 -0
  13. package/dist/src/accounts/token-account.js +13 -0
  14. package/dist/src/accounts/token-account.js.map +1 -0
  15. package/dist/src/channel-gateway/format.js +7 -1
  16. package/dist/src/channel-gateway/format.js.map +1 -1
  17. package/dist/src/channel-gateway/forwarding.d.ts +3 -0
  18. package/dist/src/channel-gateway/forwarding.js +8 -1
  19. package/dist/src/channel-gateway/forwarding.js.map +1 -1
  20. package/dist/src/channel-gateway/gateway.d.ts +7 -0
  21. package/dist/src/channel-gateway/gateway.js +80 -16
  22. package/dist/src/channel-gateway/gateway.js.map +1 -1
  23. package/dist/src/cli/docker/container-runtime.d.ts +1 -0
  24. package/dist/src/cli/docker/container-runtime.js +37 -5
  25. package/dist/src/cli/docker/container-runtime.js.map +1 -1
  26. package/dist/src/cli/docker/docker-command.js +11 -2
  27. package/dist/src/cli/docker/docker-command.js.map +1 -1
  28. package/dist/src/cli/docker/docker-utils.d.ts +1 -0
  29. package/dist/src/cli/docker/docker-utils.js +137 -27
  30. package/dist/src/cli/docker/docker-utils.js.map +1 -1
  31. package/dist/src/cli/docker/oauth-issuer-prompt.d.ts +2 -0
  32. package/dist/src/cli/docker/oauth-issuer-prompt.js +47 -0
  33. package/dist/src/cli/docker/oauth-issuer-prompt.js.map +1 -0
  34. package/dist/src/cli/docker/types.d.ts +18 -4
  35. package/dist/src/cli/docker/types.js.map +1 -1
  36. package/dist/src/cli/init/config-generator.d.ts +3 -2
  37. package/dist/src/cli/init/config-generator.js +15 -0
  38. package/dist/src/cli/init/config-generator.js.map +1 -1
  39. package/dist/src/cli/init/types.d.ts +7 -2
  40. package/dist/src/cli/init/types.js +9 -0
  41. package/dist/src/cli/init/types.js.map +1 -1
  42. package/dist/src/cli/init/wizard.js +31 -1
  43. package/dist/src/cli/init/wizard.js.map +1 -1
  44. package/dist/src/cli/install/codex.d.ts +25 -0
  45. package/dist/src/cli/install/codex.js +261 -0
  46. package/dist/src/cli/install/codex.js.map +1 -0
  47. package/dist/src/cli/install/detector.js +22 -0
  48. package/dist/src/cli/install/detector.js.map +1 -1
  49. package/dist/src/cli/install/index.d.ts +2 -1
  50. package/dist/src/cli/install/index.js +3 -1
  51. package/dist/src/cli/install/index.js.map +1 -1
  52. package/dist/src/cli/install/install-command.d.ts +5 -2
  53. package/dist/src/cli/install/install-command.js +52 -8
  54. package/dist/src/cli/install/install-command.js.map +1 -1
  55. package/dist/src/cli/install/installers.d.ts +8 -8
  56. package/dist/src/cli/install/installers.js +18 -3
  57. package/dist/src/cli/install/installers.js.map +1 -1
  58. package/dist/src/cli/install/notes.d.ts +2 -0
  59. package/dist/src/cli/install/notes.js +8 -0
  60. package/dist/src/cli/install/notes.js.map +1 -0
  61. package/dist/src/cli/install/types.d.ts +1 -0
  62. package/dist/src/cli/install/types.js +12 -0
  63. package/dist/src/cli/install/types.js.map +1 -1
  64. package/dist/src/cli/list-tools.js +14 -35
  65. package/dist/src/cli/list-tools.js.map +1 -1
  66. package/dist/src/cli/plugin/build.d.ts +23 -0
  67. package/dist/src/cli/plugin/build.js +165 -0
  68. package/dist/src/cli/plugin/build.js.map +1 -0
  69. package/dist/src/cli/plugin/command.d.ts +4 -0
  70. package/dist/src/cli/plugin/command.js +89 -0
  71. package/dist/src/cli/plugin/command.js.map +1 -0
  72. package/dist/src/cli/plugin/index.d.ts +5 -0
  73. package/dist/src/cli/plugin/index.js +15 -0
  74. package/dist/src/cli/plugin/index.js.map +1 -0
  75. package/dist/src/cli/plugin/listing.d.ts +21 -0
  76. package/dist/src/cli/plugin/listing.js +44 -0
  77. package/dist/src/cli/plugin/listing.js.map +1 -0
  78. package/dist/src/cli/plugin/validate.d.ts +21 -0
  79. package/dist/src/cli/plugin/validate.js +496 -0
  80. package/dist/src/cli/plugin/validate.js.map +1 -0
  81. package/dist/src/cli/plugin/zip.d.ts +6 -0
  82. package/dist/src/cli/plugin/zip.js +83 -0
  83. package/dist/src/cli/plugin/zip.js.map +1 -0
  84. package/dist/src/cli/setup/flows/configure-existing.js +5 -0
  85. package/dist/src/cli/setup/flows/configure-existing.js.map +1 -1
  86. package/dist/src/cli/setup/flows/local-setup.js +3 -0
  87. package/dist/src/cli/setup/flows/local-setup.js.map +1 -1
  88. package/dist/src/cli/setup/flows/server-setup.js +15 -0
  89. package/dist/src/cli/setup/flows/server-setup.js.map +1 -1
  90. package/dist/src/cli-utils.d.ts +2 -0
  91. package/dist/src/cli-utils.js +6 -0
  92. package/dist/src/cli-utils.js.map +1 -1
  93. package/dist/src/config/instances-loader.js +17 -3
  94. package/dist/src/config/instances-loader.js.map +1 -1
  95. package/dist/src/config/instances-schema.d.ts +8 -3
  96. package/dist/src/config/instances-schema.js +12 -6
  97. package/dist/src/config/instances-schema.js.map +1 -1
  98. package/dist/src/config.js.map +1 -1
  99. package/dist/src/configuration/caller.d.ts +10 -0
  100. package/dist/src/configuration/caller.js +39 -0
  101. package/dist/src/configuration/caller.js.map +1 -0
  102. package/dist/src/configuration/composed-feeds.d.ts +31 -0
  103. package/dist/src/configuration/composed-feeds.js +698 -0
  104. package/dist/src/configuration/composed-feeds.js.map +1 -0
  105. package/dist/src/configuration/composed-listings.d.ts +14 -0
  106. package/dist/src/configuration/composed-listings.js +157 -0
  107. package/dist/src/configuration/composed-listings.js.map +1 -0
  108. package/dist/src/configuration/groups.d.ts +8 -0
  109. package/dist/src/configuration/groups.js +39 -0
  110. package/dist/src/configuration/groups.js.map +1 -0
  111. package/dist/src/configuration/index.d.ts +6 -0
  112. package/dist/src/configuration/index.js +87 -0
  113. package/dist/src/configuration/index.js.map +1 -0
  114. package/dist/src/configuration/policy.d.ts +34 -0
  115. package/dist/src/configuration/policy.js +122 -0
  116. package/dist/src/configuration/policy.js.map +1 -0
  117. package/dist/src/configuration/scope-ids.d.ts +7 -0
  118. package/dist/src/configuration/scope-ids.js +78 -0
  119. package/dist/src/configuration/scope-ids.js.map +1 -0
  120. package/dist/src/configuration/scope-projects.d.ts +5 -0
  121. package/dist/src/configuration/scope-projects.js +76 -0
  122. package/dist/src/configuration/scope-projects.js.map +1 -0
  123. package/dist/src/configuration/scope-targets.d.ts +26 -0
  124. package/dist/src/configuration/scope-targets.js +307 -0
  125. package/dist/src/configuration/scope-targets.js.map +1 -0
  126. package/dist/src/configuration/scoped-execution.d.ts +6 -0
  127. package/dist/src/configuration/scoped-execution.js +577 -0
  128. package/dist/src/configuration/scoped-execution.js.map +1 -0
  129. package/dist/src/configuration/scoped-feeds.d.ts +22 -0
  130. package/dist/src/configuration/scoped-feeds.js +136 -0
  131. package/dist/src/configuration/scoped-feeds.js.map +1 -0
  132. package/dist/src/configuration/service.d.ts +52 -0
  133. package/dist/src/configuration/service.js +169 -0
  134. package/dist/src/configuration/service.js.map +1 -0
  135. package/dist/src/configuration/settings-store.d.ts +20 -0
  136. package/dist/src/configuration/settings-store.js +228 -0
  137. package/dist/src/configuration/settings-store.js.map +1 -0
  138. package/dist/src/configuration/types.d.ts +30 -0
  139. package/dist/src/configuration/types.js +20 -0
  140. package/dist/src/configuration/types.js.map +1 -0
  141. package/dist/src/contracts/storage.d.ts +3 -2
  142. package/dist/src/dashboard/html-template.js +8 -15
  143. package/dist/src/dashboard/html-template.js.map +1 -1
  144. package/dist/src/dashboard/metrics.d.ts +1 -1
  145. package/dist/src/entities/context/accounts.d.ts +19 -0
  146. package/dist/src/entities/context/accounts.js +115 -0
  147. package/dist/src/entities/context/accounts.js.map +1 -0
  148. package/dist/src/entities/context/connection-check.d.ts +64 -0
  149. package/dist/src/entities/context/connection-check.js +117 -0
  150. package/dist/src/entities/context/connection-check.js.map +1 -0
  151. package/dist/src/entities/context/context-manager.d.ts +10 -23
  152. package/dist/src/entities/context/context-manager.js +101 -282
  153. package/dist/src/entities/context/context-manager.js.map +1 -1
  154. package/dist/src/entities/context/handlers.d.ts +5 -5
  155. package/dist/src/entities/context/handlers.js +11 -14
  156. package/dist/src/entities/context/handlers.js.map +1 -1
  157. package/dist/src/entities/context/output-schema.d.ts +320 -0
  158. package/dist/src/entities/context/output-schema.js +210 -0
  159. package/dist/src/entities/context/output-schema.js.map +1 -0
  160. package/dist/src/entities/context/profile.d.ts +29 -0
  161. package/dist/src/entities/context/profile.js +72 -0
  162. package/dist/src/entities/context/profile.js.map +1 -0
  163. package/dist/src/entities/context/registry.js +140 -3
  164. package/dist/src/entities/context/registry.js.map +1 -1
  165. package/dist/src/entities/context/schema.d.ts +32 -14
  166. package/dist/src/entities/context/schema.js +36 -13
  167. package/dist/src/entities/context/schema.js.map +1 -1
  168. package/dist/src/entities/context/scope-search.d.ts +49 -0
  169. package/dist/src/entities/context/scope-search.js +71 -0
  170. package/dist/src/entities/context/scope-search.js.map +1 -0
  171. package/dist/src/entities/context/settings-panel.d.ts +13 -0
  172. package/dist/src/entities/context/settings-panel.js +508 -0
  173. package/dist/src/entities/context/settings-panel.js.map +1 -0
  174. package/dist/src/entities/context/settings.d.ts +78 -0
  175. package/dist/src/entities/context/settings.js +239 -0
  176. package/dist/src/entities/context/settings.js.map +1 -0
  177. package/dist/src/entities/context/types.d.ts +3 -4
  178. package/dist/src/entities/context/whoami.js +39 -31
  179. package/dist/src/entities/context/whoami.js.map +1 -1
  180. package/dist/src/entities/core/registry.js +34 -33
  181. package/dist/src/entities/core/registry.js.map +1 -1
  182. package/dist/src/entities/core/schema-readonly.d.ts +4 -4
  183. package/dist/src/entities/environments/schema-readonly.d.ts +4 -4
  184. package/dist/src/entities/files/registry.js +3 -2
  185. package/dist/src/entities/files/registry.js.map +1 -1
  186. package/dist/src/entities/iterations/registry.js +3 -2
  187. package/dist/src/entities/iterations/registry.js.map +1 -1
  188. package/dist/src/entities/mrs/registry.js +6 -4
  189. package/dist/src/entities/mrs/registry.js.map +1 -1
  190. package/dist/src/entities/mrs/schema-readonly.d.ts +2 -2
  191. package/dist/src/entities/mrs/schema-readonly.js +19 -2
  192. package/dist/src/entities/mrs/schema-readonly.js.map +1 -1
  193. package/dist/src/entities/mrs/schema.d.ts +1 -1
  194. package/dist/src/entities/pipelines/registry.js +23 -31
  195. package/dist/src/entities/pipelines/registry.js.map +1 -1
  196. package/dist/src/entities/pipelines/schema-readonly.d.ts +11 -11
  197. package/dist/src/entities/pipelines/schema-readonly.js +5 -2
  198. package/dist/src/entities/pipelines/schema-readonly.js.map +1 -1
  199. package/dist/src/entities/pipelines/trace.d.ts +20 -0
  200. package/dist/src/entities/pipelines/trace.js +156 -0
  201. package/dist/src/entities/pipelines/trace.js.map +1 -0
  202. package/dist/src/entities/runners/project-access.d.ts +14 -0
  203. package/dist/src/entities/runners/project-access.js +64 -0
  204. package/dist/src/entities/runners/project-access.js.map +1 -0
  205. package/dist/src/entities/runners/registry.js +54 -26
  206. package/dist/src/entities/runners/registry.js.map +1 -1
  207. package/dist/src/entities/search/schema-readonly.d.ts +28 -28
  208. package/dist/src/graphql/runners.d.ts +26 -1
  209. package/dist/src/graphql/runners.js +43 -6
  210. package/dist/src/graphql/runners.js.map +1 -1
  211. package/dist/src/graphql/vulnerabilities.d.ts +3 -0
  212. package/dist/src/graphql/vulnerabilities.js +1 -0
  213. package/dist/src/graphql/vulnerabilities.js.map +1 -1
  214. package/dist/src/handlers.js +351 -190
  215. package/dist/src/handlers.js.map +1 -1
  216. package/dist/src/main.js +23 -5
  217. package/dist/src/main.js.map +1 -1
  218. package/dist/src/mcp-apps.d.ts +6 -0
  219. package/dist/src/mcp-apps.js +8 -0
  220. package/dist/src/mcp-apps.js.map +1 -0
  221. package/dist/src/mcp-server-context.d.ts +3 -0
  222. package/dist/src/mcp-server-context.js +13 -0
  223. package/dist/src/mcp-server-context.js.map +1 -0
  224. package/dist/src/middleware/mcp-auth-routes.d.ts +3 -0
  225. package/dist/src/middleware/mcp-auth-routes.js +9 -0
  226. package/dist/src/middleware/mcp-auth-routes.js.map +1 -0
  227. package/dist/src/middleware/oauth-auth.js +87 -24
  228. package/dist/src/middleware/oauth-auth.js.map +1 -1
  229. package/dist/src/middleware/rate-limiter.js +11 -10
  230. package/dist/src/middleware/rate-limiter.js.map +1 -1
  231. package/dist/src/oauth/authorization-response.d.ts +1 -0
  232. package/dist/src/oauth/authorization-response.js +14 -0
  233. package/dist/src/oauth/authorization-response.js.map +1 -0
  234. package/dist/src/oauth/client-auth.d.ts +16 -0
  235. package/dist/src/oauth/client-auth.js +73 -0
  236. package/dist/src/oauth/client-auth.js.map +1 -0
  237. package/dist/src/oauth/code-exchange.d.ts +7 -0
  238. package/dist/src/oauth/code-exchange.js +38 -0
  239. package/dist/src/oauth/code-exchange.js.map +1 -0
  240. package/dist/src/oauth/config.d.ts +2 -0
  241. package/dist/src/oauth/config.js +37 -0
  242. package/dist/src/oauth/config.js.map +1 -1
  243. package/dist/src/oauth/endpoints/authorize.d.ts +1 -0
  244. package/dist/src/oauth/endpoints/authorize.js +361 -102
  245. package/dist/src/oauth/endpoints/authorize.js.map +1 -1
  246. package/dist/src/oauth/endpoints/callback.js +76 -41
  247. package/dist/src/oauth/endpoints/callback.js.map +1 -1
  248. package/dist/src/oauth/endpoints/index.d.ts +1 -0
  249. package/dist/src/oauth/endpoints/index.js +3 -1
  250. package/dist/src/oauth/endpoints/index.js.map +1 -1
  251. package/dist/src/oauth/endpoints/metadata.d.ts +1 -1
  252. package/dist/src/oauth/endpoints/metadata.js +23 -8
  253. package/dist/src/oauth/endpoints/metadata.js.map +1 -1
  254. package/dist/src/oauth/endpoints/register.d.ts +3 -2
  255. package/dist/src/oauth/endpoints/register.js +70 -19
  256. package/dist/src/oauth/endpoints/register.js.map +1 -1
  257. package/dist/src/oauth/endpoints/revoke.d.ts +2 -0
  258. package/dist/src/oauth/endpoints/revoke.js +78 -0
  259. package/dist/src/oauth/endpoints/revoke.js.map +1 -0
  260. package/dist/src/oauth/endpoints/token.js +136 -62
  261. package/dist/src/oauth/endpoints/token.js.map +1 -1
  262. package/dist/src/oauth/gitlab-device-flow.d.ts +27 -8
  263. package/dist/src/oauth/gitlab-device-flow.js +119 -57
  264. package/dist/src/oauth/gitlab-device-flow.js.map +1 -1
  265. package/dist/src/oauth/gitlab-request-bound.d.ts +1 -0
  266. package/dist/src/oauth/gitlab-request-bound.js +6 -0
  267. package/dist/src/oauth/gitlab-request-bound.js.map +1 -0
  268. package/dist/src/oauth/gitlab-token-refresh.d.ts +7 -0
  269. package/dist/src/oauth/gitlab-token-refresh.js +147 -0
  270. package/dist/src/oauth/gitlab-token-refresh.js.map +1 -0
  271. package/dist/src/oauth/grant-revocation.d.ts +10 -0
  272. package/dist/src/oauth/grant-revocation.js +179 -0
  273. package/dist/src/oauth/grant-revocation.js.map +1 -0
  274. package/dist/src/oauth/granted-scopes.d.ts +1 -0
  275. package/dist/src/oauth/granted-scopes.js +7 -0
  276. package/dist/src/oauth/granted-scopes.js.map +1 -0
  277. package/dist/src/oauth/index.d.ts +2 -2
  278. package/dist/src/oauth/index.js +4 -2
  279. package/dist/src/oauth/index.js.map +1 -1
  280. package/dist/src/oauth/instance-app.d.ts +4 -0
  281. package/dist/src/oauth/instance-app.js +45 -0
  282. package/dist/src/oauth/instance-app.js.map +1 -0
  283. package/dist/src/oauth/issued-tokens.d.ts +1 -0
  284. package/dist/src/oauth/issued-tokens.js +24 -0
  285. package/dist/src/oauth/issued-tokens.js.map +1 -0
  286. package/dist/src/oauth/oauth-app.d.ts +9 -0
  287. package/dist/src/oauth/oauth-app.js +14 -0
  288. package/dist/src/oauth/oauth-app.js.map +1 -0
  289. package/dist/src/oauth/request-params.d.ts +1 -0
  290. package/dist/src/oauth/request-params.js +17 -0
  291. package/dist/src/oauth/request-params.js.map +1 -0
  292. package/dist/src/oauth/resource.d.ts +12 -0
  293. package/dist/src/oauth/resource.js +66 -0
  294. package/dist/src/oauth/resource.js.map +1 -0
  295. package/dist/src/oauth/routes.d.ts +2 -0
  296. package/dist/src/oauth/routes.js +31 -0
  297. package/dist/src/oauth/routes.js.map +1 -0
  298. package/dist/src/oauth/session-store.d.ts +51 -36
  299. package/dist/src/oauth/session-store.js +156 -251
  300. package/dist/src/oauth/session-store.js.map +1 -1
  301. package/dist/src/oauth/storage/factory.js +1 -1
  302. package/dist/src/oauth/storage/factory.js.map +1 -1
  303. package/dist/src/oauth/storage/file.d.ts +29 -2
  304. package/dist/src/oauth/storage/file.js +194 -42
  305. package/dist/src/oauth/storage/file.js.map +1 -1
  306. package/dist/src/oauth/storage/memory.d.ts +35 -2
  307. package/dist/src/oauth/storage/memory.js +327 -32
  308. package/dist/src/oauth/storage/memory.js.map +1 -1
  309. package/dist/src/oauth/storage/types.d.ts +37 -1
  310. package/dist/src/oauth/storage/types.js +6 -1
  311. package/dist/src/oauth/storage/types.js.map +1 -1
  312. package/dist/src/oauth/tool-auth.d.ts +12 -0
  313. package/dist/src/oauth/tool-auth.js +108 -0
  314. package/dist/src/oauth/tool-auth.js.map +1 -0
  315. package/dist/src/oauth/types.d.ts +41 -0
  316. package/dist/src/profiles/scope-enforcer.d.ts +8 -0
  317. package/dist/src/profiles/scope-enforcer.js +86 -24
  318. package/dist/src/profiles/scope-enforcer.js.map +1 -1
  319. package/dist/src/profiles/types.js +4 -1
  320. package/dist/src/profiles/types.js.map +1 -1
  321. package/dist/src/registry-manager.d.ts +16 -4
  322. package/dist/src/registry-manager.js +122 -33
  323. package/dist/src/registry-manager.js.map +1 -1
  324. package/dist/src/server.js +82 -50
  325. package/dist/src/server.js.map +1 -1
  326. package/dist/src/services/AdminDetector.d.ts +1 -1
  327. package/dist/src/services/AdminDetector.js +4 -4
  328. package/dist/src/services/AdminDetector.js.map +1 -1
  329. package/dist/src/services/ConnectionManager.d.ts +2 -2
  330. package/dist/src/services/ConnectionManager.js +43 -70
  331. package/dist/src/services/ConnectionManager.js.map +1 -1
  332. package/dist/src/services/HealthMonitor.js +4 -2
  333. package/dist/src/services/HealthMonitor.js.map +1 -1
  334. package/dist/src/services/NamespaceTierDetector.js +26 -27
  335. package/dist/src/services/NamespaceTierDetector.js.map +1 -1
  336. package/dist/src/services/TokenScopeDetector.d.ts +6 -2
  337. package/dist/src/services/TokenScopeDetector.js +22 -3
  338. package/dist/src/services/TokenScopeDetector.js.map +1 -1
  339. package/dist/src/session-manager.d.ts +3 -1
  340. package/dist/src/session-manager.js +43 -10
  341. package/dist/src/session-manager.js.map +1 -1
  342. package/dist/src/types.d.ts +3 -2
  343. package/dist/src/types.js.map +1 -1
  344. package/dist/src/utils/bounded-map.d.ts +1 -0
  345. package/dist/src/utils/bounded-map.js +23 -0
  346. package/dist/src/utils/bounded-map.js.map +1 -0
  347. package/dist/src/utils/fetch.d.ts +1 -2
  348. package/dist/src/utils/fetch.js +12 -17
  349. package/dist/src/utils/fetch.js.map +1 -1
  350. package/dist/src/utils/gitlab-api.js +2 -1
  351. package/dist/src/utils/gitlab-api.js.map +1 -1
  352. package/dist/src/utils/gitlab-base-url.d.ts +2 -0
  353. package/dist/src/utils/gitlab-base-url.js +34 -0
  354. package/dist/src/utils/gitlab-base-url.js.map +1 -0
  355. package/dist/src/utils/html.d.ts +1 -0
  356. package/dist/src/utils/html.js +12 -0
  357. package/dist/src/utils/html.js.map +1 -0
  358. package/dist/src/utils/namespace.d.ts +1 -0
  359. package/dist/src/utils/namespace.js +72 -24
  360. package/dist/src/utils/namespace.js.map +1 -1
  361. package/dist/src/utils/schema-utils.d.ts +5 -3
  362. package/dist/src/utils/schema-utils.js +50 -22
  363. package/dist/src/utils/schema-utils.js.map +1 -1
  364. package/dist/src/utils/smart-user-search.js +2 -1
  365. package/dist/src/utils/smart-user-search.js.map +1 -1
  366. package/dist/src/utils/sync-directory.d.ts +1 -0
  367. package/dist/src/utils/sync-directory.js +49 -0
  368. package/dist/src/utils/sync-directory.js.map +1 -0
  369. package/dist/src/utils/tool-result.d.ts +4 -0
  370. package/dist/src/utils/tool-result.js +41 -0
  371. package/dist/src/utils/tool-result.js.map +1 -0
  372. package/dist/tsconfig.build.tsbuildinfo +1 -1
  373. package/package.json +74 -21
  374. package/plugin/assets/composer-icon-dark.png +0 -0
  375. package/plugin/assets/composer-icon-dark.svg +17 -0
  376. package/plugin/assets/composer-icon.png +0 -0
  377. package/plugin/assets/composer-icon.svg +17 -0
  378. package/plugin/assets/logo.png +0 -0
  379. package/plugin/assets/screenshot-1.png +0 -0
  380. package/plugin/assets/screenshot-2.png +0 -0
  381. package/plugin/schemas/mcp.schema.json +120 -0
  382. package/plugin/schemas/plugin.schema.json +65 -0
  383. package/skills/gitlab-ci/SKILL.md +16 -0
  384. package/skills/gitlab-discovery/SKILL.md +15 -0
  385. package/skills/gitlab-review/SKILL.md +16 -0
  386. package/skills/gitlab-setup/SKILL.md +16 -0
  387. package/skills/gitlab-work-items/SKILL.md +16 -0
@@ -36,6 +36,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.resetHandlersState = resetHandlersState;
37
37
  exports.setupHandlers = setupHandlers;
38
38
  const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
39
+ const settings_panel_1 = require("./entities/context/settings-panel");
40
+ const mcp_apps_1 = require("./mcp-apps");
39
41
  const ConnectionManager_1 = require("./services/ConnectionManager");
40
42
  const HealthMonitor_1 = require("./services/HealthMonitor");
41
43
  const url_1 = require("./utils/url");
@@ -44,6 +46,16 @@ const error_handler_1 = require("./utils/error-handler");
44
46
  const fetch_1 = require("./utils/fetch");
45
47
  const index_1 = require("./logging/index");
46
48
  const config_1 = require("./config");
49
+ const schema_utils_1 = require("./utils/schema-utils");
50
+ const tool_result_1 = require("./utils/tool-result");
51
+ const tool_auth_1 = require("./oauth/tool-auth");
52
+ const chat_accounts_1 = require("./accounts/chat-accounts");
53
+ const mcp_server_context_1 = require("./mcp-server-context");
54
+ const token_account_1 = require("./accounts/token-account");
55
+ const configuration_1 = require("./configuration");
56
+ const policy_1 = require("./configuration/policy");
57
+ const scoped_execution_1 = require("./configuration/scoped-execution");
58
+ const scope_ids_1 = require("./configuration/scope-ids");
47
59
  function hasAction(value) {
48
60
  return (typeof value === 'object' &&
49
61
  value !== null &&
@@ -74,14 +86,15 @@ function recordEarlyReturnError(toolName, action, errorMessage) {
74
86
  }
75
87
  }
76
88
  }
77
- function isIdempotentOperation(toolName) {
89
+ function isIdempotentOperation(toolName, declared) {
90
+ if (declared !== undefined)
91
+ return declared;
78
92
  return (toolName.startsWith('browse_') ||
79
93
  toolName.startsWith('list_') ||
80
94
  toolName.startsWith('get_') ||
81
- toolName.startsWith('download_') ||
82
- toolName === 'manage_context');
95
+ toolName.startsWith('download_'));
83
96
  }
84
- function toStructuredError(error, toolName, toolArgs) {
97
+ function toStructuredError(error, toolName, toolArgs, declaredIdempotent) {
85
98
  if ((0, error_handler_1.isStructuredToolError)(error)) {
86
99
  return error.structuredError;
87
100
  }
@@ -101,13 +114,13 @@ function toStructuredError(error, toolName, toolArgs) {
101
114
  error.name === 'GitLabTimeoutError' &&
102
115
  'timeoutMs' in error &&
103
116
  typeof error.timeoutMs === 'number')) {
104
- const retryable = isIdempotentOperation(toolName);
117
+ const retryable = isIdempotentOperation(toolName, declaredIdempotent);
105
118
  return (0, error_handler_1.createTimeoutError)(toolName, action, error.timeoutMs, retryable);
106
119
  }
107
120
  if (error instanceof Error) {
108
121
  const timeoutMs = (0, error_handler_1.parseTimeoutError)(error.message);
109
122
  if (timeoutMs !== null) {
110
- const retryable = isIdempotentOperation(toolName);
123
+ const retryable = isIdempotentOperation(toolName, declaredIdempotent);
111
124
  return (0, error_handler_1.createTimeoutError)(toolName, action, timeoutMs, retryable);
112
125
  }
113
126
  }
@@ -117,7 +130,8 @@ function toStructuredError(error, toolName, toolArgs) {
117
130
  return (0, error_handler_1.handleGitLabError)({ status: parsed.status, message: parsed.message }, toolName, action, toolArgs);
118
131
  }
119
132
  function checkUnreachableInstance(toolName, toolArguments, effectiveInstanceUrl, healthMonitor) {
120
- if (healthMonitor.isInstanceReachable(effectiveInstanceUrl) || toolName === 'manage_context') {
133
+ if (healthMonitor.isInstanceReachable(effectiveInstanceUrl) ||
134
+ policy_1.CONFIGURATION_TOOLS.has(toolName)) {
121
135
  return null;
122
136
  }
123
137
  const action = toolArguments && typeof toolArguments.action === 'string' ? toolArguments.action : 'unknown';
@@ -134,37 +148,26 @@ function checkUnreachableInstance(toolName, toolArguments, effectiveInstanceUrl,
134
148
  }
135
149
  const connError = (0, error_handler_1.createConnectionFailedError)(toolName, action, effectiveInstanceUrl, connectionState);
136
150
  recordEarlyReturnError(toolName, action, connError.message);
137
- return { content: [{ type: 'text', text: JSON.stringify(connError, null, 2) }], isError: true };
151
+ return (0, tool_result_1.errorToolResult)(connError);
138
152
  }
139
- async function resyncSessionAfterSwitchProfile(toolName, toolArguments, sessionId) {
140
- if (toolName !== 'manage_context' || !sessionId)
141
- return;
142
- const action = toolArguments && typeof toolArguments.action === 'string' ? toolArguments.action : undefined;
143
- if (action !== 'switch_profile')
144
- return;
145
- try {
146
- const { getContextManager } = await Promise.resolve().then(() => __importStar(require('./entities/context/context-manager')));
147
- const newProfileUrl = await getContextManager().getCurrentProfileUrl();
148
- if (!newProfileUrl)
149
- return;
150
- const normalized = (0, url_1.normalizeInstanceUrl)(newProfileUrl);
151
- const { getSessionManager } = await Promise.resolve().then(() => __importStar(require('./session-manager')));
152
- const sessionManager = getSessionManager();
153
- const pinnedUrl = sessionManager.getSessionInstanceUrl(sessionId);
154
- if (pinnedUrl && (0, url_1.normalizeInstanceUrl)(pinnedUrl) === normalized)
155
- return;
156
- sessionManager.setSessionInstanceUrl(sessionId, normalized);
157
- }
158
- catch (err) {
159
- (0, logger_1.logWarn)('Failed to re-pin session after switch_profile', {
160
- error: err instanceof Error ? err.message : String(err),
161
- });
162
- }
163
- }
164
- async function tryManageContextFastPath(toolName, toolArguments, effectiveInstanceUrl, healthMonitor, sessionId) {
165
- if (toolName !== 'manage_context' || healthMonitor.isInstanceReachable(effectiveInstanceUrl)) {
153
+ async function tryManageContextFastPath(toolName, toolArguments, effectiveInstanceUrl, healthMonitor, sessionId, requestScopes) {
154
+ if (!policy_1.CONFIGURATION_TOOLS.has(toolName) ||
155
+ healthMonitor.isInstanceReachable(effectiveInstanceUrl)) {
166
156
  return null;
167
157
  }
158
+ const result = await executeWithoutBootstrap(toolName, toolArguments, effectiveInstanceUrl, requestScopes);
159
+ if (result)
160
+ healthMonitor.forceReconnect(effectiveInstanceUrl);
161
+ return result;
162
+ }
163
+ async function tryWithoutBootstrap(request, toolArguments, effectiveInstanceUrl, healthMonitor, sessionId, requestScopes) {
164
+ const toolName = request.params.name;
165
+ const fastPath = await tryManageContextFastPath(toolName, toolArguments, effectiveInstanceUrl, healthMonitor, sessionId, requestScopes);
166
+ if (fastPath || !managesAccounts(request))
167
+ return fastPath;
168
+ return executeWithoutBootstrap(toolName, toolArguments, effectiveInstanceUrl, requestScopes);
169
+ }
170
+ async function executeWithoutBootstrap(toolName, toolArguments, effectiveInstanceUrl, requestScopes) {
168
171
  if (config_1.LOG_FORMAT === 'condensed') {
169
172
  const action = toolArguments && typeof toolArguments.action === 'string' ? toolArguments.action : undefined;
170
173
  const requestTracker = (0, index_1.getRequestTracker)();
@@ -172,21 +175,21 @@ async function tryManageContextFastPath(toolName, toolArguments, effectiveInstan
172
175
  }
173
176
  const { RegistryManager } = await Promise.resolve().then(() => __importStar(require('./registry-manager')));
174
177
  const registryManager = RegistryManager.getInstance();
175
- if (registryManager.hasToolHandler(toolName, effectiveInstanceUrl)) {
176
- const result = await registryManager.executeTool(toolName, toolArguments, effectiveInstanceUrl);
177
- if (result === undefined) {
178
- return null;
179
- }
180
- await resyncSessionAfterSwitchProfile(toolName, toolArguments, sessionId);
181
- return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
178
+ if (!registryManager.hasToolHandler(toolName, effectiveInstanceUrl)) {
179
+ return null;
180
+ }
181
+ const result = await registryManager.executeTool(toolName, toolArguments, effectiveInstanceUrl, requestScopes);
182
+ if (result === undefined) {
183
+ return null;
182
184
  }
183
- return null;
185
+ return (0, tool_result_1.formatToolResult)(result, registryManager.getTool(toolName, effectiveInstanceUrl, requestScopes));
184
186
  }
185
187
  async function ensureBootstrapped(ctx) {
186
- const { toolName, toolArguments, effectiveInstanceUrl, oauthMode, connectionManager, healthMonitor, isTimedOut, bootstrapState, } = ctx;
188
+ const { effectiveInstanceUrl, oauthMode, requestScopes, connectionManager, bootstrapState } = ctx;
187
189
  bootstrapState.started = true;
188
190
  try {
189
- if (!connectionManager.isConnected(effectiveInstanceUrl)) {
191
+ const firstInitialization = !connectionManager.isConnected(effectiveInstanceUrl);
192
+ if (firstInitialization) {
190
193
  if (config_1.LOG_FORMAT === 'verbose') {
191
194
  (0, logger_1.logInfo)('Connection not initialized, attempting to initialize...');
192
195
  }
@@ -194,7 +197,7 @@ async function ensureBootstrapped(ctx) {
194
197
  }
195
198
  connectionManager.getClient(effectiveInstanceUrl);
196
199
  if (oauthMode) {
197
- await connectionManager.ensureIntrospected(effectiveInstanceUrl);
200
+ await connectionManager.ensureIntrospected(effectiveInstanceUrl, requestScopes);
198
201
  }
199
202
  bootstrapState.complete = true;
200
203
  try {
@@ -207,6 +210,8 @@ async function ensureBootstrapped(ctx) {
207
210
  err: cacheError,
208
211
  });
209
212
  }
213
+ if (firstInitialization)
214
+ announceToolListChange(effectiveInstanceUrl);
210
215
  if (config_1.LOG_FORMAT === 'verbose') {
211
216
  try {
212
217
  const instanceInfo = connectionManager.getInstanceInfo(effectiveInstanceUrl);
@@ -221,37 +226,177 @@ async function ensureBootstrapped(ctx) {
221
226
  return undefined;
222
227
  }
223
228
  catch (initError) {
224
- const errorCategory = initError instanceof Error ? (0, error_handler_1.classifyError)(initError) : 'permanent';
225
- if (initError instanceof Error) {
226
- if (!isTimedOut() || errorCategory === 'auth' || errorCategory === 'permanent') {
227
- healthMonitor.reportError(effectiveInstanceUrl, initError);
228
- }
229
- }
230
- (0, logger_1.logError)(`Connection initialization failed: ${initError instanceof Error ? initError.message : String(initError)}`, {
231
- instanceUrl: effectiveInstanceUrl,
232
- err: initError instanceof Error ? initError : new Error(String(initError)),
233
- });
234
- const action = toolArguments && typeof toolArguments.action === 'string' ? toolArguments.action : 'unknown';
235
- const monitorState = healthMonitor.getState(effectiveInstanceUrl);
236
- let derivedState;
237
- if (monitorState === 'connecting' || monitorState === 'failed') {
238
- derivedState = monitorState;
239
- }
240
- else if (errorCategory === 'auth' || errorCategory === 'permanent') {
241
- derivedState = 'failed';
229
+ return formatBootstrapFailure(ctx, initError);
230
+ }
231
+ }
232
+ function announceToolListChange(instanceUrl) {
233
+ void Promise.resolve().then(() => __importStar(require('./session-manager'))).then(({ getSessionManager }) => getSessionManager().broadcastToolsListChanged(instanceUrl))
234
+ .catch((error) => (0, logger_1.logDebug)('Could not announce the tool list', { err: error }));
235
+ void (0, mcp_server_context_1.currentMcpServer)()
236
+ ?.sendToolListChanged()
237
+ .catch((error) => (0, logger_1.logDebug)('Could not announce the tool list', { err: error }));
238
+ }
239
+ function bootstrapFailureState(monitorState, category) {
240
+ if (monitorState === 'connecting' || monitorState === 'failed')
241
+ return monitorState;
242
+ return category === 'auth' || category === 'permanent' ? 'failed' : 'disconnected';
243
+ }
244
+ function formatBootstrapFailure(ctx, initError) {
245
+ const { toolName, toolArguments, effectiveInstanceUrl, healthMonitor, isTimedOut } = ctx;
246
+ const errorCategory = initError instanceof Error ? (0, error_handler_1.classifyError)(initError) : 'permanent';
247
+ if (initError instanceof Error) {
248
+ if (!isTimedOut() || errorCategory === 'auth' || errorCategory === 'permanent') {
249
+ healthMonitor.reportError(effectiveInstanceUrl, initError);
242
250
  }
243
- else {
244
- derivedState = 'disconnected';
251
+ }
252
+ (0, logger_1.logError)(`Connection initialization failed: ${initError instanceof Error ? initError.message : String(initError)}`, {
253
+ instanceUrl: effectiveInstanceUrl,
254
+ err: initError instanceof Error ? initError : new Error(String(initError)),
255
+ });
256
+ const action = toolArguments && typeof toolArguments.action === 'string' ? toolArguments.action : 'unknown';
257
+ const monitorState = healthMonitor.getState(effectiveInstanceUrl);
258
+ const derivedState = bootstrapFailureState(monitorState, errorCategory);
259
+ const connError = (0, error_handler_1.createConnectionFailedError)(toolName, action, effectiveInstanceUrl, derivedState);
260
+ if (!isTimedOut()) {
261
+ recordEarlyReturnError(toolName, action, connError.message);
262
+ }
263
+ return (0, tool_auth_1.withReauthChallenge)((0, tool_result_1.errorToolResult)(connError), initError);
264
+ }
265
+ const ACCOUNT_ACTIONS = new Set([
266
+ 'list_accounts',
267
+ 'switch_account',
268
+ 'link_account',
269
+ 'unlink_account',
270
+ ]);
271
+ function managesAccounts(request) {
272
+ const action = request.params.arguments?.action;
273
+ return (request.params.name === 'manage_context' &&
274
+ typeof action === 'string' &&
275
+ ACCOUNT_ACTIONS.has(action));
276
+ }
277
+ function activeInstanceUrl(oauthEnabled, oauthContextUrl) {
278
+ const raw = oauthEnabled
279
+ ? (oauthContextUrl ?? config_1.GITLAB_BASE_URL)
280
+ : ((0, token_account_1.currentTokenAccount)()?.instanceUrl ?? config_1.GITLAB_BASE_URL);
281
+ return (0, url_1.normalizeInstanceUrl)(raw);
282
+ }
283
+ async function pinSessionInstance(sessionId, oauthEnabled, oauthContextUrl, instanceUrl) {
284
+ if (oauthEnabled && oauthContextUrl === undefined)
285
+ return;
286
+ const { getSessionManager } = await Promise.resolve().then(() => __importStar(require('./session-manager')));
287
+ getSessionManager().setSessionInstanceUrl(sessionId, instanceUrl);
288
+ }
289
+ const HANDLER_TIMEOUT = Symbol('handler_timeout');
290
+ function startCallDeadline() {
291
+ let expired = false;
292
+ let timer;
293
+ const promise = new Promise((resolve) => {
294
+ timer = setTimeout(() => {
295
+ expired = true;
296
+ resolve(HANDLER_TIMEOUT);
297
+ }, config_1.HANDLER_TIMEOUT_MS);
298
+ });
299
+ return { expired: promise, isExpired: () => expired, clear: () => clearTimeout(timer) };
300
+ }
301
+ function handlerTimeoutResult(request, declaredIdempotent, bootstrapState, requestInstanceUrl) {
302
+ const toolName = request.params.name;
303
+ const requested = request.params.arguments?.action;
304
+ const action = typeof requested === 'string' ? requested : 'unknown';
305
+ const retryable = isIdempotentOperation(toolName, declaredIdempotent);
306
+ const timeoutError = (0, error_handler_1.createTimeoutError)(toolName, action, config_1.HANDLER_TIMEOUT_MS, retryable);
307
+ (0, logger_1.logError)(`Handler timeout: tool '${toolName}' timed out after ${config_1.HANDLER_TIMEOUT_MS}ms`);
308
+ if (bootstrapState.started && !bootstrapState.complete) {
309
+ HealthMonitor_1.HealthMonitor.getInstance().reportError(requestInstanceUrl, new Error(`Handler timed out after ${config_1.HANDLER_TIMEOUT_MS}ms — bootstrap did not complete`));
310
+ ConnectionManager_1.ConnectionManager.getInstance().clearInflight(requestInstanceUrl);
311
+ }
312
+ recordEarlyReturnError(toolName, action, timeoutError.message);
313
+ return (0, tool_result_1.errorToolResult)(timeoutError);
314
+ }
315
+ function recordToolError(errMsg) {
316
+ const reqTracker = (0, index_1.getRequestTracker)();
317
+ reqTracker.setErrorForCurrentRequest(errMsg);
318
+ const curRequestId = (0, index_1.getCurrentRequestId)();
319
+ const sessionId = curRequestId ? reqTracker.getStack(curRequestId)?.sessionId : undefined;
320
+ if (sessionId) {
321
+ (0, index_1.getConnectionTracker)().recordError(sessionId, errMsg);
322
+ }
323
+ }
324
+ async function withoutRestrictedTools(tools, caller, registryManager) {
325
+ let policy;
326
+ try {
327
+ policy = (await (0, configuration_1.getConfigurationService)().resolve(caller)).policy;
328
+ }
329
+ catch (error) {
330
+ (0, logger_1.logWarn)('Could not read the caller settings for the tool list', { err: error });
331
+ return tools;
332
+ }
333
+ const listed = [];
334
+ for (const tool of tools) {
335
+ const inputSchema = (0, policy_1.listedToolSchema)(policy, registryManager.getToolFacts(tool.name), tool.inputSchema);
336
+ if (inputSchema)
337
+ listed.push(inputSchema === tool.inputSchema ? tool : { ...tool, inputSchema });
338
+ }
339
+ return listed;
340
+ }
341
+ async function prepareScopedCall(toolName, args, configured, registryManager) {
342
+ const unscoped = settingsRejection(toolName, args, (0, policy_1.withoutScope)(configured), registryManager);
343
+ if (unscoped || !configured.scopeEnforcer || (0, policy_1.isExemptFromSettings)(toolName))
344
+ return { rejection: unscoped, args, policy: configured };
345
+ const policy = await (0, scope_ids_1.withScopePaths)(configured);
346
+ const selected = (0, scoped_execution_1.parseScopedArguments)(toolName, args);
347
+ const action = typeof args.action === 'string' ? args.action : undefined;
348
+ const declared = selected === args ? registryManager.getDeclaredArguments(toolName, action) : undefined;
349
+ const own = declared
350
+ ? Object.fromEntries(Object.entries(selected).filter(([name]) => declared.has(name)))
351
+ : selected;
352
+ return {
353
+ rejection: settingsRejection(toolName, await (0, scope_ids_1.withTargetPaths)(own, undefined, policy.scopeEnforcer), policy, registryManager),
354
+ args: selected,
355
+ policy,
356
+ };
357
+ }
358
+ function settingsRejection(toolName, args, policy, registryManager) {
359
+ const reason = (0, policy_1.callRestriction)(policy, registryManager.getToolFacts(toolName), args);
360
+ if (reason === null)
361
+ return null;
362
+ const action = typeof args.action === 'string' ? args.action : undefined;
363
+ const call = action ? `${toolName} ${action}` : toolName;
364
+ const message = `'${call}' is not allowed by the current settings: ` +
365
+ `${reason}. The account settings are changed with update_settings, this session's ` +
366
+ 'with manage_context.';
367
+ recordEarlyReturnError(toolName, action, message);
368
+ return (0, tool_result_1.errorToolResult)({ error: message });
369
+ }
370
+ async function executeInScope(registryManager, toolName, requested, policy, instanceUrl, requestScopes) {
371
+ const run = (tool, toolArgs) => requestScopes === undefined
372
+ ? registryManager.executeTool(tool, toolArgs, instanceUrl)
373
+ : registryManager.executeTool(tool, toolArgs, instanceUrl, requestScopes);
374
+ return (0, scoped_execution_1.executeScoped)(run, toolName, requested, policy, true);
375
+ }
376
+ function recordCallContext(scopePath, readOnly) {
377
+ const requestTracker = (0, index_1.getRequestTracker)();
378
+ if (scopePath) {
379
+ requestTracker.setContextForCurrentRequest(scopePath);
380
+ }
381
+ requestTracker.setReadOnlyForCurrentRequest(readOnly);
382
+ const currentRequestId = (0, index_1.getCurrentRequestId)();
383
+ if (currentRequestId) {
384
+ const stack = requestTracker.getStack(currentRequestId);
385
+ if (stack?.sessionId) {
386
+ const connectionTracker = (0, index_1.getConnectionTracker)();
387
+ connectionTracker.incrementTools(stack.sessionId);
245
388
  }
246
- const connError = (0, error_handler_1.createConnectionFailedError)(toolName, action, effectiveInstanceUrl, derivedState);
247
- if (!isTimedOut()) {
248
- recordEarlyReturnError(toolName, action, connError.message);
389
+ }
390
+ }
391
+ function throwDispatchError(error, toolName, instanceUrl, healthMonitor, timedOut) {
392
+ if (!timedOut && error instanceof Error) {
393
+ const category = (0, error_handler_1.classifyError)(error);
394
+ if (category === 'transient' || category === 'auth') {
395
+ healthMonitor.reportError(instanceUrl, error);
249
396
  }
250
- return {
251
- content: [{ type: 'text', text: JSON.stringify(connError, null, 2) }],
252
- isError: true,
253
- };
254
397
  }
398
+ const errorMessage = error instanceof Error ? error.message : String(error);
399
+ throw new Error(`Failed to execute tool '${toolName}': ${errorMessage}`, { cause: error });
255
400
  }
256
401
  let healthMonitorStartup = null;
257
402
  let stateChangeRegistered = false;
@@ -312,7 +457,40 @@ async function setupHandlers(server) {
312
457
  else {
313
458
  (0, logger_1.logInfo)('Skipping connection initialization - no authentication configured');
314
459
  }
315
- server.setRequestHandler(types_js_1.ListToolsRequestSchema, async (_request, extra) => {
460
+ server.setRequestHandler(types_js_1.ListResourcesRequestSchema, () => {
461
+ const rejection = (0, tool_auth_1.resourceScopeRejection)();
462
+ if (rejection)
463
+ throw rejection;
464
+ return {
465
+ resources: [
466
+ {
467
+ uri: settings_panel_1.SETTINGS_PANEL_URI,
468
+ name: 'GitLab connection panel',
469
+ mimeType: mcp_apps_1.MCP_APP_MIME_TYPE,
470
+ _meta: settings_panel_1.SETTINGS_PANEL_RESOURCE_META,
471
+ },
472
+ ],
473
+ };
474
+ });
475
+ server.setRequestHandler(types_js_1.ReadResourceRequestSchema, (request) => {
476
+ const rejection = (0, tool_auth_1.resourceScopeRejection)();
477
+ if (rejection)
478
+ throw rejection;
479
+ if (request.params.uri !== settings_panel_1.SETTINGS_PANEL_URI) {
480
+ throw new types_js_1.McpError(types_js_1.ErrorCode.InvalidParams, `Unknown resource: ${request.params.uri}`);
481
+ }
482
+ return {
483
+ contents: [
484
+ {
485
+ uri: settings_panel_1.SETTINGS_PANEL_URI,
486
+ mimeType: mcp_apps_1.MCP_APP_MIME_TYPE,
487
+ text: (0, settings_panel_1.settingsPanelHtml)(),
488
+ _meta: settings_panel_1.SETTINGS_PANEL_RESOURCE_META,
489
+ },
490
+ ],
491
+ };
492
+ });
493
+ const listTools = async (extra) => {
316
494
  (0, logger_1.logInfo)('ListToolsRequest received');
317
495
  const { getSessionManager: getSessionMgr } = await Promise.resolve().then(() => __importStar(require('./session-manager')));
318
496
  const sessionMgr = getSessionMgr();
@@ -322,7 +500,16 @@ async function setupHandlers(server) {
322
500
  : undefined;
323
501
  const { RegistryManager } = await Promise.resolve().then(() => __importStar(require('./registry-manager')));
324
502
  const registryManager = RegistryManager.getInstance();
325
- const tools = registryManager.getAllToolDefinitions(sessionInstanceUrl);
503
+ const mode = (0, schema_utils_1.getSchemaMode)(server.getClientVersion()?.name);
504
+ const { getTokenContext: getCatalogContext, isOAuthEnabled: isCatalogOAuth, getGitLabApiUrlFromContext: getCatalogUrl, } = await Promise.resolve().then(() => __importStar(require('./oauth/index')));
505
+ const scopes = getCatalogContext()?.gitlabScopes;
506
+ const securitySchemes = isCatalogOAuth() ? tool_auth_1.OAUTH_SECURITY_SCHEMES : undefined;
507
+ const catalog = scopes === undefined
508
+ ? registryManager.getAllToolDefinitions(sessionInstanceUrl, mode)
509
+ : registryManager.getAllToolDefinitions(sessionInstanceUrl, mode, scopes);
510
+ const callerInstanceUrl = sessionInstanceUrl ??
511
+ activeInstanceUrl(isCatalogOAuth(), isCatalogOAuth() ? getCatalogUrl() : undefined);
512
+ const tools = await withoutRestrictedTools(catalog, (0, configuration_1.resolveCaller)(listToolsSessionId, callerInstanceUrl), registryManager);
326
513
  (0, logger_1.logInfo)('Returning tools list', { toolCount: tools.length });
327
514
  function resolveRefs(schema, rootSchema) {
328
515
  if (!schema || typeof schema !== 'object')
@@ -378,39 +565,51 @@ async function setupHandlers(server) {
378
565
  delete cleanedSchema.$schema;
379
566
  inputSchema = cleanedSchema;
380
567
  }
381
- return { ...tool, inputSchema };
568
+ if (!securitySchemes || tool._meta?.securitySchemes !== undefined) {
569
+ return { ...tool, inputSchema };
570
+ }
571
+ const schemes = tool._meta?.ui ? tool_auth_1.APP_PANEL_SECURITY_SCHEMES : securitySchemes;
572
+ return {
573
+ ...tool,
574
+ inputSchema,
575
+ securitySchemes: schemes,
576
+ _meta: { ...tool._meta, securitySchemes: schemes },
577
+ };
382
578
  });
383
579
  return {
384
580
  tools: modifiedTools,
385
581
  };
582
+ };
583
+ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async (_request, extra) => {
584
+ try {
585
+ return await (0, chat_accounts_1.withChatAccount)(extra?.sessionId, () => listTools(extra));
586
+ }
587
+ catch (error) {
588
+ if (!(error instanceof chat_accounts_1.AccountUnavailableError))
589
+ throw error;
590
+ return listTools(extra);
591
+ }
386
592
  });
387
- server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request, extra) => {
388
- const { getGitLabApiUrlFromContext: getUrlFromCtx, isOAuthEnabled } = await Promise.resolve().then(() => __importStar(require('./oauth/index')));
593
+ const callTool = async (request, extra, deadline) => {
594
+ const { getGitLabApiUrlFromContext: getUrlFromCtx, isOAuthEnabled, getTokenContext: getCallContext, } = await Promise.resolve().then(() => __importStar(require('./oauth/index')));
389
595
  const oauthEnabled = isOAuthEnabled();
596
+ if (oauthEnabled) {
597
+ const rejection = (0, tool_auth_1.toolScopeRejection)();
598
+ if (rejection)
599
+ return rejection;
600
+ }
601
+ const requestScopes = oauthEnabled ? getCallContext()?.gitlabScopes : undefined;
602
+ let declaredIdempotent;
390
603
  const oauthContextUrl = oauthEnabled ? getUrlFromCtx() : undefined;
391
- const rawInstanceUrl = oauthEnabled
392
- ? (oauthContextUrl ?? config_1.GITLAB_BASE_URL)
393
- : (ConnectionManager_1.ConnectionManager.getInstance().getCurrentInstanceUrl() ?? config_1.GITLAB_BASE_URL);
394
- const requestInstanceUrl = (0, url_1.normalizeInstanceUrl)(rawInstanceUrl);
604
+ const requestInstanceUrl = activeInstanceUrl(oauthEnabled, oauthContextUrl);
395
605
  const callSessionId = extra?.sessionId;
396
- if (callSessionId && (!oauthEnabled || oauthContextUrl !== undefined)) {
397
- const { getSessionManager: getSessionMgrForCall } = await Promise.resolve().then(() => __importStar(require('./session-manager')));
398
- getSessionMgrForCall().setSessionInstanceUrl(callSessionId, requestInstanceUrl);
606
+ if (callSessionId && !managesAccounts(request)) {
607
+ await pinSessionInstance(callSessionId, oauthEnabled, oauthContextUrl, requestInstanceUrl);
399
608
  }
400
- let timedOut = false;
609
+ const caller = (0, configuration_1.resolveCaller)(callSessionId, requestInstanceUrl);
401
610
  const bootstrapState = { started: false, complete: false };
402
- const HANDLER_TIMEOUT_SYMBOL = Symbol('handler_timeout');
403
- let handlerTimeoutId;
404
- const timeoutPromise = new Promise((resolve) => {
405
- handlerTimeoutId = setTimeout(() => {
406
- timedOut = true;
407
- resolve(HANDLER_TIMEOUT_SYMBOL);
408
- }, config_1.HANDLER_TIMEOUT_MS);
409
- });
611
+ const timedOut = deadline.isExpired;
410
612
  const handlerWork = async () => {
411
- if (!request.params.arguments) {
412
- throw new Error('Arguments are required');
413
- }
414
613
  if (config_1.LOG_FORMAT === 'verbose') {
415
614
  (0, logger_1.logInfo)(`Tool called: ${request.params.name}`);
416
615
  }
@@ -425,22 +624,29 @@ async function setupHandlers(server) {
425
624
  const connectionManager = ConnectionManager_1.ConnectionManager.getInstance();
426
625
  const healthMonitor = HealthMonitor_1.HealthMonitor.getInstance();
427
626
  const toolName = request.params.name;
428
- const toolArguments = request.params.arguments;
627
+ let toolArguments = request.params.arguments;
628
+ const { RegistryManager: CallRegistry } = await Promise.resolve().then(() => __importStar(require('./registry-manager')));
629
+ const configuration = await (0, configuration_1.getConfigurationService)().resolve(caller);
630
+ const prepared = await prepareScopedCall(toolName, toolArguments ?? {}, configuration.policy, CallRegistry.getInstance());
631
+ if (prepared.rejection)
632
+ return prepared.rejection;
633
+ toolArguments = prepared.args;
429
634
  const unreachableResult = checkUnreachableInstance(toolName, toolArguments, effectiveInstanceUrl, healthMonitor);
430
635
  if (unreachableResult)
431
636
  return unreachableResult;
432
- const fastPathResult = await tryManageContextFastPath(toolName, toolArguments, effectiveInstanceUrl, healthMonitor, callSessionId);
433
- if (fastPathResult)
434
- return fastPathResult;
637
+ const withoutBootstrap = await tryWithoutBootstrap(request, toolArguments, effectiveInstanceUrl, healthMonitor, callSessionId, requestScopes);
638
+ if (withoutBootstrap)
639
+ return withoutBootstrap;
435
640
  const oauthMode = isOAuthEnabled();
436
641
  const bootstrapFailure = await ensureBootstrapped({
437
642
  toolName,
438
643
  toolArguments,
439
644
  effectiveInstanceUrl,
440
645
  oauthMode,
646
+ requestScopes,
441
647
  connectionManager,
442
648
  healthMonitor,
443
- isTimedOut: () => timedOut,
649
+ isTimedOut: timedOut,
444
650
  bootstrapState,
445
651
  });
446
652
  if (bootstrapFailure)
@@ -450,25 +656,13 @@ async function setupHandlers(server) {
450
656
  if (config_1.LOG_FORMAT === 'condensed') {
451
657
  const requestTracker = (0, index_1.getRequestTracker)();
452
658
  requestTracker.setToolForCurrentRequest(toolName, action);
453
- const { getContextManager } = await Promise.resolve().then(() => __importStar(require('./entities/context/context-manager')));
454
- const contextManager = getContextManager();
455
- const sessionContext = contextManager.getContext();
456
- if (sessionContext.scope?.path) {
457
- requestTracker.setContextForCurrentRequest(sessionContext.scope.path);
458
- }
459
- requestTracker.setReadOnlyForCurrentRequest(sessionContext.readOnly);
460
- const currentRequestId = (0, index_1.getCurrentRequestId)();
461
- if (currentRequestId) {
462
- const stack = requestTracker.getStack(currentRequestId);
463
- if (stack?.sessionId) {
464
- const connectionTracker = (0, index_1.getConnectionTracker)();
465
- connectionTracker.incrementTools(stack.sessionId);
466
- }
467
- }
659
+ recordCallContext((0, policy_1.scopeLabel)(configuration.policy.scope), config_1.GITLAB_READ_ONLY_MODE || configuration.policy.readOnly);
468
660
  }
469
661
  try {
470
662
  const { RegistryManager } = await Promise.resolve().then(() => __importStar(require('./registry-manager')));
471
663
  const registryManager = RegistryManager.getInstance();
664
+ const definition = registryManager.getTool(toolName, effectiveInstanceUrl, requestScopes);
665
+ declaredIdempotent = definition?.idempotent ?? definition?.annotations?.idempotentHint;
472
666
  if (!registryManager.hasToolHandler(toolName, effectiveInstanceUrl)) {
473
667
  throw new Error(`Tool '${toolName}' is not available or has been filtered out`);
474
668
  }
@@ -484,103 +678,70 @@ async function setupHandlers(server) {
484
678
  tool: toolName,
485
679
  });
486
680
  }
487
- const result = await registryManager.executeTool(toolName, request.params.arguments, effectiveInstanceUrl);
681
+ const result = await executeInScope(registryManager, toolName, toolArguments, prepared.policy, effectiveInstanceUrl, requestScopes);
488
682
  if (result === undefined) {
489
683
  throw new Error(`Tool '${toolName}' is not available or has been filtered out`);
490
684
  }
491
- await resyncSessionAfterSwitchProfile(toolName, request.params.arguments, callSessionId);
492
- if (!timedOut) {
685
+ if (!timedOut()) {
493
686
  healthMonitor.reportSuccess(effectiveInstanceUrl);
494
687
  }
495
- return {
496
- content: [
497
- {
498
- type: 'text',
499
- text: JSON.stringify(result, null, 2),
500
- },
501
- ],
502
- };
688
+ return (0, tool_result_1.formatToolResult)(result, definition);
503
689
  }
504
690
  catch (error) {
505
- if (!timedOut && error instanceof Error) {
506
- const category = (0, error_handler_1.classifyError)(error);
507
- if (category === 'transient' || category === 'auth') {
508
- healthMonitor.reportError(effectiveInstanceUrl, error);
509
- }
510
- }
511
- const errorMessage = error instanceof Error ? error.message : String(error);
512
- throw new Error(`Failed to execute tool '${toolName}': ${errorMessage}`, { cause: error });
691
+ throwDispatchError(error, toolName, effectiveInstanceUrl, healthMonitor, timedOut());
513
692
  }
514
693
  };
515
694
  try {
516
- const result = await Promise.race([handlerWork(), timeoutPromise]);
517
- if (result === HANDLER_TIMEOUT_SYMBOL) {
518
- const toolName = request.params.name;
519
- const action = request.params.arguments && typeof request.params.arguments.action === 'string'
520
- ? request.params.arguments.action
521
- : 'unknown';
522
- const retryable = isIdempotentOperation(toolName);
523
- const timeoutError = (0, error_handler_1.createTimeoutError)(toolName, action, config_1.HANDLER_TIMEOUT_MS, retryable);
524
- (0, logger_1.logError)(`Handler timeout: tool '${toolName}' timed out after ${config_1.HANDLER_TIMEOUT_MS}ms`);
525
- if (bootstrapState.started && !bootstrapState.complete) {
526
- HealthMonitor_1.HealthMonitor.getInstance().reportError(requestInstanceUrl, new Error(`Handler timed out after ${config_1.HANDLER_TIMEOUT_MS}ms — bootstrap did not complete`));
527
- ConnectionManager_1.ConnectionManager.getInstance().clearInflight(requestInstanceUrl);
528
- }
529
- recordEarlyReturnError(toolName, action, timeoutError.message);
530
- return {
531
- content: [
532
- {
533
- type: 'text',
534
- text: JSON.stringify(timeoutError, null, 2),
535
- },
536
- ],
537
- isError: true,
538
- };
695
+ const result = await Promise.race([(0, configuration_1.runWithCaller)(caller, handlerWork), deadline.expired]);
696
+ if (result === HANDLER_TIMEOUT) {
697
+ return handlerTimeoutResult(request, declaredIdempotent, bootstrapState, requestInstanceUrl);
539
698
  }
540
699
  return result;
541
700
  }
542
701
  catch (error) {
543
702
  const errMsg = error instanceof Error ? error.message : String(error);
544
703
  (0, logger_1.logError)(`Error in tool handler: ${errMsg}`);
545
- const reqTracker = (0, index_1.getRequestTracker)();
546
- reqTracker.setErrorForCurrentRequest(errMsg);
547
- const curRequestId = (0, index_1.getCurrentRequestId)();
548
- if (curRequestId) {
549
- const stack = reqTracker.getStack(curRequestId);
550
- if (stack?.sessionId) {
551
- const connTracker = (0, index_1.getConnectionTracker)();
552
- connTracker.recordError(stack.sessionId, errMsg);
553
- }
554
- }
704
+ recordToolError(errMsg);
555
705
  const toolName = request.params.name;
556
706
  const toolArgs = request.params.arguments;
557
- const structuredError = toStructuredError(error, toolName, toolArgs);
707
+ const structuredError = toStructuredError(error, toolName, toolArgs, declaredIdempotent);
558
708
  if (structuredError) {
559
709
  (0, logger_1.logDebug)('Returning structured error response', { structuredError });
560
- return {
561
- content: [
562
- {
563
- type: 'text',
564
- text: JSON.stringify(structuredError, null, 2),
565
- },
566
- ],
567
- isError: true,
568
- };
710
+ return (0, tool_auth_1.withReauthChallenge)((0, tool_result_1.errorToolResult)(structuredError), error);
569
711
  }
570
712
  const errorMessage = error instanceof Error ? error.message : String(error);
571
- return {
572
- content: [
573
- {
574
- type: 'text',
575
- text: JSON.stringify({ error: errorMessage }, null, 2),
576
- },
577
- ],
578
- isError: true,
579
- };
713
+ return (0, tool_auth_1.withReauthChallenge)((0, tool_result_1.errorToolResult)({ error: errorMessage }), error);
714
+ }
715
+ };
716
+ server.setRequestHandler(types_js_1.CallToolRequestSchema, (request, extra) => (0, mcp_server_context_1.runWithMcpServer)(server, async () => {
717
+ const deadline = startCallDeadline();
718
+ try {
719
+ if (managesAccounts(request))
720
+ return await callTool(request, extra, deadline);
721
+ let running = false;
722
+ const call = (0, chat_accounts_1.withChatAccount)(extra?.sessionId, async () => {
723
+ if (deadline.isExpired())
724
+ return undefined;
725
+ running = true;
726
+ return callTool(request, extra, deadline);
727
+ });
728
+ const first = await Promise.race([call, deadline.expired]);
729
+ if (first !== HANDLER_TIMEOUT && first !== undefined)
730
+ return first;
731
+ const answered = running ? await call : undefined;
732
+ if (answered)
733
+ return answered;
734
+ call.catch((error) => (0, logger_1.logDebug)('Account resolution failed after the call timed out', { err: error }));
735
+ return handlerTimeoutResult(request, undefined, { started: false, complete: false }, config_1.GITLAB_BASE_URL);
736
+ }
737
+ catch (error) {
738
+ if (!(error instanceof chat_accounts_1.AccountUnavailableError))
739
+ throw error;
740
+ return (0, tool_result_1.errorToolResult)({ error: error.message });
580
741
  }
581
742
  finally {
582
- clearTimeout(handlerTimeoutId);
743
+ deadline.clear();
583
744
  }
584
- });
745
+ }));
585
746
  }
586
747
  //# sourceMappingURL=handlers.js.map