@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.
- package/lib/api/api-extensions.d.ts +2 -0
- package/lib/api/api-extensions.js +239 -0
- package/lib/api/api-extensions.js.map +1 -0
- package/lib/api/mcp-actor.service.d.ts +19 -0
- package/lib/api/mcp-actor.service.js +52 -0
- package/lib/api/mcp-actor.service.js.map +1 -0
- package/lib/api/mcp-admin.resolver.d.ts +105 -0
- package/lib/api/mcp-admin.resolver.js +463 -0
- package/lib/api/mcp-admin.resolver.js.map +1 -0
- package/lib/api/mcp-shop.resolver.d.ts +25 -0
- package/lib/api/mcp-shop.resolver.js +74 -0
- package/lib/api/mcp-shop.resolver.js.map +1 -0
- package/lib/check-options.d.ts +7 -0
- package/lib/check-options.js +130 -0
- package/lib/check-options.js.map +1 -0
- package/lib/constants.d.ts +48 -0
- package/lib/constants.js +72 -0
- package/lib/constants.js.map +1 -0
- package/lib/delete-in-batches.d.ts +5 -0
- package/lib/delete-in-batches.js +28 -0
- package/lib/delete-in-batches.js.map +1 -0
- package/lib/entities/index.d.ts +5 -0
- package/lib/entities/index.js +22 -0
- package/lib/entities/index.js.map +1 -0
- package/lib/entities/mcp-authorization-code.entity.d.ts +33 -0
- package/lib/entities/mcp-authorization-code.entity.js +77 -0
- package/lib/entities/mcp-authorization-code.entity.js.map +1 -0
- package/lib/entities/mcp-authorization-request.entity.d.ts +31 -0
- package/lib/entities/mcp-authorization-request.entity.js +73 -0
- package/lib/entities/mcp-authorization-request.entity.js.map +1 -0
- package/lib/entities/mcp-oauth-client.entity.d.ts +56 -0
- package/lib/entities/mcp-oauth-client.entity.js +70 -0
- package/lib/entities/mcp-oauth-client.entity.js.map +1 -0
- package/lib/entities/mcp-oauth-grant.entity.d.ts +77 -0
- package/lib/entities/mcp-oauth-grant.entity.js +121 -0
- package/lib/entities/mcp-oauth-grant.entity.js.map +1 -0
- package/lib/entities/mcp-tool-call-log.entity.d.ts +50 -0
- package/lib/entities/mcp-tool-call-log.entity.js +101 -0
- package/lib/entities/mcp-tool-call-log.entity.js.map +1 -0
- package/lib/events/mcp-tool-call.event.d.ts +17 -0
- package/lib/events/mcp-tool-call.event.js +23 -0
- package/lib/events/mcp-tool-call.event.js.map +1 -0
- package/lib/get-client-ip.d.ts +2 -0
- package/lib/get-client-ip.js +10 -0
- package/lib/get-client-ip.js.map +1 -0
- package/lib/get-language-code.d.ts +3 -0
- package/lib/get-language-code.js +12 -0
- package/lib/get-language-code.js.map +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +26 -0
- package/lib/index.js.map +1 -0
- package/lib/internal-types.d.ts +27 -0
- package/lib/internal-types.js +3 -0
- package/lib/internal-types.js.map +1 -0
- package/lib/logging/mcp-tool-call-log-retention.service.d.ts +8 -0
- package/lib/logging/mcp-tool-call-log-retention.service.js +54 -0
- package/lib/logging/mcp-tool-call-log-retention.service.js.map +1 -0
- package/lib/logging/mcp-tool-call-log.service.d.ts +24 -0
- package/lib/logging/mcp-tool-call-log.service.js +128 -0
- package/lib/logging/mcp-tool-call-log.service.js.map +1 -0
- package/lib/oauth/cimd/cimd-client-resolver.service.d.ts +18 -0
- package/lib/oauth/cimd/cimd-client-resolver.service.js +109 -0
- package/lib/oauth/cimd/cimd-client-resolver.service.js.map +1 -0
- package/lib/oauth/cimd/cimd-document.d.ts +11 -0
- package/lib/oauth/cimd/cimd-document.js +66 -0
- package/lib/oauth/cimd/cimd-document.js.map +1 -0
- package/lib/oauth/cimd/cimd-fetch.d.ts +14 -0
- package/lib/oauth/cimd/cimd-fetch.js +192 -0
- package/lib/oauth/cimd/cimd-fetch.js.map +1 -0
- package/lib/oauth/cimd/cimd-url.d.ts +5 -0
- package/lib/oauth/cimd/cimd-url.js +94 -0
- package/lib/oauth/cimd/cimd-url.js.map +1 -0
- package/lib/oauth/grant-session.service.d.ts +19 -0
- package/lib/oauth/grant-session.service.js +141 -0
- package/lib/oauth/grant-session.service.js.map +1 -0
- package/lib/oauth/oauth-error.d.ts +18 -0
- package/lib/oauth/oauth-error.js +60 -0
- package/lib/oauth/oauth-error.js.map +1 -0
- package/lib/oauth/oauth-metadata.service.d.ts +34 -0
- package/lib/oauth/oauth-metadata.service.js +107 -0
- package/lib/oauth/oauth-metadata.service.js.map +1 -0
- package/lib/oauth/oauth-retention.service.d.ts +23 -0
- package/lib/oauth/oauth-retention.service.js +103 -0
- package/lib/oauth/oauth-retention.service.js.map +1 -0
- package/lib/oauth/oauth-types.d.ts +61 -0
- package/lib/oauth/oauth-types.js +32 -0
- package/lib/oauth/oauth-types.js.map +1 -0
- package/lib/oauth/oauth-utils.d.ts +20 -0
- package/lib/oauth/oauth-utils.js +111 -0
- package/lib/oauth/oauth-utils.js.map +1 -0
- package/lib/oauth/oauth.controller.d.ts +31 -0
- package/lib/oauth/oauth.controller.js +132 -0
- package/lib/oauth/oauth.controller.js.map +1 -0
- package/lib/oauth/oauth.service.d.ts +69 -0
- package/lib/oauth/oauth.service.js +650 -0
- package/lib/oauth/oauth.service.js.map +1 -0
- package/lib/oauth/token-hash.d.ts +6 -0
- package/lib/oauth/token-hash.js +21 -0
- package/lib/oauth/token-hash.js.map +1 -0
- package/lib/plugin.d.ts +54 -0
- package/lib/plugin.js +171 -0
- package/lib/plugin.js.map +1 -0
- package/lib/rate-limit/ip-bucket-key.d.ts +1 -0
- package/lib/rate-limit/ip-bucket-key.js +35 -0
- package/lib/rate-limit/ip-bucket-key.js.map +1 -0
- package/lib/rate-limit/mcp-oauth-rate-limit.guard.d.ts +20 -0
- package/lib/rate-limit/mcp-oauth-rate-limit.guard.js +63 -0
- package/lib/rate-limit/mcp-oauth-rate-limit.guard.js.map +1 -0
- package/lib/rate-limit/mcp-rate-limiter.service.d.ts +47 -0
- package/lib/rate-limit/mcp-rate-limiter.service.js +248 -0
- package/lib/rate-limit/mcp-rate-limiter.service.js.map +1 -0
- package/lib/registry/bm25.d.ts +12 -0
- package/lib/registry/bm25.js +60 -0
- package/lib/registry/bm25.js.map +1 -0
- package/lib/registry/mcp-tool-execution.service.d.ts +45 -0
- package/lib/registry/mcp-tool-execution.service.js +72 -0
- package/lib/registry/mcp-tool-execution.service.js.map +1 -0
- package/lib/registry/mcp-tool-registry.service.d.ts +89 -0
- package/lib/registry/mcp-tool-registry.service.js +668 -0
- package/lib/registry/mcp-tool-registry.service.js.map +1 -0
- package/lib/registry/mcp-tool-schema.service.d.ts +42 -0
- package/lib/registry/mcp-tool-schema.service.js +229 -0
- package/lib/registry/mcp-tool-schema.service.js.map +1 -0
- package/lib/registry/registry-types.d.ts +32 -0
- package/lib/registry/registry-types.js +3 -0
- package/lib/registry/registry-types.js.map +1 -0
- package/lib/resolve-options.d.ts +7 -0
- package/lib/resolve-options.js +85 -0
- package/lib/resolve-options.js.map +1 -0
- package/lib/shared/endpoint-paths.d.ts +8 -0
- package/lib/shared/endpoint-paths.js +12 -0
- package/lib/shared/endpoint-paths.js.map +1 -0
- package/lib/shared/loopback.d.ts +2 -0
- package/lib/shared/loopback.js +9 -0
- package/lib/shared/loopback.js.map +1 -0
- package/lib/shop-session/mcp-shop-session.service.d.ts +47 -0
- package/lib/shop-session/mcp-shop-session.service.js +132 -0
- package/lib/shop-session/mcp-shop-session.service.js.map +1 -0
- package/lib/tasks/mcp-oauth-retention.task.d.ts +9 -0
- package/lib/tasks/mcp-oauth-retention.task.js +21 -0
- package/lib/tasks/mcp-oauth-retention.task.js.map +1 -0
- package/lib/tasks/mcp-tool-call-log-retention.task.d.ts +7 -0
- package/lib/tasks/mcp-tool-call-log-retention.task.js +22 -0
- package/lib/tasks/mcp-tool-call-log-retention.task.js.map +1 -0
- package/lib/tools/built-in/active-order.service.d.ts +26 -0
- package/lib/tools/built-in/active-order.service.js +125 -0
- package/lib/tools/built-in/active-order.service.js.map +1 -0
- package/lib/tools/built-in/admin/add-customer-to-group.tool.d.ts +23 -0
- package/lib/tools/built-in/admin/add-customer-to-group.tool.js +68 -0
- package/lib/tools/built-in/admin/add-customer-to-group.tool.js.map +1 -0
- package/lib/tools/built-in/admin/add-note-to-order.tool.d.ts +104 -0
- package/lib/tools/built-in/admin/add-note-to-order.tool.js +66 -0
- package/lib/tools/built-in/admin/add-note-to-order.tool.js.map +1 -0
- package/lib/tools/built-in/admin/adjust-stock.tool.d.ts +26 -0
- package/lib/tools/built-in/admin/adjust-stock.tool.js +88 -0
- package/lib/tools/built-in/admin/adjust-stock.tool.js.map +1 -0
- package/lib/tools/built-in/admin/cancel-order.tool.d.ts +17 -0
- package/lib/tools/built-in/admin/cancel-order.tool.js +60 -0
- package/lib/tools/built-in/admin/cancel-order.tool.js.map +1 -0
- package/lib/tools/built-in/admin/channel-access.d.ts +2 -0
- package/lib/tools/built-in/admin/channel-access.js +9 -0
- package/lib/tools/built-in/admin/channel-access.js.map +1 -0
- package/lib/tools/built-in/admin/create-customer.tool.d.ts +41 -0
- package/lib/tools/built-in/admin/create-customer.tool.js +57 -0
- package/lib/tools/built-in/admin/create-customer.tool.js.map +1 -0
- package/lib/tools/built-in/admin/create-fulfillment.tool.d.ts +118 -0
- package/lib/tools/built-in/admin/create-fulfillment.tool.js +156 -0
- package/lib/tools/built-in/admin/create-fulfillment.tool.js.map +1 -0
- package/lib/tools/built-in/admin/create-product.tool.d.ts +52 -0
- package/lib/tools/built-in/admin/create-product.tool.js +61 -0
- package/lib/tools/built-in/admin/create-product.tool.js.map +1 -0
- package/lib/tools/built-in/admin/create-variant.tool.d.ts +48 -0
- package/lib/tools/built-in/admin/create-variant.tool.js +79 -0
- package/lib/tools/built-in/admin/create-variant.tool.js.map +1 -0
- package/lib/tools/built-in/admin/entity-field-schemas.d.ts +36 -0
- package/lib/tools/built-in/admin/entity-field-schemas.js +63 -0
- package/lib/tools/built-in/admin/entity-field-schemas.js.map +1 -0
- package/lib/tools/built-in/admin/get-customer.tool.d.ts +28 -0
- package/lib/tools/built-in/admin/get-customer.tool.js +55 -0
- package/lib/tools/built-in/admin/get-customer.tool.js.map +1 -0
- package/lib/tools/built-in/admin/get-order.tool.d.ts +100 -0
- package/lib/tools/built-in/admin/get-order.tool.js +68 -0
- package/lib/tools/built-in/admin/get-order.tool.js.map +1 -0
- package/lib/tools/built-in/admin/get-product.tool.d.ts +69 -0
- package/lib/tools/built-in/admin/get-product.tool.js +77 -0
- package/lib/tools/built-in/admin/get-product.tool.js.map +1 -0
- package/lib/tools/built-in/admin/get-stock-levels.tool.d.ts +23 -0
- package/lib/tools/built-in/admin/get-stock-levels.tool.js +61 -0
- package/lib/tools/built-in/admin/get-stock-levels.tool.js.map +1 -0
- package/lib/tools/built-in/admin/index.d.ts +25 -0
- package/lib/tools/built-in/admin/index.js +54 -0
- package/lib/tools/built-in/admin/index.js.map +1 -0
- package/lib/tools/built-in/admin/list-channels.tool.d.ts +24 -0
- package/lib/tools/built-in/admin/list-channels.tool.js +56 -0
- package/lib/tools/built-in/admin/list-channels.tool.js.map +1 -0
- package/lib/tools/built-in/admin/list-customer-groups.tool.d.ts +23 -0
- package/lib/tools/built-in/admin/list-customer-groups.tool.js +52 -0
- package/lib/tools/built-in/admin/list-customer-groups.tool.js.map +1 -0
- package/lib/tools/built-in/admin/list-customers.tool.d.ts +62 -0
- package/lib/tools/built-in/admin/list-customers.tool.js +66 -0
- package/lib/tools/built-in/admin/list-customers.tool.js.map +1 -0
- package/lib/tools/built-in/admin/list-orders.tool.d.ts +142 -0
- package/lib/tools/built-in/admin/list-orders.tool.js +87 -0
- package/lib/tools/built-in/admin/list-orders.tool.js.map +1 -0
- package/lib/tools/built-in/admin/list-products.tool.d.ts +63 -0
- package/lib/tools/built-in/admin/list-products.tool.js +71 -0
- package/lib/tools/built-in/admin/list-products.tool.js.map +1 -0
- package/lib/tools/built-in/admin/refund-order.tool.d.ts +38 -0
- package/lib/tools/built-in/admin/refund-order.tool.js +115 -0
- package/lib/tools/built-in/admin/refund-order.tool.js.map +1 -0
- package/lib/tools/built-in/admin/set-active-channel.tool.d.ts +22 -0
- package/lib/tools/built-in/admin/set-active-channel.tool.js +84 -0
- package/lib/tools/built-in/admin/set-active-channel.tool.js.map +1 -0
- package/lib/tools/built-in/admin/translation-schemas.d.ts +12 -0
- package/lib/tools/built-in/admin/translation-schemas.js +17 -0
- package/lib/tools/built-in/admin/translation-schemas.js.map +1 -0
- package/lib/tools/built-in/admin/update-customer.tool.d.ts +42 -0
- package/lib/tools/built-in/admin/update-customer.tool.js +59 -0
- package/lib/tools/built-in/admin/update-customer.tool.js.map +1 -0
- package/lib/tools/built-in/admin/update-order-state.tool.d.ts +16 -0
- package/lib/tools/built-in/admin/update-order-state.tool.js +58 -0
- package/lib/tools/built-in/admin/update-order-state.tool.js.map +1 -0
- package/lib/tools/built-in/admin/update-product.tool.d.ts +53 -0
- package/lib/tools/built-in/admin/update-product.tool.js +68 -0
- package/lib/tools/built-in/admin/update-product.tool.js.map +1 -0
- package/lib/tools/built-in/admin/update-variant.tool.d.ts +46 -0
- package/lib/tools/built-in/admin/update-variant.tool.js +77 -0
- package/lib/tools/built-in/admin/update-variant.tool.js.map +1 -0
- package/lib/tools/built-in/admin/upload-asset.tool.d.ts +32 -0
- package/lib/tools/built-in/admin/upload-asset.tool.js +56 -0
- package/lib/tools/built-in/admin/upload-asset.tool.js.map +1 -0
- package/lib/tools/built-in/catalog-query.service.d.ts +21 -0
- package/lib/tools/built-in/catalog-query.service.js +128 -0
- package/lib/tools/built-in/catalog-query.service.js.map +1 -0
- package/lib/tools/built-in/custom-field-input.service.d.ts +10 -0
- package/lib/tools/built-in/custom-field-input.service.js +64 -0
- package/lib/tools/built-in/custom-field-input.service.js.map +1 -0
- package/lib/tools/built-in/email-schema.d.ts +2 -0
- package/lib/tools/built-in/email-schema.js +12 -0
- package/lib/tools/built-in/email-schema.js.map +1 -0
- package/lib/tools/built-in/id-schema.d.ts +3 -0
- package/lib/tools/built-in/id-schema.js +11 -0
- package/lib/tools/built-in/id-schema.js.map +1 -0
- package/lib/tools/built-in/int32-schema.d.ts +4 -0
- package/lib/tools/built-in/int32-schema.js +8 -0
- package/lib/tools/built-in/int32-schema.js.map +1 -0
- package/lib/tools/built-in/list-helpers.d.ts +48 -0
- package/lib/tools/built-in/list-helpers.js +76 -0
- package/lib/tools/built-in/list-helpers.js.map +1 -0
- package/lib/tools/built-in/order-list-helpers.d.ts +20 -0
- package/lib/tools/built-in/order-list-helpers.js +48 -0
- package/lib/tools/built-in/order-list-helpers.js.map +1 -0
- package/lib/tools/built-in/providers.d.ts +2 -0
- package/lib/tools/built-in/providers.js +7 -0
- package/lib/tools/built-in/providers.js.map +1 -0
- package/lib/tools/built-in/remote-asset.d.ts +4 -0
- package/lib/tools/built-in/remote-asset.js +54 -0
- package/lib/tools/built-in/remote-asset.js.map +1 -0
- package/lib/tools/built-in/serializer.service.d.ts +327 -0
- package/lib/tools/built-in/serializer.service.js +413 -0
- package/lib/tools/built-in/serializer.service.js.map +1 -0
- package/lib/tools/built-in/shop/add-to-cart.tool.d.ts +21 -0
- package/lib/tools/built-in/shop/add-to-cart.tool.js +100 -0
- package/lib/tools/built-in/shop/add-to-cart.tool.js.map +1 -0
- package/lib/tools/built-in/shop/address-schema.d.ts +15 -0
- package/lib/tools/built-in/shop/address-schema.js +20 -0
- package/lib/tools/built-in/shop/address-schema.js.map +1 -0
- package/lib/tools/built-in/shop/apply-coupon-code.tool.d.ts +17 -0
- package/lib/tools/built-in/shop/apply-coupon-code.tool.js +62 -0
- package/lib/tools/built-in/shop/apply-coupon-code.tool.js.map +1 -0
- package/lib/tools/built-in/shop/collection-lookup.d.ts +15 -0
- package/lib/tools/built-in/shop/collection-lookup.js +35 -0
- package/lib/tools/built-in/shop/collection-lookup.js.map +1 -0
- package/lib/tools/built-in/shop/get-cart.tool.d.ts +94 -0
- package/lib/tools/built-in/shop/get-cart.tool.js +55 -0
- package/lib/tools/built-in/shop/get-cart.tool.js.map +1 -0
- package/lib/tools/built-in/shop/get-collection.tool.d.ts +42 -0
- package/lib/tools/built-in/shop/get-collection.tool.js +64 -0
- package/lib/tools/built-in/shop/get-collection.tool.js.map +1 -0
- package/lib/tools/built-in/shop/get-eligible-payment-methods.tool.d.ts +26 -0
- package/lib/tools/built-in/shop/get-eligible-payment-methods.tool.js +58 -0
- package/lib/tools/built-in/shop/get-eligible-payment-methods.tool.js.map +1 -0
- package/lib/tools/built-in/shop/get-eligible-shipping-methods.tool.d.ts +30 -0
- package/lib/tools/built-in/shop/get-eligible-shipping-methods.tool.js +59 -0
- package/lib/tools/built-in/shop/get-eligible-shipping-methods.tool.js.map +1 -0
- package/lib/tools/built-in/shop/get-my-account.tool.d.ts +22 -0
- package/lib/tools/built-in/shop/get-my-account.tool.js +57 -0
- package/lib/tools/built-in/shop/get-my-account.tool.js.map +1 -0
- package/lib/tools/built-in/shop/get-order.tool.d.ts +100 -0
- package/lib/tools/built-in/shop/get-order.tool.js +67 -0
- package/lib/tools/built-in/shop/get-order.tool.js.map +1 -0
- package/lib/tools/built-in/shop/get-product.tool.d.ts +57 -0
- package/lib/tools/built-in/shop/get-product.tool.js +81 -0
- package/lib/tools/built-in/shop/get-product.tool.js.map +1 -0
- package/lib/tools/built-in/shop/index.d.ts +19 -0
- package/lib/tools/built-in/shop/index.js +42 -0
- package/lib/tools/built-in/shop/index.js.map +1 -0
- package/lib/tools/built-in/shop/list-collections.tool.d.ts +42 -0
- package/lib/tools/built-in/shop/list-collections.tool.js +75 -0
- package/lib/tools/built-in/shop/list-collections.tool.js.map +1 -0
- package/lib/tools/built-in/shop/list-my-orders.tool.d.ts +100 -0
- package/lib/tools/built-in/shop/list-my-orders.tool.js +63 -0
- package/lib/tools/built-in/shop/list-my-orders.tool.js.map +1 -0
- package/lib/tools/built-in/shop/place-order.tool.d.ts +188 -0
- package/lib/tools/built-in/shop/place-order.tool.js +152 -0
- package/lib/tools/built-in/shop/place-order.tool.js.map +1 -0
- package/lib/tools/built-in/shop/product-search-query.d.ts +4 -0
- package/lib/tools/built-in/shop/product-search-query.js +34 -0
- package/lib/tools/built-in/shop/product-search-query.js.map +1 -0
- package/lib/tools/built-in/shop/remove-coupon-code.tool.d.ts +17 -0
- package/lib/tools/built-in/shop/remove-coupon-code.tool.js +63 -0
- package/lib/tools/built-in/shop/remove-coupon-code.tool.js.map +1 -0
- package/lib/tools/built-in/shop/remove-from-cart.tool.d.ts +17 -0
- package/lib/tools/built-in/shop/remove-from-cart.tool.js +58 -0
- package/lib/tools/built-in/shop/remove-from-cart.tool.js.map +1 -0
- package/lib/tools/built-in/shop/search-products.tool.d.ts +48 -0
- package/lib/tools/built-in/shop/search-products.tool.js +95 -0
- package/lib/tools/built-in/shop/search-products.tool.js.map +1 -0
- package/lib/tools/built-in/shop/set-checkout-details.tool.d.ts +56 -0
- package/lib/tools/built-in/shop/set-checkout-details.tool.js +187 -0
- package/lib/tools/built-in/shop/set-checkout-details.tool.js.map +1 -0
- package/lib/tools/built-in/shop/set-shipping-method.tool.d.ts +17 -0
- package/lib/tools/built-in/shop/set-shipping-method.tool.js +58 -0
- package/lib/tools/built-in/shop/set-shipping-method.tool.js.map +1 -0
- package/lib/tools/built-in/shop/update-cart-line.tool.d.ts +18 -0
- package/lib/tools/built-in/shop/update-cart-line.tool.js +60 -0
- package/lib/tools/built-in/shop/update-cart-line.tool.js.map +1 -0
- package/lib/tools/built-in/string-schemas.d.ts +4 -0
- package/lib/tools/built-in/string-schemas.js +13 -0
- package/lib/tools/built-in/string-schemas.js.map +1 -0
- package/lib/transport/mcp-server.factory.d.ts +13 -0
- package/lib/transport/mcp-server.factory.js +32 -0
- package/lib/transport/mcp-server.factory.js.map +1 -0
- package/lib/transport/mcp-transport.controller.d.ts +77 -0
- package/lib/transport/mcp-transport.controller.js +442 -0
- package/lib/transport/mcp-transport.controller.js.map +1 -0
- package/lib/types.d.ts +432 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/package.json +42 -0
- package/src/dashboard/components/activity-block.tsx +72 -0
- package/src/dashboard/components/actor-cell.tsx +31 -0
- package/src/dashboard/components/connection-dialog.tsx +106 -0
- package/src/dashboard/components/empty-cell.tsx +7 -0
- package/src/dashboard/components/grants-block.tsx +218 -0
- package/src/dashboard/components/stats-block.tsx +275 -0
- package/src/dashboard/components/tools-block.tsx +274 -0
- package/src/dashboard/components/tooltip-button.tsx +28 -0
- package/src/dashboard/components/use-mcp-table-state.ts +47 -0
- package/src/dashboard/i18n/ar.po +311 -0
- package/src/dashboard/i18n/bg.po +311 -0
- package/src/dashboard/i18n/cs.po +311 -0
- package/src/dashboard/i18n/de.po +311 -0
- package/src/dashboard/i18n/en.po +311 -0
- package/src/dashboard/i18n/es.po +311 -0
- package/src/dashboard/i18n/fa.po +311 -0
- package/src/dashboard/i18n/fr.po +311 -0
- package/src/dashboard/i18n/he.po +311 -0
- package/src/dashboard/i18n/hr.po +311 -0
- package/src/dashboard/i18n/hu.po +311 -0
- package/src/dashboard/i18n/it.po +311 -0
- package/src/dashboard/i18n/ja.po +311 -0
- package/src/dashboard/i18n/ko.po +311 -0
- package/src/dashboard/i18n/nb.po +311 -0
- package/src/dashboard/i18n/ne.po +311 -0
- package/src/dashboard/i18n/nl.po +311 -0
- package/src/dashboard/i18n/pl.po +311 -0
- package/src/dashboard/i18n/pt_BR.po +311 -0
- package/src/dashboard/i18n/pt_PT.po +311 -0
- package/src/dashboard/i18n/ro.po +311 -0
- package/src/dashboard/i18n/ru.po +311 -0
- package/src/dashboard/i18n/sv.po +311 -0
- package/src/dashboard/i18n/tr.po +311 -0
- package/src/dashboard/i18n/uk.po +311 -0
- package/src/dashboard/i18n/uz.po +311 -0
- package/src/dashboard/i18n/zh_Hans.po +311 -0
- package/src/dashboard/i18n/zh_Hant.po +311 -0
- package/src/dashboard/index.tsx +30 -0
- package/src/dashboard/mcp-activity-route.tsx +38 -0
- package/src/dashboard/mcp-authorize-route.tsx +369 -0
- package/src/dashboard/mcp-grants-route.tsx +38 -0
- package/src/dashboard/mcp-overview-route.tsx +46 -0
- package/src/dashboard/mcp-server-redirect-route.tsx +15 -0
- package/src/dashboard/mcp-tools-route.tsx +38 -0
- package/src/dashboard/mcp.graphql.ts +127 -0
- package/src/dashboard/published-files.spec.ts +54 -0
- package/src/dashboard/tsconfig.json +9 -0
- package/src/shared/endpoint-paths.ts +8 -0
- package/src/shared/loopback.ts +6 -0
|
@@ -0,0 +1,54 @@
|
|
|
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.McpToolCallLogRetentionService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const core_1 = require("@vendure/core");
|
|
18
|
+
const constants_1 = require("../constants");
|
|
19
|
+
const delete_in_batches_1 = require("../delete-in-batches");
|
|
20
|
+
const mcp_tool_call_log_entity_1 = require("../entities/mcp-tool-call-log.entity");
|
|
21
|
+
// Deletes in batches so a large table is never locked by one statement.
|
|
22
|
+
let McpToolCallLogRetentionService = class McpToolCallLogRetentionService {
|
|
23
|
+
constructor(connection, options) {
|
|
24
|
+
this.connection = connection;
|
|
25
|
+
this.options = options;
|
|
26
|
+
}
|
|
27
|
+
async deleteExpiredToolCallLogs(ctx, channelId) {
|
|
28
|
+
const ttlDays = this.options.logging.ttlDays;
|
|
29
|
+
if (ttlDays === 0) {
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
const cutoff = new Date(Date.now() - ttlDays * constants_1.MS_PER_DAY);
|
|
33
|
+
return (0, delete_in_batches_1.deleteInBatches)(this.connection, ctx, mcp_tool_call_log_entity_1.McpToolCallLog, () => {
|
|
34
|
+
const query = this.connection
|
|
35
|
+
.getRepository(ctx, mcp_tool_call_log_entity_1.McpToolCallLog)
|
|
36
|
+
.createQueryBuilder('log')
|
|
37
|
+
.select('log.id', 'id')
|
|
38
|
+
.where('log.createdAt < :cutoff', { cutoff })
|
|
39
|
+
.limit(constants_1.RETENTION_DELETE_BATCH_SIZE);
|
|
40
|
+
if (channelId != null) {
|
|
41
|
+
// A channel only ever prunes its own rows, matching what it can see in the dashboard log list.
|
|
42
|
+
query.andWhere('log.channelId = :channelId', { channelId });
|
|
43
|
+
}
|
|
44
|
+
return query.getRawMany();
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.McpToolCallLogRetentionService = McpToolCallLogRetentionService;
|
|
49
|
+
exports.McpToolCallLogRetentionService = McpToolCallLogRetentionService = __decorate([
|
|
50
|
+
(0, common_1.Injectable)(),
|
|
51
|
+
__param(1, (0, common_1.Inject)(constants_1.MCP_PLUGIN_OPTIONS)),
|
|
52
|
+
__metadata("design:paramtypes", [core_1.TransactionalConnection, Object])
|
|
53
|
+
], McpToolCallLogRetentionService);
|
|
54
|
+
//# sourceMappingURL=mcp-tool-call-log-retention.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tool-call-log-retention.service.js","sourceRoot":"","sources":["../../src/logging/mcp-tool-call-log-retention.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,wCAA4E;AAE5E,4CAA2F;AAC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B,CA0B1C"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { EventBus, TransactionalConnection } from '@vendure/core';
|
|
2
|
+
import { McpExecutionContext, ResolvedMcpPluginOptions } from '../internal-types';
|
|
3
|
+
import { McpRegisteredTool } from '../registry/registry-types';
|
|
4
|
+
import { McpToolCallStatus } from '../types';
|
|
5
|
+
export interface LogToolCallInput {
|
|
6
|
+
executionContext: McpExecutionContext;
|
|
7
|
+
tool: McpRegisteredTool;
|
|
8
|
+
input: unknown;
|
|
9
|
+
output: unknown;
|
|
10
|
+
durationMs: number;
|
|
11
|
+
status: McpToolCallStatus;
|
|
12
|
+
}
|
|
13
|
+
export declare class McpToolCallLogService {
|
|
14
|
+
private readonly connection;
|
|
15
|
+
private readonly eventBus;
|
|
16
|
+
private readonly options;
|
|
17
|
+
constructor(connection: TransactionalConnection, eventBus: EventBus, options: ResolvedMcpPluginOptions);
|
|
18
|
+
logToolCall(call: LogToolCallInput): Promise<void>;
|
|
19
|
+
private resolveActor;
|
|
20
|
+
private resolveActorType;
|
|
21
|
+
/** Both `input` and `output` come back null in `metadata` capture mode, or if the operator's redact function throws. */
|
|
22
|
+
private captureBodies;
|
|
23
|
+
private capBody;
|
|
24
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
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.McpToolCallLogService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const core_1 = require("@vendure/core");
|
|
18
|
+
const constants_1 = require("../constants");
|
|
19
|
+
const mcp_tool_call_log_entity_1 = require("../entities/mcp-tool-call-log.entity");
|
|
20
|
+
const mcp_tool_call_event_1 = require("../events/mcp-tool-call.event");
|
|
21
|
+
let McpToolCallLogService = class McpToolCallLogService {
|
|
22
|
+
constructor(connection, eventBus, options) {
|
|
23
|
+
this.connection = connection;
|
|
24
|
+
this.eventBus = eventBus;
|
|
25
|
+
this.options = options;
|
|
26
|
+
}
|
|
27
|
+
async logToolCall(call) {
|
|
28
|
+
var _a, _b, _c, _d;
|
|
29
|
+
const { ctx, grant, clientIp } = call.executionContext;
|
|
30
|
+
let saved = false;
|
|
31
|
+
try {
|
|
32
|
+
const log = new mcp_tool_call_log_entity_1.McpToolCallLog({
|
|
33
|
+
grantId: (_a = grant === null || grant === void 0 ? void 0 : grant.id) !== null && _a !== void 0 ? _a : null,
|
|
34
|
+
actor: this.resolveActor(grant, ctx),
|
|
35
|
+
actorType: this.resolveActorType(grant, ctx),
|
|
36
|
+
channelId: grant ? ((_b = grant.channelId) !== null && _b !== void 0 ? _b : null) : ((_c = ctx.channelId) !== null && _c !== void 0 ? _c : null),
|
|
37
|
+
clientIp: this.options.logging.captureClientIp ? (clientIp !== null && clientIp !== void 0 ? clientIp : null) : null,
|
|
38
|
+
toolName: call.tool.name,
|
|
39
|
+
pluginSource: call.tool.pluginSource,
|
|
40
|
+
durationMs: call.durationMs,
|
|
41
|
+
status: call.status,
|
|
42
|
+
oauthClientId: (_d = grant === null || grant === void 0 ? void 0 : grant.oauthClientId) !== null && _d !== void 0 ? _d : null,
|
|
43
|
+
});
|
|
44
|
+
const bodies = this.captureBodies(call);
|
|
45
|
+
log.input = bodies.input;
|
|
46
|
+
log.output = bodies.output;
|
|
47
|
+
await this.connection.getRepository(ctx, mcp_tool_call_log_entity_1.McpToolCallLog).save(log);
|
|
48
|
+
saved = true;
|
|
49
|
+
await this.eventBus.publish(new mcp_tool_call_event_1.McpToolCallEvent(ctx, log));
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
const reason = e instanceof Error ? e.message : String(e);
|
|
53
|
+
if (saved) {
|
|
54
|
+
core_1.Logger.warn(`Recorded MCP tool call "${call.tool.name}" but publishing its McpToolCallEvent failed: ${reason}`, constants_1.loggerCtx);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
core_1.Logger.warn(`Failed to record MCP tool call "${call.tool.name}": ${reason}`, constants_1.loggerCtx);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
resolveActor(grant, ctx) {
|
|
62
|
+
if ((grant === null || grant === void 0 ? void 0 : grant.actorId) != null) {
|
|
63
|
+
return String(grant.actorId);
|
|
64
|
+
}
|
|
65
|
+
if (ctx.activeUserId != null) {
|
|
66
|
+
return String(ctx.activeUserId);
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
resolveActorType(grant, ctx) {
|
|
71
|
+
if ((grant === null || grant === void 0 ? void 0 : grant.actorType) != null) {
|
|
72
|
+
return grant.actorType;
|
|
73
|
+
}
|
|
74
|
+
if (ctx.apiType === 'admin') {
|
|
75
|
+
return 'admin';
|
|
76
|
+
}
|
|
77
|
+
if (ctx.activeUserId != null) {
|
|
78
|
+
return 'customer';
|
|
79
|
+
}
|
|
80
|
+
return 'anonymous';
|
|
81
|
+
}
|
|
82
|
+
/** Both `input` and `output` come back null in `metadata` capture mode, or if the operator's redact function throws. */
|
|
83
|
+
captureBodies(call) {
|
|
84
|
+
const logging = this.options.logging;
|
|
85
|
+
if (logging.capture !== 'full') {
|
|
86
|
+
return { input: null, output: null };
|
|
87
|
+
}
|
|
88
|
+
let bodies;
|
|
89
|
+
if (logging.redact) {
|
|
90
|
+
try {
|
|
91
|
+
bodies = logging.redact({
|
|
92
|
+
toolName: call.tool.name,
|
|
93
|
+
input: call.input,
|
|
94
|
+
output: call.output,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
catch (redactError) {
|
|
98
|
+
const reason = redactError instanceof Error ? redactError.message : String(redactError);
|
|
99
|
+
core_1.Logger.warn(`The configured logging.redact function threw while redacting tool call ` +
|
|
100
|
+
`"${call.tool.name}": ${reason}. ` +
|
|
101
|
+
`The call was recorded without its input/output bodies.`, constants_1.loggerCtx);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
bodies = { input: call.input, output: call.output };
|
|
106
|
+
}
|
|
107
|
+
return { input: this.capBody(bodies === null || bodies === void 0 ? void 0 : bodies.input), output: this.capBody(bodies === null || bodies === void 0 ? void 0 : bodies.output) };
|
|
108
|
+
}
|
|
109
|
+
capBody(value) {
|
|
110
|
+
if (value == null) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
const maxBodyBytes = this.options.logging.maxBodyBytes;
|
|
114
|
+
const bytes = Buffer.byteLength(JSON.stringify(value), 'utf8');
|
|
115
|
+
if (bytes > maxBodyBytes) {
|
|
116
|
+
return { omitted: `body exceeded logging.maxBodyBytes (${maxBodyBytes} bytes)`, bytes };
|
|
117
|
+
}
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
exports.McpToolCallLogService = McpToolCallLogService;
|
|
122
|
+
exports.McpToolCallLogService = McpToolCallLogService = __decorate([
|
|
123
|
+
(0, common_1.Injectable)(),
|
|
124
|
+
__param(2, (0, common_1.Inject)(constants_1.MCP_PLUGIN_OPTIONS)),
|
|
125
|
+
__metadata("design:paramtypes", [core_1.TransactionalConnection,
|
|
126
|
+
core_1.EventBus, Object])
|
|
127
|
+
], McpToolCallLogService);
|
|
128
|
+
//# sourceMappingURL=mcp-tool-call-log.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-tool-call-log.service.js","sourceRoot":"","sources":["../../src/logging/mcp-tool-call-log.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,wCAA0F;AAE1F,4CAA6D;AAE7D,mFAAsE;AACtE,uEAAiE;AAe1D,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAC9B,YACqB,UAAmC,EACnC,QAAkB,EACU,OAAiC;QAF7D,eAAU,GAAV,UAAU,CAAyB;QACnC,aAAQ,GAAR,QAAQ,CAAU;QACU,YAAO,GAAP,OAAO,CAA0B;IAC/E,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAC,IAAsB;;QACpC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,gBAAgB,CAAC;QACvD,IAAI,KAAK,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC;YACD,MAAM,GAAG,GAAG,IAAI,yCAAc,CAAC;gBAC3B,OAAO,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,EAAE,mCAAI,IAAI;gBAC1B,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,GAAG,CAAC;gBACpC,SAAS,EAAE,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,GAAG,CAAC;gBAC5C,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,MAAA,KAAK,CAAC,SAAS,mCAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAA,GAAG,CAAC,SAAS,mCAAI,IAAI,CAAC;gBACtE,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,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U,GAAE;IAKJ,WAAA,IAAA,eAAM,EAAC,8BAAkB,CAAC,CAAA;qCAFE,8BAAuB;QACzB,eAAQ;GAH9B,qBAAqB,CAyGjC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RequestContext, TransactionalConnection } from '@vendure/core';
|
|
2
|
+
import { McpOauthClient } from '../../entities/mcp-oauth-client.entity';
|
|
3
|
+
import { ResolvedMcpPluginOptions } from '../../internal-types';
|
|
4
|
+
/** Caches CIMD documents as client rows so they aren't refetched on every request; invalid documents are never cached. */
|
|
5
|
+
export declare class McpCimdClientResolverService {
|
|
6
|
+
private readonly connection;
|
|
7
|
+
private readonly options;
|
|
8
|
+
/** Avoids firing off duplicate fetches when several requests for the same client_id arrive at once. */
|
|
9
|
+
private readonly inFlight;
|
|
10
|
+
constructor(connection: TransactionalConnection, options: ResolvedMcpPluginOptions);
|
|
11
|
+
private get allowLoopback();
|
|
12
|
+
resolveClient(ctx: RequestContext, clientId: string): Promise<McpOauthClient>;
|
|
13
|
+
/** Fetches and validates the document, sharing one request with any concurrent caller. */
|
|
14
|
+
private resolveDocument;
|
|
15
|
+
private storeDocument;
|
|
16
|
+
private findClientRow;
|
|
17
|
+
private isFresh;
|
|
18
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
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.McpCimdClientResolverService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const core_1 = require("@vendure/core");
|
|
18
|
+
const constants_1 = require("../../constants");
|
|
19
|
+
const mcp_oauth_client_entity_1 = require("../../entities/mcp-oauth-client.entity");
|
|
20
|
+
const oauth_utils_1 = require("../oauth-utils");
|
|
21
|
+
const cimd_document_1 = require("./cimd-document");
|
|
22
|
+
const cimd_fetch_1 = require("./cimd-fetch");
|
|
23
|
+
const cimd_url_1 = require("./cimd-url");
|
|
24
|
+
/** Caches CIMD documents as client rows so they aren't refetched on every request; invalid documents are never cached. */
|
|
25
|
+
let McpCimdClientResolverService = class McpCimdClientResolverService {
|
|
26
|
+
constructor(connection, options) {
|
|
27
|
+
this.connection = connection;
|
|
28
|
+
this.options = options;
|
|
29
|
+
/** Avoids firing off duplicate fetches when several requests for the same client_id arrive at once. */
|
|
30
|
+
this.inFlight = new Map();
|
|
31
|
+
}
|
|
32
|
+
// Documents on the local machine are a development-only convenience (draft §8.6), so the
|
|
33
|
+
// operator has to ask for them; `McpPlugin` refuses to start with them on in production.
|
|
34
|
+
get allowLoopback() {
|
|
35
|
+
var _a;
|
|
36
|
+
return ((_a = this.options.oauth) === null || _a === void 0 ? void 0 : _a.allowLoopbackCimdDocuments) === true;
|
|
37
|
+
}
|
|
38
|
+
async resolveClient(ctx, clientId) {
|
|
39
|
+
const url = (0, cimd_url_1.validateCimdClientIdUrl)(clientId, { allowLoopback: this.allowLoopback });
|
|
40
|
+
const cached = await this.findClientRow(ctx, clientId);
|
|
41
|
+
if (cached && this.isFresh(cached)) {
|
|
42
|
+
return cached;
|
|
43
|
+
}
|
|
44
|
+
const document = await this.resolveDocument(clientId, url);
|
|
45
|
+
return this.storeDocument(ctx, clientId, document);
|
|
46
|
+
}
|
|
47
|
+
/** Fetches and validates the document, sharing one request with any concurrent caller. */
|
|
48
|
+
resolveDocument(clientId, url) {
|
|
49
|
+
const running = this.inFlight.get(clientId);
|
|
50
|
+
if (running) {
|
|
51
|
+
return running;
|
|
52
|
+
}
|
|
53
|
+
const task = (0, cimd_fetch_1.fetchCimdDocument)(url, {
|
|
54
|
+
timeoutMs: constants_1.CIMD_FETCH_TIMEOUT_MS,
|
|
55
|
+
maxBytes: constants_1.CIMD_MAX_DOCUMENT_BYTES,
|
|
56
|
+
allowLoopback: this.allowLoopback,
|
|
57
|
+
})
|
|
58
|
+
.then(body => (0, cimd_document_1.parseCimdDocument)(clientId, body))
|
|
59
|
+
.finally(() => {
|
|
60
|
+
this.inFlight.delete(clientId);
|
|
61
|
+
});
|
|
62
|
+
this.inFlight.set(clientId, task);
|
|
63
|
+
return task;
|
|
64
|
+
}
|
|
65
|
+
async storeDocument(ctx, clientId, document) {
|
|
66
|
+
const repository = this.connection.getRepository(ctx, mcp_oauth_client_entity_1.McpOauthClient);
|
|
67
|
+
let client = await this.findClientRow(ctx, clientId);
|
|
68
|
+
if (!client) {
|
|
69
|
+
client = new mcp_oauth_client_entity_1.McpOauthClient();
|
|
70
|
+
client.clientId = clientId;
|
|
71
|
+
client.lastUsedAt = null;
|
|
72
|
+
}
|
|
73
|
+
client.clientName = document.clientName;
|
|
74
|
+
client.clientUri = document.clientUri;
|
|
75
|
+
client.logoUri = document.logoUri;
|
|
76
|
+
client.redirectUris = document.redirectUris;
|
|
77
|
+
client.grantTypes = document.grantTypes;
|
|
78
|
+
client.tokenEndpointAuthMethod = document.tokenEndpointAuthMethod;
|
|
79
|
+
client.cimdDocumentExpiresAt = (0, oauth_utils_1.addSeconds)(new Date(), constants_1.CIMD_CACHE_TTL_SECONDS);
|
|
80
|
+
try {
|
|
81
|
+
return await repository.save(client);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
// If two servers race to create the same client row, use whichever one won rather than
|
|
85
|
+
// failing; other errors must still surface, since the existing row could be stale.
|
|
86
|
+
const winner = await this.findClientRow(ctx, clientId);
|
|
87
|
+
if (winner && this.isFresh(winner)) {
|
|
88
|
+
return winner;
|
|
89
|
+
}
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async findClientRow(ctx, clientId) {
|
|
94
|
+
const row = await this.connection.getRepository(ctx, mcp_oauth_client_entity_1.McpOauthClient).findOne({ where: { clientId } });
|
|
95
|
+
// SQL equality follows the column collation (MySQL's default ignores case and trailing
|
|
96
|
+
// spaces), so the row is used only when its stored id is exactly the one asked for.
|
|
97
|
+
return (row === null || row === void 0 ? void 0 : row.clientId) === clientId ? row : undefined;
|
|
98
|
+
}
|
|
99
|
+
isFresh(client) {
|
|
100
|
+
return client.cimdDocumentExpiresAt != null && client.cimdDocumentExpiresAt > new Date();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
exports.McpCimdClientResolverService = McpCimdClientResolverService;
|
|
104
|
+
exports.McpCimdClientResolverService = McpCimdClientResolverService = __decorate([
|
|
105
|
+
(0, common_1.Injectable)(),
|
|
106
|
+
__param(1, (0, common_1.Inject)(constants_1.MCP_PLUGIN_OPTIONS)),
|
|
107
|
+
__metadata("design:paramtypes", [core_1.TransactionalConnection, Object])
|
|
108
|
+
], McpCimdClientResolverService);
|
|
109
|
+
//# sourceMappingURL=cimd-client-resolver.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cimd-client-resolver.service.js","sourceRoot":"","sources":["../../../src/oauth/cimd/cimd-client-resolver.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,wCAAwE;AAExE,+CAKyB;AACzB,oFAAwE;AAExE,gDAA4C;AAE5C,mDAAkE;AAClE,6CAAi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,IAAI,CAAC;YACD,OAAO,MAAM,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,uFAAuF;YACvF,mFAAmF;YACnF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YACvD,IAAI,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBACjC,OAAO,MAAM,CAAC;YAClB,CAAC;YACD,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,GAAmB,EAAE,QAAgB;QAC7D,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,GAAG,EAAE,wCAAc,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;QACtG,uFAAuF;QACvF,oFAAoF;QACpF,OAAO,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,QAAQ,MAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IACxD,CAAC;IAEO,OAAO,CAAC,MAAsB;QAClC,OAAO,MAAM,CAAC,qBAAqB,IAAI,IAAI,IAAI,MAAM,CAAC,qBAAqB,GAAG,IAAI,IAAI,EAAE,CAAC;IAC7F,CAAC;CACJ,CAAA;AAtFY,oEAA4B;uCAA5B,4BAA4B;IADxC,IAAA,mBAAU,GAAE;IAOJ,WAAA,IAAA,eAAM,EAAC,8BAAkB,CAAC,CAAA;qCADE,8BAAuB;GAL/C,4BAA4B,CAsFxC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The subset of a fetched CIMD document that this authorization server stores. */
|
|
2
|
+
export interface CimdDocument {
|
|
3
|
+
clientId: string;
|
|
4
|
+
clientName: string;
|
|
5
|
+
redirectUris: string[];
|
|
6
|
+
clientUri: string | null;
|
|
7
|
+
logoUri: string | null;
|
|
8
|
+
grantTypes: string[];
|
|
9
|
+
tokenEndpointAuthMethod: 'none';
|
|
10
|
+
}
|
|
11
|
+
export declare function parseCimdDocument(clientId: string, rawBody: string): CimdDocument;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseCimdDocument = parseCimdDocument;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
const oauth_utils_1 = require("../oauth-utils");
|
|
7
|
+
function parseCimdDocument(clientId, rawBody) {
|
|
8
|
+
var _a;
|
|
9
|
+
let parsed;
|
|
10
|
+
try {
|
|
11
|
+
parsed = JSON.parse(rawBody);
|
|
12
|
+
}
|
|
13
|
+
catch (_b) {
|
|
14
|
+
throw new common_1.BadRequestException('client_id metadata document is not valid JSON');
|
|
15
|
+
}
|
|
16
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
17
|
+
throw new common_1.BadRequestException('client_id metadata document must be a JSON object');
|
|
18
|
+
}
|
|
19
|
+
const document = parsed;
|
|
20
|
+
if (document.client_id !== clientId) {
|
|
21
|
+
throw new common_1.BadRequestException('client_id metadata document client_id must exactly match the client_id URL');
|
|
22
|
+
}
|
|
23
|
+
if (typeof document.client_name !== 'string' || document.client_name.length === 0) {
|
|
24
|
+
throw new common_1.BadRequestException('client_id metadata document must include client_name');
|
|
25
|
+
}
|
|
26
|
+
if (document.client_name.length > constants_1.MAX_CLIENT_METADATA_FIELD_LENGTH) {
|
|
27
|
+
throw new common_1.BadRequestException(`client_id metadata document client_name must be at most ${constants_1.MAX_CLIENT_METADATA_FIELD_LENGTH} characters`);
|
|
28
|
+
}
|
|
29
|
+
const redirectUris = document.redirect_uris;
|
|
30
|
+
if (!Array.isArray(redirectUris) ||
|
|
31
|
+
redirectUris.length === 0 ||
|
|
32
|
+
!redirectUris.every(uri => typeof uri === 'string')) {
|
|
33
|
+
throw new common_1.BadRequestException('client_id metadata document must include redirect_uris');
|
|
34
|
+
}
|
|
35
|
+
for (const uri of redirectUris) {
|
|
36
|
+
(0, oauth_utils_1.assertSafeRedirectUri)(uri);
|
|
37
|
+
}
|
|
38
|
+
if ('client_secret' in document || 'client_secret_expires_at' in document) {
|
|
39
|
+
throw new common_1.BadRequestException('client_id metadata document must not contain a client secret');
|
|
40
|
+
}
|
|
41
|
+
const declaredMethod = (_a = document.token_endpoint_auth_method) !== null && _a !== void 0 ? _a : 'none';
|
|
42
|
+
const supportedMethods = Array.isArray(document.token_endpoint_auth_methods_supported)
|
|
43
|
+
? document.token_endpoint_auth_methods_supported
|
|
44
|
+
: [];
|
|
45
|
+
if (declaredMethod !== 'none' && !supportedMethods.includes('none')) {
|
|
46
|
+
throw new common_1.BadRequestException('client_id metadata document must support token_endpoint_auth_method "none"');
|
|
47
|
+
}
|
|
48
|
+
// A document may list grant types meant for other servers too, so only keep the ones we support.
|
|
49
|
+
const declaredGrantTypes = Array.isArray(document.grant_types)
|
|
50
|
+
? document.grant_types.filter((grant) => typeof grant === 'string')
|
|
51
|
+
: constants_1.SUPPORTED_OAUTH_GRANT_TYPES;
|
|
52
|
+
const grantTypes = declaredGrantTypes.filter(grant => constants_1.SUPPORTED_OAUTH_GRANT_TYPES.includes(grant));
|
|
53
|
+
if (!grantTypes.includes('authorization_code')) {
|
|
54
|
+
throw new common_1.BadRequestException('client_id metadata document must allow the authorization_code grant');
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
clientId,
|
|
58
|
+
clientName: document.client_name,
|
|
59
|
+
redirectUris,
|
|
60
|
+
clientUri: (0, oauth_utils_1.httpsUrlOrNull)(document.client_uri),
|
|
61
|
+
logoUri: (0, oauth_utils_1.httpsUrlOrNull)(document.logo_uri),
|
|
62
|
+
grantTypes,
|
|
63
|
+
tokenEndpointAuthMethod: 'none',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=cimd-document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cimd-document.js","sourceRoot":"","sources":["../../../src/oauth/cimd/cimd-document.ts"],"names":[],"mappings":";;AAgBA,8CAgEC;AAhFD,2CAAqD;AAErD,+CAAgG;AAChG,gDAAuE;AAavE,SAAgB,iBAAiB,CAAC,QAAgB,EAAE,OAAe;;IAC/D,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACD,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAAC,WAAM,CAAC;QACL,MAAM,IAAI,4BAAmB,CAAC,+CAA+C,CAAC,CAAC;IACnF,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACzE,MAAM,IAAI,4BAAmB,CAAC,mDAAmD,CAAC,CAAC;IACvF,CAAC;IACD,MAAM,QAAQ,GAAG,MAAiC,CAAC;IACnD,IAAI,QAAQ,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;QAClC,MAAM,IAAI,4BAAmB,CACzB,4EAA4E,CAC/E,CAAC;IACN,CAAC;IACD,IAAI,OAAO,QAAQ,CAAC,WAAW,KAAK,QAAQ,IAAI,QAAQ,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChF,MAAM,IAAI,4BAAmB,CAAC,sDAAsD,CAAC,CAAC;IAC1F,CAAC;IACD,IAAI,QAAQ,CAAC,WAAW,CAAC,MAAM,GAAG,4CAAgC,EAAE,CAAC;QACjE,MAAM,IAAI,4BAAmB,CACzB,2DAA2D,4CAAgC,aAAa,CAC3G,CAAC;IACN,CAAC;IACD,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC;IAC5C,IACI,CAAC,KAAK,CAAC,OAAO,CAAC,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AAQ,CAAC,oBAAoB,CAAC,EAAE,CAAC;QAC7C,MAAM,IAAI,4BAAmB,CAAC,qEAAqE,CAAC,CAAC;IACzG,CAAC;IACD,OAAO;QACH,QAAQ;QACR,UAAU,EAAE,QAAQ,CAAC,WAAW;QAChC,YAAY;QACZ,SAAS,EAAE,IAAA,4BAAc,EAAC,QAAQ,CAAC,UAAU,CAAC;QAC9C,OAAO,EAAE,IAAA,4BAAc,EAAC,QAAQ,CAAC,QAAQ,CAAC;QAC1C,UAAU;QACV,uBAAuB,EAAE,MAAM;KAClC,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as dns from 'node:dns';
|
|
2
|
+
export interface CimdFetchOptions {
|
|
3
|
+
/** Whole-request deadline — connection plus body — in milliseconds. */
|
|
4
|
+
timeoutMs: number;
|
|
5
|
+
/** Hard cap on the response body size, in bytes. */
|
|
6
|
+
maxBytes: number;
|
|
7
|
+
/** Permit loopback destinations. Development only (draft §8.6). */
|
|
8
|
+
allowLoopback: boolean;
|
|
9
|
+
/** DNS lookup used by the socket; injectable for tests. */
|
|
10
|
+
lookup?: typeof dns.lookup;
|
|
11
|
+
}
|
|
12
|
+
/** True when a resolved address may be dialed. Loopback is only allowed in development. */
|
|
13
|
+
export declare function isAllowedCimdAddress(address: string, family: number, allowLoopback: boolean): boolean;
|
|
14
|
+
export declare function fetchCimdDocument(url: URL, options: CimdFetchOptions): Promise<string>;
|