@vendure/mcp-plugin 3.8.0-minor-bootstrap.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 (389) hide show
  1. package/lib/api/api-extensions.d.ts +2 -0
  2. package/lib/api/api-extensions.js +239 -0
  3. package/lib/api/api-extensions.js.map +1 -0
  4. package/lib/api/mcp-actor.service.d.ts +19 -0
  5. package/lib/api/mcp-actor.service.js +52 -0
  6. package/lib/api/mcp-actor.service.js.map +1 -0
  7. package/lib/api/mcp-admin.resolver.d.ts +105 -0
  8. package/lib/api/mcp-admin.resolver.js +463 -0
  9. package/lib/api/mcp-admin.resolver.js.map +1 -0
  10. package/lib/api/mcp-shop.resolver.d.ts +25 -0
  11. package/lib/api/mcp-shop.resolver.js +74 -0
  12. package/lib/api/mcp-shop.resolver.js.map +1 -0
  13. package/lib/check-options.d.ts +7 -0
  14. package/lib/check-options.js +130 -0
  15. package/lib/check-options.js.map +1 -0
  16. package/lib/constants.d.ts +48 -0
  17. package/lib/constants.js +72 -0
  18. package/lib/constants.js.map +1 -0
  19. package/lib/delete-in-batches.d.ts +5 -0
  20. package/lib/delete-in-batches.js +28 -0
  21. package/lib/delete-in-batches.js.map +1 -0
  22. package/lib/entities/index.d.ts +5 -0
  23. package/lib/entities/index.js +22 -0
  24. package/lib/entities/index.js.map +1 -0
  25. package/lib/entities/mcp-authorization-code.entity.d.ts +33 -0
  26. package/lib/entities/mcp-authorization-code.entity.js +77 -0
  27. package/lib/entities/mcp-authorization-code.entity.js.map +1 -0
  28. package/lib/entities/mcp-authorization-request.entity.d.ts +31 -0
  29. package/lib/entities/mcp-authorization-request.entity.js +73 -0
  30. package/lib/entities/mcp-authorization-request.entity.js.map +1 -0
  31. package/lib/entities/mcp-oauth-client.entity.d.ts +56 -0
  32. package/lib/entities/mcp-oauth-client.entity.js +70 -0
  33. package/lib/entities/mcp-oauth-client.entity.js.map +1 -0
  34. package/lib/entities/mcp-oauth-grant.entity.d.ts +77 -0
  35. package/lib/entities/mcp-oauth-grant.entity.js +121 -0
  36. package/lib/entities/mcp-oauth-grant.entity.js.map +1 -0
  37. package/lib/entities/mcp-tool-call-log.entity.d.ts +50 -0
  38. package/lib/entities/mcp-tool-call-log.entity.js +101 -0
  39. package/lib/entities/mcp-tool-call-log.entity.js.map +1 -0
  40. package/lib/events/mcp-tool-call.event.d.ts +17 -0
  41. package/lib/events/mcp-tool-call.event.js +23 -0
  42. package/lib/events/mcp-tool-call.event.js.map +1 -0
  43. package/lib/get-client-ip.d.ts +2 -0
  44. package/lib/get-client-ip.js +10 -0
  45. package/lib/get-client-ip.js.map +1 -0
  46. package/lib/get-language-code.d.ts +3 -0
  47. package/lib/get-language-code.js +12 -0
  48. package/lib/get-language-code.js.map +1 -0
  49. package/lib/index.d.ts +6 -0
  50. package/lib/index.js +26 -0
  51. package/lib/index.js.map +1 -0
  52. package/lib/internal-types.d.ts +27 -0
  53. package/lib/internal-types.js +3 -0
  54. package/lib/internal-types.js.map +1 -0
  55. package/lib/logging/mcp-tool-call-log-retention.service.d.ts +8 -0
  56. package/lib/logging/mcp-tool-call-log-retention.service.js +54 -0
  57. package/lib/logging/mcp-tool-call-log-retention.service.js.map +1 -0
  58. package/lib/logging/mcp-tool-call-log.service.d.ts +24 -0
  59. package/lib/logging/mcp-tool-call-log.service.js +128 -0
  60. package/lib/logging/mcp-tool-call-log.service.js.map +1 -0
  61. package/lib/oauth/cimd/cimd-client-resolver.service.d.ts +18 -0
  62. package/lib/oauth/cimd/cimd-client-resolver.service.js +109 -0
  63. package/lib/oauth/cimd/cimd-client-resolver.service.js.map +1 -0
  64. package/lib/oauth/cimd/cimd-document.d.ts +11 -0
  65. package/lib/oauth/cimd/cimd-document.js +66 -0
  66. package/lib/oauth/cimd/cimd-document.js.map +1 -0
  67. package/lib/oauth/cimd/cimd-fetch.d.ts +14 -0
  68. package/lib/oauth/cimd/cimd-fetch.js +192 -0
  69. package/lib/oauth/cimd/cimd-fetch.js.map +1 -0
  70. package/lib/oauth/cimd/cimd-url.d.ts +5 -0
  71. package/lib/oauth/cimd/cimd-url.js +94 -0
  72. package/lib/oauth/cimd/cimd-url.js.map +1 -0
  73. package/lib/oauth/grant-session.service.d.ts +19 -0
  74. package/lib/oauth/grant-session.service.js +141 -0
  75. package/lib/oauth/grant-session.service.js.map +1 -0
  76. package/lib/oauth/oauth-error.d.ts +18 -0
  77. package/lib/oauth/oauth-error.js +60 -0
  78. package/lib/oauth/oauth-error.js.map +1 -0
  79. package/lib/oauth/oauth-metadata.service.d.ts +34 -0
  80. package/lib/oauth/oauth-metadata.service.js +107 -0
  81. package/lib/oauth/oauth-metadata.service.js.map +1 -0
  82. package/lib/oauth/oauth-retention.service.d.ts +23 -0
  83. package/lib/oauth/oauth-retention.service.js +103 -0
  84. package/lib/oauth/oauth-retention.service.js.map +1 -0
  85. package/lib/oauth/oauth-types.d.ts +61 -0
  86. package/lib/oauth/oauth-types.js +32 -0
  87. package/lib/oauth/oauth-types.js.map +1 -0
  88. package/lib/oauth/oauth-utils.d.ts +20 -0
  89. package/lib/oauth/oauth-utils.js +111 -0
  90. package/lib/oauth/oauth-utils.js.map +1 -0
  91. package/lib/oauth/oauth.controller.d.ts +31 -0
  92. package/lib/oauth/oauth.controller.js +132 -0
  93. package/lib/oauth/oauth.controller.js.map +1 -0
  94. package/lib/oauth/oauth.service.d.ts +69 -0
  95. package/lib/oauth/oauth.service.js +650 -0
  96. package/lib/oauth/oauth.service.js.map +1 -0
  97. package/lib/oauth/token-hash.d.ts +6 -0
  98. package/lib/oauth/token-hash.js +21 -0
  99. package/lib/oauth/token-hash.js.map +1 -0
  100. package/lib/plugin.d.ts +54 -0
  101. package/lib/plugin.js +171 -0
  102. package/lib/plugin.js.map +1 -0
  103. package/lib/rate-limit/ip-bucket-key.d.ts +1 -0
  104. package/lib/rate-limit/ip-bucket-key.js +35 -0
  105. package/lib/rate-limit/ip-bucket-key.js.map +1 -0
  106. package/lib/rate-limit/mcp-oauth-rate-limit.guard.d.ts +20 -0
  107. package/lib/rate-limit/mcp-oauth-rate-limit.guard.js +63 -0
  108. package/lib/rate-limit/mcp-oauth-rate-limit.guard.js.map +1 -0
  109. package/lib/rate-limit/mcp-rate-limiter.service.d.ts +47 -0
  110. package/lib/rate-limit/mcp-rate-limiter.service.js +248 -0
  111. package/lib/rate-limit/mcp-rate-limiter.service.js.map +1 -0
  112. package/lib/registry/bm25.d.ts +12 -0
  113. package/lib/registry/bm25.js +60 -0
  114. package/lib/registry/bm25.js.map +1 -0
  115. package/lib/registry/mcp-tool-execution.service.d.ts +45 -0
  116. package/lib/registry/mcp-tool-execution.service.js +72 -0
  117. package/lib/registry/mcp-tool-execution.service.js.map +1 -0
  118. package/lib/registry/mcp-tool-registry.service.d.ts +89 -0
  119. package/lib/registry/mcp-tool-registry.service.js +668 -0
  120. package/lib/registry/mcp-tool-registry.service.js.map +1 -0
  121. package/lib/registry/mcp-tool-schema.service.d.ts +42 -0
  122. package/lib/registry/mcp-tool-schema.service.js +229 -0
  123. package/lib/registry/mcp-tool-schema.service.js.map +1 -0
  124. package/lib/registry/registry-types.d.ts +32 -0
  125. package/lib/registry/registry-types.js +3 -0
  126. package/lib/registry/registry-types.js.map +1 -0
  127. package/lib/resolve-options.d.ts +7 -0
  128. package/lib/resolve-options.js +85 -0
  129. package/lib/resolve-options.js.map +1 -0
  130. package/lib/shared/endpoint-paths.d.ts +8 -0
  131. package/lib/shared/endpoint-paths.js +12 -0
  132. package/lib/shared/endpoint-paths.js.map +1 -0
  133. package/lib/shared/loopback.d.ts +2 -0
  134. package/lib/shared/loopback.js +9 -0
  135. package/lib/shared/loopback.js.map +1 -0
  136. package/lib/shop-session/mcp-shop-session.service.d.ts +47 -0
  137. package/lib/shop-session/mcp-shop-session.service.js +132 -0
  138. package/lib/shop-session/mcp-shop-session.service.js.map +1 -0
  139. package/lib/tasks/mcp-oauth-retention.task.d.ts +9 -0
  140. package/lib/tasks/mcp-oauth-retention.task.js +21 -0
  141. package/lib/tasks/mcp-oauth-retention.task.js.map +1 -0
  142. package/lib/tasks/mcp-tool-call-log-retention.task.d.ts +7 -0
  143. package/lib/tasks/mcp-tool-call-log-retention.task.js +22 -0
  144. package/lib/tasks/mcp-tool-call-log-retention.task.js.map +1 -0
  145. package/lib/tools/built-in/active-order.service.d.ts +26 -0
  146. package/lib/tools/built-in/active-order.service.js +125 -0
  147. package/lib/tools/built-in/active-order.service.js.map +1 -0
  148. package/lib/tools/built-in/admin/add-customer-to-group.tool.d.ts +23 -0
  149. package/lib/tools/built-in/admin/add-customer-to-group.tool.js +68 -0
  150. package/lib/tools/built-in/admin/add-customer-to-group.tool.js.map +1 -0
  151. package/lib/tools/built-in/admin/add-note-to-order.tool.d.ts +104 -0
  152. package/lib/tools/built-in/admin/add-note-to-order.tool.js +66 -0
  153. package/lib/tools/built-in/admin/add-note-to-order.tool.js.map +1 -0
  154. package/lib/tools/built-in/admin/adjust-stock.tool.d.ts +26 -0
  155. package/lib/tools/built-in/admin/adjust-stock.tool.js +88 -0
  156. package/lib/tools/built-in/admin/adjust-stock.tool.js.map +1 -0
  157. package/lib/tools/built-in/admin/cancel-order.tool.d.ts +17 -0
  158. package/lib/tools/built-in/admin/cancel-order.tool.js +60 -0
  159. package/lib/tools/built-in/admin/cancel-order.tool.js.map +1 -0
  160. package/lib/tools/built-in/admin/channel-access.d.ts +2 -0
  161. package/lib/tools/built-in/admin/channel-access.js +9 -0
  162. package/lib/tools/built-in/admin/channel-access.js.map +1 -0
  163. package/lib/tools/built-in/admin/create-customer.tool.d.ts +41 -0
  164. package/lib/tools/built-in/admin/create-customer.tool.js +57 -0
  165. package/lib/tools/built-in/admin/create-customer.tool.js.map +1 -0
  166. package/lib/tools/built-in/admin/create-fulfillment.tool.d.ts +118 -0
  167. package/lib/tools/built-in/admin/create-fulfillment.tool.js +156 -0
  168. package/lib/tools/built-in/admin/create-fulfillment.tool.js.map +1 -0
  169. package/lib/tools/built-in/admin/create-product.tool.d.ts +52 -0
  170. package/lib/tools/built-in/admin/create-product.tool.js +61 -0
  171. package/lib/tools/built-in/admin/create-product.tool.js.map +1 -0
  172. package/lib/tools/built-in/admin/create-variant.tool.d.ts +48 -0
  173. package/lib/tools/built-in/admin/create-variant.tool.js +79 -0
  174. package/lib/tools/built-in/admin/create-variant.tool.js.map +1 -0
  175. package/lib/tools/built-in/admin/entity-field-schemas.d.ts +36 -0
  176. package/lib/tools/built-in/admin/entity-field-schemas.js +63 -0
  177. package/lib/tools/built-in/admin/entity-field-schemas.js.map +1 -0
  178. package/lib/tools/built-in/admin/get-customer.tool.d.ts +28 -0
  179. package/lib/tools/built-in/admin/get-customer.tool.js +55 -0
  180. package/lib/tools/built-in/admin/get-customer.tool.js.map +1 -0
  181. package/lib/tools/built-in/admin/get-order.tool.d.ts +100 -0
  182. package/lib/tools/built-in/admin/get-order.tool.js +68 -0
  183. package/lib/tools/built-in/admin/get-order.tool.js.map +1 -0
  184. package/lib/tools/built-in/admin/get-product.tool.d.ts +69 -0
  185. package/lib/tools/built-in/admin/get-product.tool.js +77 -0
  186. package/lib/tools/built-in/admin/get-product.tool.js.map +1 -0
  187. package/lib/tools/built-in/admin/get-stock-levels.tool.d.ts +23 -0
  188. package/lib/tools/built-in/admin/get-stock-levels.tool.js +61 -0
  189. package/lib/tools/built-in/admin/get-stock-levels.tool.js.map +1 -0
  190. package/lib/tools/built-in/admin/index.d.ts +25 -0
  191. package/lib/tools/built-in/admin/index.js +54 -0
  192. package/lib/tools/built-in/admin/index.js.map +1 -0
  193. package/lib/tools/built-in/admin/list-channels.tool.d.ts +24 -0
  194. package/lib/tools/built-in/admin/list-channels.tool.js +56 -0
  195. package/lib/tools/built-in/admin/list-channels.tool.js.map +1 -0
  196. package/lib/tools/built-in/admin/list-customer-groups.tool.d.ts +23 -0
  197. package/lib/tools/built-in/admin/list-customer-groups.tool.js +52 -0
  198. package/lib/tools/built-in/admin/list-customer-groups.tool.js.map +1 -0
  199. package/lib/tools/built-in/admin/list-customers.tool.d.ts +62 -0
  200. package/lib/tools/built-in/admin/list-customers.tool.js +66 -0
  201. package/lib/tools/built-in/admin/list-customers.tool.js.map +1 -0
  202. package/lib/tools/built-in/admin/list-orders.tool.d.ts +142 -0
  203. package/lib/tools/built-in/admin/list-orders.tool.js +87 -0
  204. package/lib/tools/built-in/admin/list-orders.tool.js.map +1 -0
  205. package/lib/tools/built-in/admin/list-products.tool.d.ts +63 -0
  206. package/lib/tools/built-in/admin/list-products.tool.js +71 -0
  207. package/lib/tools/built-in/admin/list-products.tool.js.map +1 -0
  208. package/lib/tools/built-in/admin/refund-order.tool.d.ts +38 -0
  209. package/lib/tools/built-in/admin/refund-order.tool.js +115 -0
  210. package/lib/tools/built-in/admin/refund-order.tool.js.map +1 -0
  211. package/lib/tools/built-in/admin/set-active-channel.tool.d.ts +22 -0
  212. package/lib/tools/built-in/admin/set-active-channel.tool.js +84 -0
  213. package/lib/tools/built-in/admin/set-active-channel.tool.js.map +1 -0
  214. package/lib/tools/built-in/admin/translation-schemas.d.ts +12 -0
  215. package/lib/tools/built-in/admin/translation-schemas.js +17 -0
  216. package/lib/tools/built-in/admin/translation-schemas.js.map +1 -0
  217. package/lib/tools/built-in/admin/update-customer.tool.d.ts +42 -0
  218. package/lib/tools/built-in/admin/update-customer.tool.js +59 -0
  219. package/lib/tools/built-in/admin/update-customer.tool.js.map +1 -0
  220. package/lib/tools/built-in/admin/update-order-state.tool.d.ts +16 -0
  221. package/lib/tools/built-in/admin/update-order-state.tool.js +58 -0
  222. package/lib/tools/built-in/admin/update-order-state.tool.js.map +1 -0
  223. package/lib/tools/built-in/admin/update-product.tool.d.ts +53 -0
  224. package/lib/tools/built-in/admin/update-product.tool.js +68 -0
  225. package/lib/tools/built-in/admin/update-product.tool.js.map +1 -0
  226. package/lib/tools/built-in/admin/update-variant.tool.d.ts +46 -0
  227. package/lib/tools/built-in/admin/update-variant.tool.js +77 -0
  228. package/lib/tools/built-in/admin/update-variant.tool.js.map +1 -0
  229. package/lib/tools/built-in/admin/upload-asset.tool.d.ts +32 -0
  230. package/lib/tools/built-in/admin/upload-asset.tool.js +56 -0
  231. package/lib/tools/built-in/admin/upload-asset.tool.js.map +1 -0
  232. package/lib/tools/built-in/catalog-query.service.d.ts +21 -0
  233. package/lib/tools/built-in/catalog-query.service.js +128 -0
  234. package/lib/tools/built-in/catalog-query.service.js.map +1 -0
  235. package/lib/tools/built-in/custom-field-input.service.d.ts +10 -0
  236. package/lib/tools/built-in/custom-field-input.service.js +64 -0
  237. package/lib/tools/built-in/custom-field-input.service.js.map +1 -0
  238. package/lib/tools/built-in/email-schema.d.ts +2 -0
  239. package/lib/tools/built-in/email-schema.js +12 -0
  240. package/lib/tools/built-in/email-schema.js.map +1 -0
  241. package/lib/tools/built-in/id-schema.d.ts +3 -0
  242. package/lib/tools/built-in/id-schema.js +11 -0
  243. package/lib/tools/built-in/id-schema.js.map +1 -0
  244. package/lib/tools/built-in/int32-schema.d.ts +4 -0
  245. package/lib/tools/built-in/int32-schema.js +8 -0
  246. package/lib/tools/built-in/int32-schema.js.map +1 -0
  247. package/lib/tools/built-in/list-helpers.d.ts +48 -0
  248. package/lib/tools/built-in/list-helpers.js +76 -0
  249. package/lib/tools/built-in/list-helpers.js.map +1 -0
  250. package/lib/tools/built-in/order-list-helpers.d.ts +20 -0
  251. package/lib/tools/built-in/order-list-helpers.js +48 -0
  252. package/lib/tools/built-in/order-list-helpers.js.map +1 -0
  253. package/lib/tools/built-in/providers.d.ts +2 -0
  254. package/lib/tools/built-in/providers.js +7 -0
  255. package/lib/tools/built-in/providers.js.map +1 -0
  256. package/lib/tools/built-in/remote-asset.d.ts +4 -0
  257. package/lib/tools/built-in/remote-asset.js +54 -0
  258. package/lib/tools/built-in/remote-asset.js.map +1 -0
  259. package/lib/tools/built-in/serializer.service.d.ts +327 -0
  260. package/lib/tools/built-in/serializer.service.js +413 -0
  261. package/lib/tools/built-in/serializer.service.js.map +1 -0
  262. package/lib/tools/built-in/shop/add-to-cart.tool.d.ts +21 -0
  263. package/lib/tools/built-in/shop/add-to-cart.tool.js +100 -0
  264. package/lib/tools/built-in/shop/add-to-cart.tool.js.map +1 -0
  265. package/lib/tools/built-in/shop/address-schema.d.ts +15 -0
  266. package/lib/tools/built-in/shop/address-schema.js +20 -0
  267. package/lib/tools/built-in/shop/address-schema.js.map +1 -0
  268. package/lib/tools/built-in/shop/apply-coupon-code.tool.d.ts +17 -0
  269. package/lib/tools/built-in/shop/apply-coupon-code.tool.js +62 -0
  270. package/lib/tools/built-in/shop/apply-coupon-code.tool.js.map +1 -0
  271. package/lib/tools/built-in/shop/collection-lookup.d.ts +15 -0
  272. package/lib/tools/built-in/shop/collection-lookup.js +35 -0
  273. package/lib/tools/built-in/shop/collection-lookup.js.map +1 -0
  274. package/lib/tools/built-in/shop/get-cart.tool.d.ts +94 -0
  275. package/lib/tools/built-in/shop/get-cart.tool.js +55 -0
  276. package/lib/tools/built-in/shop/get-cart.tool.js.map +1 -0
  277. package/lib/tools/built-in/shop/get-collection.tool.d.ts +42 -0
  278. package/lib/tools/built-in/shop/get-collection.tool.js +64 -0
  279. package/lib/tools/built-in/shop/get-collection.tool.js.map +1 -0
  280. package/lib/tools/built-in/shop/get-eligible-payment-methods.tool.d.ts +26 -0
  281. package/lib/tools/built-in/shop/get-eligible-payment-methods.tool.js +58 -0
  282. package/lib/tools/built-in/shop/get-eligible-payment-methods.tool.js.map +1 -0
  283. package/lib/tools/built-in/shop/get-eligible-shipping-methods.tool.d.ts +30 -0
  284. package/lib/tools/built-in/shop/get-eligible-shipping-methods.tool.js +59 -0
  285. package/lib/tools/built-in/shop/get-eligible-shipping-methods.tool.js.map +1 -0
  286. package/lib/tools/built-in/shop/get-my-account.tool.d.ts +22 -0
  287. package/lib/tools/built-in/shop/get-my-account.tool.js +57 -0
  288. package/lib/tools/built-in/shop/get-my-account.tool.js.map +1 -0
  289. package/lib/tools/built-in/shop/get-order.tool.d.ts +100 -0
  290. package/lib/tools/built-in/shop/get-order.tool.js +67 -0
  291. package/lib/tools/built-in/shop/get-order.tool.js.map +1 -0
  292. package/lib/tools/built-in/shop/get-product.tool.d.ts +57 -0
  293. package/lib/tools/built-in/shop/get-product.tool.js +81 -0
  294. package/lib/tools/built-in/shop/get-product.tool.js.map +1 -0
  295. package/lib/tools/built-in/shop/index.d.ts +19 -0
  296. package/lib/tools/built-in/shop/index.js +42 -0
  297. package/lib/tools/built-in/shop/index.js.map +1 -0
  298. package/lib/tools/built-in/shop/list-collections.tool.d.ts +42 -0
  299. package/lib/tools/built-in/shop/list-collections.tool.js +75 -0
  300. package/lib/tools/built-in/shop/list-collections.tool.js.map +1 -0
  301. package/lib/tools/built-in/shop/list-my-orders.tool.d.ts +100 -0
  302. package/lib/tools/built-in/shop/list-my-orders.tool.js +63 -0
  303. package/lib/tools/built-in/shop/list-my-orders.tool.js.map +1 -0
  304. package/lib/tools/built-in/shop/place-order.tool.d.ts +188 -0
  305. package/lib/tools/built-in/shop/place-order.tool.js +152 -0
  306. package/lib/tools/built-in/shop/place-order.tool.js.map +1 -0
  307. package/lib/tools/built-in/shop/product-search-query.d.ts +4 -0
  308. package/lib/tools/built-in/shop/product-search-query.js +34 -0
  309. package/lib/tools/built-in/shop/product-search-query.js.map +1 -0
  310. package/lib/tools/built-in/shop/remove-coupon-code.tool.d.ts +17 -0
  311. package/lib/tools/built-in/shop/remove-coupon-code.tool.js +63 -0
  312. package/lib/tools/built-in/shop/remove-coupon-code.tool.js.map +1 -0
  313. package/lib/tools/built-in/shop/remove-from-cart.tool.d.ts +17 -0
  314. package/lib/tools/built-in/shop/remove-from-cart.tool.js +58 -0
  315. package/lib/tools/built-in/shop/remove-from-cart.tool.js.map +1 -0
  316. package/lib/tools/built-in/shop/search-products.tool.d.ts +48 -0
  317. package/lib/tools/built-in/shop/search-products.tool.js +95 -0
  318. package/lib/tools/built-in/shop/search-products.tool.js.map +1 -0
  319. package/lib/tools/built-in/shop/set-checkout-details.tool.d.ts +56 -0
  320. package/lib/tools/built-in/shop/set-checkout-details.tool.js +187 -0
  321. package/lib/tools/built-in/shop/set-checkout-details.tool.js.map +1 -0
  322. package/lib/tools/built-in/shop/set-shipping-method.tool.d.ts +17 -0
  323. package/lib/tools/built-in/shop/set-shipping-method.tool.js +58 -0
  324. package/lib/tools/built-in/shop/set-shipping-method.tool.js.map +1 -0
  325. package/lib/tools/built-in/shop/update-cart-line.tool.d.ts +18 -0
  326. package/lib/tools/built-in/shop/update-cart-line.tool.js +60 -0
  327. package/lib/tools/built-in/shop/update-cart-line.tool.js.map +1 -0
  328. package/lib/tools/built-in/string-schemas.d.ts +4 -0
  329. package/lib/tools/built-in/string-schemas.js +13 -0
  330. package/lib/tools/built-in/string-schemas.js.map +1 -0
  331. package/lib/transport/mcp-server.factory.d.ts +13 -0
  332. package/lib/transport/mcp-server.factory.js +32 -0
  333. package/lib/transport/mcp-server.factory.js.map +1 -0
  334. package/lib/transport/mcp-transport.controller.d.ts +77 -0
  335. package/lib/transport/mcp-transport.controller.js +442 -0
  336. package/lib/transport/mcp-transport.controller.js.map +1 -0
  337. package/lib/types.d.ts +432 -0
  338. package/lib/types.js +3 -0
  339. package/lib/types.js.map +1 -0
  340. package/package.json +42 -0
  341. package/src/dashboard/components/activity-block.tsx +72 -0
  342. package/src/dashboard/components/actor-cell.tsx +31 -0
  343. package/src/dashboard/components/connection-dialog.tsx +106 -0
  344. package/src/dashboard/components/empty-cell.tsx +7 -0
  345. package/src/dashboard/components/grants-block.tsx +218 -0
  346. package/src/dashboard/components/stats-block.tsx +275 -0
  347. package/src/dashboard/components/tools-block.tsx +274 -0
  348. package/src/dashboard/components/tooltip-button.tsx +28 -0
  349. package/src/dashboard/components/use-mcp-table-state.ts +47 -0
  350. package/src/dashboard/i18n/ar.po +311 -0
  351. package/src/dashboard/i18n/bg.po +311 -0
  352. package/src/dashboard/i18n/cs.po +311 -0
  353. package/src/dashboard/i18n/de.po +311 -0
  354. package/src/dashboard/i18n/en.po +311 -0
  355. package/src/dashboard/i18n/es.po +311 -0
  356. package/src/dashboard/i18n/fa.po +311 -0
  357. package/src/dashboard/i18n/fr.po +311 -0
  358. package/src/dashboard/i18n/he.po +311 -0
  359. package/src/dashboard/i18n/hr.po +311 -0
  360. package/src/dashboard/i18n/hu.po +311 -0
  361. package/src/dashboard/i18n/it.po +311 -0
  362. package/src/dashboard/i18n/ja.po +311 -0
  363. package/src/dashboard/i18n/ko.po +311 -0
  364. package/src/dashboard/i18n/nb.po +311 -0
  365. package/src/dashboard/i18n/ne.po +311 -0
  366. package/src/dashboard/i18n/nl.po +311 -0
  367. package/src/dashboard/i18n/pl.po +311 -0
  368. package/src/dashboard/i18n/pt_BR.po +311 -0
  369. package/src/dashboard/i18n/pt_PT.po +311 -0
  370. package/src/dashboard/i18n/ro.po +311 -0
  371. package/src/dashboard/i18n/ru.po +311 -0
  372. package/src/dashboard/i18n/sv.po +311 -0
  373. package/src/dashboard/i18n/tr.po +311 -0
  374. package/src/dashboard/i18n/uk.po +311 -0
  375. package/src/dashboard/i18n/uz.po +311 -0
  376. package/src/dashboard/i18n/zh_Hans.po +311 -0
  377. package/src/dashboard/i18n/zh_Hant.po +311 -0
  378. package/src/dashboard/index.tsx +30 -0
  379. package/src/dashboard/mcp-activity-route.tsx +38 -0
  380. package/src/dashboard/mcp-authorize-route.tsx +369 -0
  381. package/src/dashboard/mcp-grants-route.tsx +38 -0
  382. package/src/dashboard/mcp-overview-route.tsx +46 -0
  383. package/src/dashboard/mcp-server-redirect-route.tsx +15 -0
  384. package/src/dashboard/mcp-tools-route.tsx +38 -0
  385. package/src/dashboard/mcp.graphql.ts +127 -0
  386. package/src/dashboard/published-files.spec.ts +54 -0
  387. package/src/dashboard/tsconfig.json +9 -0
  388. package/src/shared/endpoint-paths.ts +8 -0
  389. package/src/shared/loopback.ts +6 -0
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.UpdateCartLineTool = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const core_1 = require("@vendure/core");
15
+ const mcp_sdk_1 = require("@vendure/mcp-sdk");
16
+ const zod_1 = require("zod");
17
+ const active_order_service_1 = require("../active-order.service");
18
+ const id_schema_1 = require("../id-schema");
19
+ const int32_schema_1 = require("../int32-schema");
20
+ const serializer_service_1 = require("../serializer.service");
21
+ const updateCartLineInput = zod_1.z.strictObject({
22
+ orderLineId: id_schema_1.idSchema.describe('Order line ID.'),
23
+ quantity: int32_schema_1.int32Schema.min(0).describe('New quantity for the line, a whole number. 0 removes the line.'),
24
+ });
25
+ let UpdateCartLineTool = class UpdateCartLineTool {
26
+ constructor(activeOrder, orderService, serializer) {
27
+ this.activeOrder = activeOrder;
28
+ this.orderService = orderService;
29
+ this.serializer = serializer;
30
+ }
31
+ async execute(ctx, input) {
32
+ const order = await this.activeOrder.findOrThrow(ctx);
33
+ return this.serializer.orderOrError(await this.orderService.adjustOrderLine(order.ctx, order.id, input.orderLineId, input.quantity));
34
+ }
35
+ };
36
+ exports.UpdateCartLineTool = UpdateCartLineTool;
37
+ exports.UpdateCartLineTool = UpdateCartLineTool = __decorate([
38
+ (0, mcp_sdk_1.McpTool)({
39
+ name: 'update_cart_line',
40
+ toolset: 'shop',
41
+ description: 'Update the quantity of a cart line.',
42
+ keywords: [
43
+ 'change the quantity',
44
+ 'buy more of this one',
45
+ 'increase how many I want',
46
+ 'reduce the amount in my basket',
47
+ 'adjust item count',
48
+ 'update the number of this item',
49
+ ],
50
+ permissions: [core_1.Permission.Public],
51
+ behavior: 'mutating',
52
+ usesActiveOrder: true,
53
+ inputSchema: updateCartLineInput,
54
+ }),
55
+ (0, common_1.Injectable)(),
56
+ __metadata("design:paramtypes", [active_order_service_1.McpActiveOrderService,
57
+ core_1.OrderService,
58
+ serializer_service_1.McpToolSerializerService])
59
+ ], UpdateCartLineTool);
60
+ //# sourceMappingURL=update-cart-line.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-cart-line.tool.js","sourceRoot":"","sources":["../../../../src/tools/built-in/shop/update-cart-line.tool.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,wCAAyE;AACzE,8CAA2D;AAC3D,6BAAwB;AAExB,kEAAgE;AAChE,4CAAwC;AACxC,kDAA8C;AAC9C,8DAAiE;AAEjE,MAAM,mBAAmB,GAAG,OAAC,CAAC,YAAY,CAAC;IACvC,WAAW,EAAE,oBAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC;IAChD,QAAQ,EAAE,0BAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,gEAAgE,CAAC;CAC1G,CAAC,CAAC;AAsBI,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC3B,YACqB,WAAkC,EAClC,YAA0B,EAC1B,UAAoC;QAFpC,gBAAW,GAAX,WAAW,CAAuB;QAClC,iBAAY,GAAZ,YAAY,CAAc;QAC1B,eAAU,GAAV,UAAU,CAA0B;IACtD,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,GAAmB,EAAE,KAA0B;QACzD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACtD,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,CAC/B,MAAM,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,CAClG,CAAC;IACN,CAAC;CACJ,CAAA;AAbY,gDAAkB;6BAAlB,kBAAkB;IAlB9B,IAAA,iBAAO,EAAC;QACL,IAAI,EAAE,kBAAkB;QACxB,OAAO,EAAE,MAAM;QACf,WAAW,EAAE,qCAAqC;QAClD,QAAQ,EAAE;YACN,qBAAqB;YACrB,sBAAsB;YACtB,0BAA0B;YAC1B,gCAAgC;YAChC,mBAAmB;YACnB,gCAAgC;SACnC;QACD,WAAW,EAAE,CAAC,iBAAU,CAAC,MAAM,CAAC;QAChC,QAAQ,EAAE,UAAU;QACpB,eAAe,EAAE,IAAI;QACrB,WAAW,EAAE,mBAAmB;KACnC,CAAC;IACD,IAAA,mBAAU,GAAE;qCAGyB,4CAAqB;QACpB,mBAAY;QACd,6CAAwB;GAJhD,kBAAkB,CAa9B"}
@@ -0,0 +1,4 @@
1
+ import { z } from 'zod';
2
+ export declare const shortText: z.ZodString;
3
+ export declare const longText: z.ZodString;
4
+ export declare function enumString<T extends string>(schema: z.ZodString): z.ZodType<T>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.longText = exports.shortText = void 0;
4
+ exports.enumString = enumString;
5
+ const zod_1 = require("zod");
6
+ // Caps free-text inputs so an oversized value is refused before it reaches the database.
7
+ // shortText matches Vendure's usual varchar(255) columns; longText is for text columns.
8
+ exports.shortText = zod_1.z.string().max(255);
9
+ exports.longText = zod_1.z.string().max(10000);
10
+ function enumString(schema) {
11
+ return schema;
12
+ }
13
+ //# sourceMappingURL=string-schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-schemas.js","sourceRoot":"","sources":["../../../src/tools/built-in/string-schemas.ts"],"names":[],"mappings":";;;AAQA,gCAEC;AAVD,6BAAwB;AAExB,yFAAyF;AACzF,wFAAwF;AAC3E,QAAA,SAAS,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAEhC,QAAA,QAAQ,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAE9C,SAAgB,UAAU,CAAmB,MAAmB;IAC5D,OAAO,MAAiC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { McpServer } from '@modelcontextprotocol/server';
2
+ import { McpToolset } from '@vendure/mcp-sdk';
3
+ import { McpExecutionContext } from '../internal-types';
4
+ import { McpToolRegistryService } from '../registry/mcp-tool-registry.service';
5
+ /**
6
+ * @description
7
+ * Builds a fresh v2 `McpServer` for a single request, registering only the tools the caller is
8
+ * permitted to see. Each tool is registered with its schema, compiled once at bootstrap, and a
9
+ * callback that delegates to the registry's execution entry point.
10
+ *
11
+ * @since 3.8.0
12
+ */
13
+ export declare function createMcpServerForRequest(executionContext: McpExecutionContext, toolset: McpToolset, registry: McpToolRegistryService): Promise<McpServer>;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createMcpServerForRequest = createMcpServerForRequest;
4
+ const server_1 = require("@modelcontextprotocol/server");
5
+ /** Version advertised in the MCP server's `serverInfo`. Cosmetic — the MCP server implementation version. */
6
+ const MCP_SERVER_VERSION = '1.0.0';
7
+ /**
8
+ * @description
9
+ * Builds a fresh v2 `McpServer` for a single request, registering only the tools the caller is
10
+ * permitted to see. Each tool is registered with its schema, compiled once at bootstrap, and a
11
+ * callback that delegates to the registry's execution entry point.
12
+ *
13
+ * @since 3.8.0
14
+ */
15
+ async function createMcpServerForRequest(executionContext, toolset, registry) {
16
+ const server = new server_1.McpServer({ name: `vendure-mcp-${toolset}`, version: MCP_SERVER_VERSION },
17
+ // Overrides the SDK default of true: every request gets a throwaway server with no open connection to notify clients on.
18
+ { capabilities: { tools: { listChanged: false } } });
19
+ const tools = await registry.getExposedTools(executionContext, toolset);
20
+ for (const tool of tools) {
21
+ server.registerTool(tool.name, {
22
+ title: tool.title,
23
+ description: tool.description,
24
+ inputSchema: tool.compiledInputSchema,
25
+ annotations: tool.annotations,
26
+ },
27
+ // The SDK validates `args` against the registered (wire) schema before this runs.
28
+ async (args) => registry.callTool(executionContext, toolset, tool.name, args));
29
+ }
30
+ return server;
31
+ }
32
+ //# sourceMappingURL=mcp-server.factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-server.factory.js","sourceRoot":"","sources":["../../src/transport/mcp-server.factory.ts"],"names":[],"mappings":";;AAiBA,8DAyBC;AA1CD,yDAAyD;AAMzD,6GAA6G;AAC7G,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEnC;;;;;;;GAOG;AACI,KAAK,UAAU,yBAAyB,CAC3C,gBAAqC,EACrC,OAAmB,EACnB,QAAgC;IAEhC,MAAM,MAAM,GAAG,IAAI,kBAAS,CACxB,EAAE,IAAI,EAAE,eAAe,OAAO,EAAE,EAAE,OAAO,EAAE,kBAAkB,EAAE;IAC/D,yHAAyH;IACzH,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,EAAE,CACtD,CAAC;IACF,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,eAAe,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACxE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,CAAC,YAAY,CACf,IAAI,CAAC,IAAI,EACT;YACI,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,mBAAmB;YACrC,WAAW,EAAE,IAAI,CAAC,WAAW;SAChC;QACD,kFAAkF;QAClF,KAAK,EAAE,IAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CACzF,CAAC;IACN,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC"}
@@ -0,0 +1,77 @@
1
+ import { ArgumentsHost } from '@nestjs/common';
2
+ import { ChannelNotFoundError, ChannelService, ConfigService, ExceptionLoggerFilter, I18nRequest } from '@vendure/core';
3
+ import type { Response } from 'express';
4
+ import { ResolvedMcpPluginOptions } from '../internal-types';
5
+ import { McpOauthMetadataService } from '../oauth/oauth-metadata.service';
6
+ import { McpOauthService } from '../oauth/oauth.service';
7
+ import { McpRateLimiterService } from '../rate-limit/mcp-rate-limiter.service';
8
+ import { McpToolRegistryService } from '../registry/mcp-tool-registry.service';
9
+ import { McpShopSessionService } from '../shop-session/mcp-shop-session.service';
10
+ export declare class McpChannelTokenExceptionFilter extends ExceptionLoggerFilter {
11
+ private readonly channelTokenHeader;
12
+ constructor(configService: ConfigService);
13
+ catch(exception: ChannelNotFoundError, host: ArgumentsHost): import("@vendure/core").I18nError | undefined;
14
+ }
15
+ /**
16
+ * @description
17
+ * HTTP transport for the MCP server. Owns authentication, anonymous shop context, the DNS-rebinding
18
+ * front guard, and the anonymous-IP and handshake rate-limit checks (kept here, rather than in the
19
+ * SDK handler, so the `-31029` `error.data` survives). It then delegates JSON-RPC handling to the
20
+ * v2 SDK handler via `toNodeHandler`, passing the resolved Vendure context through the SDK's
21
+ * pass-through `authInfo`.
22
+ */
23
+ export declare class McpTransportController {
24
+ private readonly oauthService;
25
+ private readonly registry;
26
+ private readonly rateLimiter;
27
+ private readonly configService;
28
+ private readonly options;
29
+ private readonly shopSession;
30
+ private readonly channelService;
31
+ private readonly oauthMetadata;
32
+ private readonly nodeHandler;
33
+ private readonly hostGuard?;
34
+ private readonly originGuard?;
35
+ constructor(oauthService: McpOauthService, registry: McpToolRegistryService, rateLimiter: McpRateLimiterService, configService: ConfigService, options: ResolvedMcpPluginOptions, shopSession: McpShopSessionService, channelService: ChannelService, oauthMetadata: McpOauthMetadataService);
36
+ /** The shop endpoint answers 404 on every verb while shop access is switched off. */
37
+ private assertShopEnabled;
38
+ postShop(req: I18nRequest, res: Response, body: unknown): Promise<void>;
39
+ postAdmin(req: I18nRequest, res: Response, body: unknown): Promise<void>;
40
+ getShop(res: Response): void;
41
+ getAdmin(res: Response): void;
42
+ private handlePost;
43
+ /** Each guard writes its own 403 response and returns false when it rejects. */
44
+ private blockedByDnsRebindingGuard;
45
+ /** The refusals that come after the caller is known. Returns true once one has written the response. */
46
+ private refusedBeforeDispatch;
47
+ /** Returns undefined when it has already written the refusal response, rather than a caller. */
48
+ private resolveCaller;
49
+ private refusedByPreAuthRateLimits;
50
+ private anonymousShopExecutionContext;
51
+ /** True when any message in the body asks to open a subscription stream. */
52
+ private callsSubscriptionsListen;
53
+ private sendSubscriptionsUnsupported;
54
+ private preCheckHandshakeRateLimit;
55
+ /** A call missing `params` or a tool name never reaches the registry, so it must be charged here instead. */
56
+ private isRegistryChargedToolCall;
57
+ private sendRateLimitError;
58
+ /** Answers a request the SDK never sees: a JSON-RPC error per addressable message, with the given HTTP status. */
59
+ private sendRefusal;
60
+ /** One error per message when the body is a batch, so the client can match each refusal to its request. */
61
+ private refusalPayload;
62
+ private requestId;
63
+ /** Narrows an unparsed body entry to an object whose fields can be read; a primitive is not a message. */
64
+ private isMessage;
65
+ private usableId;
66
+ private buildAuthInfo;
67
+ private authenticateBearerToken;
68
+ private setAuthChallenge;
69
+ private methodNotAllowed;
70
+ private getBearerToken;
71
+ private createAnonymousShopContext;
72
+ private getVendureSessionToken;
73
+ private setVendureSessionToken;
74
+ /** Same precedence as core's RequestContextService: the query parameter wins over the header. */
75
+ private getChannelToken;
76
+ private getHeader;
77
+ }
@@ -0,0 +1,442 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.McpTransportController = exports.McpChannelTokenExceptionFilter = void 0;
16
+ const node_1 = require("@modelcontextprotocol/node");
17
+ const server_1 = require("@modelcontextprotocol/server");
18
+ const common_1 = require("@nestjs/common");
19
+ const core_1 = require("@vendure/core");
20
+ const constants_1 = require("../constants");
21
+ const get_client_ip_1 = require("../get-client-ip");
22
+ const get_language_code_1 = require("../get-language-code");
23
+ const oauth_error_1 = require("../oauth/oauth-error");
24
+ const oauth_metadata_service_1 = require("../oauth/oauth-metadata.service");
25
+ const oauth_service_1 = require("../oauth/oauth.service");
26
+ const mcp_rate_limiter_service_1 = require("../rate-limit/mcp-rate-limiter.service");
27
+ const mcp_tool_registry_service_1 = require("../registry/mcp-tool-registry.service");
28
+ const mcp_shop_session_service_1 = require("../shop-session/mcp-shop-session.service");
29
+ const mcp_server_factory_1 = require("./mcp-server.factory");
30
+ // Deliberately not a valid tool or method name, so it never collides with a real one.
31
+ const MALFORMED_SUBJECT = 'malformed';
32
+ // Converts an invalid channel token to a 400 instead of a 500, keeping Vendure's default response format and logging.
33
+ let McpChannelTokenExceptionFilter = class McpChannelTokenExceptionFilter extends core_1.ExceptionLoggerFilter {
34
+ constructor(configService) {
35
+ super(configService);
36
+ this.channelTokenHeader = configService.apiOptions.channelTokenKey;
37
+ }
38
+ catch(exception, host) {
39
+ return super.catch(new common_1.BadRequestException(`The ${this.channelTokenHeader} query parameter or header does not name a sales channel of this server.`), host);
40
+ }
41
+ };
42
+ exports.McpChannelTokenExceptionFilter = McpChannelTokenExceptionFilter;
43
+ exports.McpChannelTokenExceptionFilter = McpChannelTokenExceptionFilter = __decorate([
44
+ (0, common_1.Catch)(core_1.ChannelNotFoundError),
45
+ __metadata("design:paramtypes", [core_1.ConfigService])
46
+ ], McpChannelTokenExceptionFilter);
47
+ /**
48
+ * @description
49
+ * HTTP transport for the MCP server. Owns authentication, anonymous shop context, the DNS-rebinding
50
+ * front guard, and the anonymous-IP and handshake rate-limit checks (kept here, rather than in the
51
+ * SDK handler, so the `-31029` `error.data` survives). It then delegates JSON-RPC handling to the
52
+ * v2 SDK handler via `toNodeHandler`, passing the resolved Vendure context through the SDK's
53
+ * pass-through `authInfo`.
54
+ */
55
+ let McpTransportController = class McpTransportController {
56
+ constructor(oauthService, registry, rateLimiter, configService, options, shopSession, channelService, oauthMetadata) {
57
+ var _a, _b;
58
+ this.oauthService = oauthService;
59
+ this.registry = registry;
60
+ this.rateLimiter = rateLimiter;
61
+ this.configService = configService;
62
+ this.options = options;
63
+ this.shopSession = shopSession;
64
+ this.channelService = channelService;
65
+ this.oauthMetadata = oauthMetadata;
66
+ const handler = (0, server_1.createMcpHandler)(async (mcpCtx) => {
67
+ var _a;
68
+ const extra = (_a = mcpCtx.authInfo) === null || _a === void 0 ? void 0 : _a.extra;
69
+ if (!(extra === null || extra === void 0 ? void 0 : extra.executionContext) || !extra.toolset) {
70
+ throw new Error('MCP request is missing its resolved execution context');
71
+ }
72
+ return (0, mcp_server_factory_1.createMcpServerForRequest)(extra.executionContext, extra.toolset, this.registry);
73
+ }, {
74
+ onerror: error => {
75
+ // JSON.stringify escapes caller text to prevent log forgery
76
+ core_1.Logger.error(`MCP request handling failed: ${JSON.stringify(error.message)}`, constants_1.loggerCtx);
77
+ },
78
+ });
79
+ this.nodeHandler = (0, node_1.toNodeHandler)(handler, {
80
+ onerror: error => {
81
+ core_1.Logger.error(`MCP transport adapter error: ${JSON.stringify(error.message)}`, constants_1.loggerCtx);
82
+ },
83
+ });
84
+ const dns = this.options.dnsRebinding;
85
+ this.hostGuard = ((_a = dns === null || dns === void 0 ? void 0 : dns.allowedHosts) === null || _a === void 0 ? void 0 : _a.length) ? (0, node_1.hostHeaderValidation)(dns.allowedHosts) : undefined;
86
+ this.originGuard = ((_b = dns === null || dns === void 0 ? void 0 : dns.allowedOrigins) === null || _b === void 0 ? void 0 : _b.length) ? (0, node_1.originValidation)(dns.allowedOrigins) : undefined;
87
+ }
88
+ /** The shop endpoint answers 404 on every verb while shop access is switched off. */
89
+ assertShopEnabled() {
90
+ if (this.options.shopAccess === 'disabled') {
91
+ throw new common_1.NotFoundException();
92
+ }
93
+ }
94
+ async postShop(req, res, body) {
95
+ this.assertShopEnabled();
96
+ return this.handlePost('shop', req, res, body);
97
+ }
98
+ async postAdmin(req, res, body) {
99
+ return this.handlePost('admin', req, res, body);
100
+ }
101
+ getShop(res) {
102
+ this.assertShopEnabled();
103
+ this.methodNotAllowed(res);
104
+ }
105
+ getAdmin(res) {
106
+ this.methodNotAllowed(res);
107
+ }
108
+ async handlePost(toolset, req, res, body) {
109
+ var _a;
110
+ if (this.blockedByDnsRebindingGuard(req, res)) {
111
+ return;
112
+ }
113
+ const token = this.getBearerToken(this.getHeader(req.headers, 'authorization'));
114
+ const clientIp = (0, get_client_ip_1.getClientIp)(req);
115
+ const executionContext = await this.resolveCaller(toolset, req, res, body, token, clientIp);
116
+ if (!executionContext) {
117
+ return;
118
+ }
119
+ const isJson = (0, server_1.isJsonContentType)((_a = this.getHeader(req.headers, 'content-type')) !== null && _a !== void 0 ? _a : '');
120
+ if (await this.refusedBeforeDispatch(toolset, res, body, isJson, executionContext)) {
121
+ return;
122
+ }
123
+ req.auth = this.buildAuthInfo(executionContext, toolset, token);
124
+ await this.nodeHandler(req, res, isJson ? body : undefined);
125
+ }
126
+ /** Each guard writes its own 403 response and returns false when it rejects. */
127
+ blockedByDnsRebindingGuard(req, res) {
128
+ if (this.hostGuard && !this.hostGuard(req, res)) {
129
+ return true;
130
+ }
131
+ if (this.originGuard && !this.originGuard(req, res)) {
132
+ return true;
133
+ }
134
+ return false;
135
+ }
136
+ /** The refusals that come after the caller is known. Returns true once one has written the response. */
137
+ async refusedBeforeDispatch(toolset, res, body, isJson, executionContext) {
138
+ // Charged even for a body the SDK will refuse, since resolving the caller already cost a database round trip.
139
+ const preCheckExceeded = await this.preCheckHandshakeRateLimit(body, toolset, executionContext);
140
+ if (preCheckExceeded) {
141
+ this.sendRateLimitError(res, body, preCheckExceeded);
142
+ return true;
143
+ }
144
+ if (isJson && this.callsSubscriptionsListen(body)) {
145
+ this.sendSubscriptionsUnsupported(res, body);
146
+ return true;
147
+ }
148
+ return false;
149
+ }
150
+ /** Returns undefined when it has already written the refusal response, rather than a caller. */
151
+ async resolveCaller(toolset, req, res, body, token, clientIp) {
152
+ if (toolset === 'shop' && this.options.shopAccess === 'authenticated' && !token) {
153
+ this.setAuthChallenge(res, 'shop');
154
+ throw new common_1.UnauthorizedException('Shop MCP endpoint requires a Bearer token');
155
+ }
156
+ if (await this.refusedByPreAuthRateLimits(toolset, res, body, token, clientIp)) {
157
+ return undefined;
158
+ }
159
+ if (toolset === 'admin' && !token) {
160
+ this.setAuthChallenge(res, 'admin');
161
+ throw new common_1.UnauthorizedException('Admin MCP endpoint requires a Bearer token');
162
+ }
163
+ if (token) {
164
+ const authContext = await this.authenticateBearerToken(token, toolset, req, res, clientIp);
165
+ return Object.assign(Object.assign({}, authContext), { clientIp });
166
+ }
167
+ return this.anonymousShopExecutionContext(req, res, clientIp);
168
+ }
169
+ async refusedByPreAuthRateLimits(toolset, res, body, token, clientIp) {
170
+ // Rate-limit anonymous shop requests by IP before accessing the database.
171
+ if (toolset === 'shop' && !token) {
172
+ const exceeded = await this.rateLimiter.checkAnonymousIpRateLimit(toolset, clientIp);
173
+ if (exceeded) {
174
+ this.sendRateLimitError(res, body, exceeded);
175
+ return true;
176
+ }
177
+ }
178
+ // Checked before the token is looked up, so a flood of made-up tokens does not cost a database query each.
179
+ if (token) {
180
+ const exceeded = await this.rateLimiter.checkBearerAuthFailureRateLimit(clientIp);
181
+ if (exceeded) {
182
+ this.sendRateLimitError(res, body, exceeded);
183
+ return true;
184
+ }
185
+ }
186
+ return false;
187
+ }
188
+ // Most MCP clients cannot persist headers, so the session token usually arrives as a tool argument.
189
+ async anonymousShopExecutionContext(req, res, clientIp) {
190
+ var _a;
191
+ try {
192
+ const ctx = await this.createAnonymousShopContext(req, this.getVendureSessionToken(req.headers), this.getChannelToken(req));
193
+ // Preserve the session token from the header in the response so the client can reuse it.
194
+ this.setVendureSessionToken(res, (_a = ctx.session) === null || _a === void 0 ? void 0 : _a.token);
195
+ return { ctx, clientIp };
196
+ }
197
+ catch (e) {
198
+ if (e instanceof common_1.UnauthorizedException) {
199
+ this.setAuthChallenge(res, 'shop');
200
+ }
201
+ throw e;
202
+ }
203
+ }
204
+ /** True when any message in the body asks to open a subscription stream. */
205
+ callsSubscriptionsListen(body) {
206
+ const messages = Array.isArray(body) ? body : [body];
207
+ return messages.some(message => this.isMessage(message) && message.method === 'subscriptions/listen');
208
+ }
209
+ // Refused because this plugin never publishes a notification, so such a stream could only ever deliver keep-alive pings.
210
+ sendSubscriptionsUnsupported(res, body) {
211
+ // -32601 with HTTP 404 is exactly how the SDK answers a method it does not implement.
212
+ this.sendRefusal(res, 404, { code: -32601, message: 'Method not found: subscriptions/listen' }, body);
213
+ }
214
+ // Notifications are charged too, since they still reach the transport even though they get no reply.
215
+ async preCheckHandshakeRateLimit(body, toolset, executionContext) {
216
+ const messages = Array.isArray(body) ? body : [body];
217
+ for (const message of messages) {
218
+ if (this.isRegistryChargedToolCall(message)) {
219
+ continue;
220
+ }
221
+ const method = this.isMessage(message) ? message.method : undefined;
222
+ const exceeded = await this.rateLimiter.checkRateLimit({
223
+ executionContext,
224
+ endpoint: toolset,
225
+ subject: typeof method === 'string' ? method : MALFORMED_SUBJECT,
226
+ });
227
+ if (exceeded) {
228
+ return exceeded;
229
+ }
230
+ }
231
+ return undefined;
232
+ }
233
+ /** A call missing `params` or a tool name never reaches the registry, so it must be charged here instead. */
234
+ isRegistryChargedToolCall(message) {
235
+ var _a;
236
+ return (this.isMessage(message) &&
237
+ message.method === 'tools/call' &&
238
+ typeof ((_a = message.params) === null || _a === void 0 ? void 0 : _a.name) === 'string');
239
+ }
240
+ // HTTP 429 lets proxies and monitoring treat this as a proper refusal; the JSON-RPC body adds retry details for MCP-aware clients.
241
+ sendRateLimitError(res, body, exceeded) {
242
+ res.setHeader('Retry-After', String(exceeded.retryAfterSeconds));
243
+ this.sendRefusal(res, 429, {
244
+ code: constants_1.RATE_LIMIT_ERROR_CODE,
245
+ message: exceeded.message,
246
+ data: {
247
+ retryAfterSeconds: exceeded.retryAfterSeconds,
248
+ scope: exceeded.scope,
249
+ },
250
+ }, body);
251
+ }
252
+ /** Answers a request the SDK never sees: a JSON-RPC error per addressable message, with the given HTTP status. */
253
+ sendRefusal(res, status, error, body) {
254
+ res.status(status);
255
+ res.setHeader('Content-Type', 'application/json');
256
+ res.send(JSON.stringify(this.refusalPayload(body, error)));
257
+ }
258
+ /** One error per message when the body is a batch, so the client can match each refusal to its request. */
259
+ refusalPayload(body, error) {
260
+ if (Array.isArray(body)) {
261
+ const errors = body
262
+ // Only messages with an id JSON-RPC allows can be addressed by a reply.
263
+ .filter(message => this.usableId(message) !== undefined)
264
+ .map(message => ({
265
+ jsonrpc: '2.0',
266
+ id: this.requestId(message),
267
+ error,
268
+ }));
269
+ if (errors.length > 0) {
270
+ return errors;
271
+ }
272
+ }
273
+ return { jsonrpc: '2.0', id: this.requestId(body), error };
274
+ }
275
+ requestId(message) {
276
+ var _a;
277
+ return (_a = this.usableId(message)) !== null && _a !== void 0 ? _a : null;
278
+ }
279
+ /** Narrows an unparsed body entry to an object whose fields can be read; a primitive is not a message. */
280
+ isMessage(value) {
281
+ return typeof value === 'object' && value !== null;
282
+ }
283
+ usableId(message) {
284
+ if (!this.isMessage(message)) {
285
+ return undefined;
286
+ }
287
+ const { id } = message;
288
+ return typeof id === 'string' || typeof id === 'number' || id === null ? id : undefined;
289
+ }
290
+ buildAuthInfo(executionContext, toolset, token) {
291
+ const grant = executionContext.grant;
292
+ return {
293
+ // Pass-through only; the SDK does not verify this token.
294
+ token: token !== null && token !== void 0 ? token : 'anonymous',
295
+ clientId: (grant === null || grant === void 0 ? void 0 : grant.oauthClientId) != null ? String(grant.oauthClientId) : 'anonymous',
296
+ scopes: [],
297
+ expiresAt: (grant === null || grant === void 0 ? void 0 : grant.accessTokenExpiresAt)
298
+ ? Math.floor(new Date(grant.accessTokenExpiresAt).getTime() / 1000)
299
+ : undefined,
300
+ extra: { executionContext, toolset },
301
+ };
302
+ }
303
+ async authenticateBearerToken(token, toolset, req, res, clientIp) {
304
+ try {
305
+ return await this.oauthService.authenticateBearerToken(token, toolset, req);
306
+ }
307
+ catch (e) {
308
+ if (e instanceof common_1.UnauthorizedException) {
309
+ // An access token that reached the end of its lifetime is answered by refreshing,
310
+ // so it is not a failed authentication attempt and must not spend the budget that
311
+ // is there to stop token guessing.
312
+ if (!(e instanceof oauth_error_1.McpAccessTokenExpiredError)) {
313
+ await this.rateLimiter.recordBearerAuthFailure(clientIp);
314
+ }
315
+ this.setAuthChallenge(res, toolset, { invalidToken: true, description: e.message });
316
+ }
317
+ throw e;
318
+ }
319
+ }
320
+ // Per RFC 6750 §3.1: a bare challenge means no credentials were sent, while `error="invalid_token"` means one was sent and rejected.
321
+ setAuthChallenge(res, toolset, options) {
322
+ const params = [`resource_metadata="${this.oauthMetadata.protectedResourceMetadataUrl(toolset)}"`];
323
+ if (options === null || options === void 0 ? void 0 : options.invalidToken) {
324
+ params.push('error="invalid_token"');
325
+ if (options.description) {
326
+ // A header parameter is a quoted string, so only printable ASCII without a quote or backslash can go inside it.
327
+ const description = options.description.replace(/[^\x20-\x7e]|["\\]/g, '');
328
+ params.push(`error_description="${description}"`);
329
+ }
330
+ }
331
+ res.setHeader('WWW-Authenticate', `Bearer ${params.join(', ')}`);
332
+ }
333
+ methodNotAllowed(res) {
334
+ res.setHeader('Allow', 'POST');
335
+ res.status(405).send('Method Not Allowed');
336
+ }
337
+ getBearerToken(header) {
338
+ if (header === undefined) {
339
+ return undefined;
340
+ }
341
+ if (header.slice(0, 6).toLowerCase() !== 'bearer') {
342
+ return undefined;
343
+ }
344
+ const afterScheme = header.slice(6);
345
+ // "Bearerabc" is not a bearer header: the scheme has to be separated from the token.
346
+ if (!/^\s/.test(afterScheme)) {
347
+ return undefined;
348
+ }
349
+ const tokenStart = afterScheme.search(/\S/);
350
+ if (tokenStart === -1) {
351
+ return undefined;
352
+ }
353
+ return afterScheme.slice(tokenStart);
354
+ }
355
+ async createAnonymousShopContext(req, sessionToken, channelToken) {
356
+ const resolution = await this.shopSession.resolveHeaderToken(sessionToken);
357
+ if (resolution.kind === 'refused') {
358
+ throw new common_1.UnauthorizedException(resolution.message);
359
+ }
360
+ const channel = await this.channelService.getChannelFromToken(channelToken !== null && channelToken !== void 0 ? channelToken : '');
361
+ return new core_1.RequestContext({
362
+ apiType: 'shop',
363
+ channel,
364
+ languageCode: (0, get_language_code_1.getLanguageCodeFromQuery)(req),
365
+ session: resolution.session,
366
+ isAuthorized: false,
367
+ authorizedAsOwnerOnly: true,
368
+ req,
369
+ translationFn: req.t,
370
+ });
371
+ }
372
+ getVendureSessionToken(headers) {
373
+ const key = this.configService.authOptions.authTokenHeaderKey;
374
+ const value = this.getHeader(headers, key);
375
+ return value || undefined;
376
+ }
377
+ setVendureSessionToken(res, token) {
378
+ if (token) {
379
+ res.setHeader(this.configService.authOptions.authTokenHeaderKey, token);
380
+ }
381
+ }
382
+ /** Same precedence as core's RequestContextService: the query parameter wins over the header. */
383
+ getChannelToken(req) {
384
+ var _a;
385
+ const key = this.configService.apiOptions.channelTokenKey;
386
+ const fromQuery = (_a = req.query) === null || _a === void 0 ? void 0 : _a[key];
387
+ if (typeof fromQuery === 'string' && fromQuery) {
388
+ return fromQuery;
389
+ }
390
+ const value = this.getHeader(req.headers, key);
391
+ return value || undefined;
392
+ }
393
+ getHeader(headers, name) {
394
+ const value = headers[name.toLowerCase()];
395
+ return Array.isArray(value) ? value[0] : value;
396
+ }
397
+ };
398
+ exports.McpTransportController = McpTransportController;
399
+ __decorate([
400
+ (0, common_1.Post)('shop'),
401
+ __param(0, (0, common_1.Req)()),
402
+ __param(1, (0, common_1.Res)()),
403
+ __param(2, (0, common_1.Body)()),
404
+ __metadata("design:type", Function),
405
+ __metadata("design:paramtypes", [Object, Object, Object]),
406
+ __metadata("design:returntype", Promise)
407
+ ], McpTransportController.prototype, "postShop", null);
408
+ __decorate([
409
+ (0, common_1.Post)('admin'),
410
+ __param(0, (0, common_1.Req)()),
411
+ __param(1, (0, common_1.Res)()),
412
+ __param(2, (0, common_1.Body)()),
413
+ __metadata("design:type", Function),
414
+ __metadata("design:paramtypes", [Object, Object, Object]),
415
+ __metadata("design:returntype", Promise)
416
+ ], McpTransportController.prototype, "postAdmin", null);
417
+ __decorate([
418
+ (0, common_1.Get)('shop'),
419
+ __param(0, (0, common_1.Res)()),
420
+ __metadata("design:type", Function),
421
+ __metadata("design:paramtypes", [Object]),
422
+ __metadata("design:returntype", void 0)
423
+ ], McpTransportController.prototype, "getShop", null);
424
+ __decorate([
425
+ (0, common_1.Get)('admin'),
426
+ __param(0, (0, common_1.Res)()),
427
+ __metadata("design:type", Function),
428
+ __metadata("design:paramtypes", [Object]),
429
+ __metadata("design:returntype", void 0)
430
+ ], McpTransportController.prototype, "getAdmin", null);
431
+ exports.McpTransportController = McpTransportController = __decorate([
432
+ (0, common_1.UseFilters)(McpChannelTokenExceptionFilter),
433
+ (0, common_1.Controller)('mcp'),
434
+ __param(4, (0, common_1.Inject)(constants_1.MCP_PLUGIN_OPTIONS)),
435
+ __metadata("design:paramtypes", [oauth_service_1.McpOauthService,
436
+ mcp_tool_registry_service_1.McpToolRegistryService,
437
+ mcp_rate_limiter_service_1.McpRateLimiterService,
438
+ core_1.ConfigService, Object, mcp_shop_session_service_1.McpShopSessionService,
439
+ core_1.ChannelService,
440
+ oauth_metadata_service_1.McpOauthMetadataService])
441
+ ], McpTransportController);
442
+ //# sourceMappingURL=mcp-transport.controller.js.map