@dropins/mcp 0.1.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 (103) hide show
  1. package/LICENSE.md +127 -0
  2. package/README.md +314 -0
  3. package/dist/common/project-reader.d.ts +55 -0
  4. package/dist/common/project-reader.js +173 -0
  5. package/dist/common/registry-loader.d.ts +101 -0
  6. package/dist/common/registry-loader.js +386 -0
  7. package/dist/common/response-handling.d.ts +12 -0
  8. package/dist/common/response-handling.js +21 -0
  9. package/dist/common/sanitize.d.ts +8 -0
  10. package/dist/common/sanitize.js +45 -0
  11. package/dist/common/synonyms.d.ts +9 -0
  12. package/dist/common/synonyms.js +127 -0
  13. package/dist/common/telemetry.d.ts +14 -0
  14. package/dist/common/telemetry.js +54 -0
  15. package/dist/common/types.d.ts +308 -0
  16. package/dist/common/types.js +1 -0
  17. package/dist/common/version.d.ts +2 -0
  18. package/dist/common/version.js +14 -0
  19. package/dist/index.d.ts +2 -0
  20. package/dist/index.js +136 -0
  21. package/dist/operations/analyze-project.d.ts +13 -0
  22. package/dist/operations/analyze-project.js +125 -0
  23. package/dist/operations/check-block-health.d.ts +19 -0
  24. package/dist/operations/check-block-health.js +1149 -0
  25. package/dist/operations/check-config.d.ts +13 -0
  26. package/dist/operations/check-config.js +228 -0
  27. package/dist/operations/explain-event-flow.d.ts +16 -0
  28. package/dist/operations/explain-event-flow.js +218 -0
  29. package/dist/operations/get-upgrade-diff.d.ts +13 -0
  30. package/dist/operations/get-upgrade-diff.js +144 -0
  31. package/dist/operations/list-api-functions.d.ts +13 -0
  32. package/dist/operations/list-api-functions.js +53 -0
  33. package/dist/operations/list-containers.d.ts +13 -0
  34. package/dist/operations/list-containers.js +44 -0
  35. package/dist/operations/list-design-tokens.d.ts +13 -0
  36. package/dist/operations/list-design-tokens.js +47 -0
  37. package/dist/operations/list-events.d.ts +16 -0
  38. package/dist/operations/list-events.js +39 -0
  39. package/dist/operations/list-graphql-queries.d.ts +19 -0
  40. package/dist/operations/list-graphql-queries.js +84 -0
  41. package/dist/operations/list-i18n-keys.d.ts +19 -0
  42. package/dist/operations/list-i18n-keys.js +105 -0
  43. package/dist/operations/list-models.d.ts +16 -0
  44. package/dist/operations/list-models.js +80 -0
  45. package/dist/operations/list-slots.d.ts +16 -0
  46. package/dist/operations/list-slots.js +81 -0
  47. package/dist/operations/scaffold-block.d.ts +31 -0
  48. package/dist/operations/scaffold-block.js +331 -0
  49. package/dist/operations/scaffold-extension.d.ts +28 -0
  50. package/dist/operations/scaffold-extension.js +346 -0
  51. package/dist/operations/scaffold-slot.d.ts +22 -0
  52. package/dist/operations/scaffold-slot.js +189 -0
  53. package/dist/operations/search-commerce-docs.d.ts +16 -0
  54. package/dist/operations/search-commerce-docs.js +101 -0
  55. package/dist/operations/search-docs.d.ts +23 -0
  56. package/dist/operations/search-docs.js +298 -0
  57. package/dist/operations/suggest-event-handler.d.ts +16 -0
  58. package/dist/operations/suggest-event-handler.js +175 -0
  59. package/dist/operations/suggest-slot-implementation.d.ts +19 -0
  60. package/dist/operations/suggest-slot-implementation.js +183 -0
  61. package/dist/registry/api-functions.json +3045 -0
  62. package/dist/registry/block-patterns.json +78 -0
  63. package/dist/registry/containers.json +2003 -0
  64. package/dist/registry/design-tokens.json +577 -0
  65. package/dist/registry/docs/boilerplate.json +55 -0
  66. package/dist/registry/docs/dropins-all.json +97 -0
  67. package/dist/registry/docs/dropins-b2b.json +607 -0
  68. package/dist/registry/docs/dropins-cart.json +163 -0
  69. package/dist/registry/docs/dropins-checkout.json +193 -0
  70. package/dist/registry/docs/dropins-order.json +139 -0
  71. package/dist/registry/docs/dropins-payment-services.json +73 -0
  72. package/dist/registry/docs/dropins-personalization.json +67 -0
  73. package/dist/registry/docs/dropins-product-details.json +139 -0
  74. package/dist/registry/docs/dropins-product-discovery.json +85 -0
  75. package/dist/registry/docs/dropins-recommendations.json +67 -0
  76. package/dist/registry/docs/dropins-user-account.json +121 -0
  77. package/dist/registry/docs/dropins-user-auth.json +103 -0
  78. package/dist/registry/docs/dropins-wishlist.json +85 -0
  79. package/dist/registry/docs/get-started.json +85 -0
  80. package/dist/registry/docs/how-tos.json +19 -0
  81. package/dist/registry/docs/index.json +139 -0
  82. package/dist/registry/docs/licensing.json +19 -0
  83. package/dist/registry/docs/merchants.json +523 -0
  84. package/dist/registry/docs/resources.json +13 -0
  85. package/dist/registry/docs/sdk.json +139 -0
  86. package/dist/registry/docs/setup.json +145 -0
  87. package/dist/registry/docs/troubleshooting.json +19 -0
  88. package/dist/registry/events.json +2200 -0
  89. package/dist/registry/examples/index.json +19 -0
  90. package/dist/registry/examples/storefront-checkout.json +377 -0
  91. package/dist/registry/examples/storefront-quote-management.json +49 -0
  92. package/dist/registry/extensions.json +272 -0
  93. package/dist/registry/graphql.json +3469 -0
  94. package/dist/registry/i18n.json +1873 -0
  95. package/dist/registry/models.json +1001 -0
  96. package/dist/registry/sdk.json +2357 -0
  97. package/dist/registry/slots.json +2270 -0
  98. package/dist/registry/tools-components.json +595 -0
  99. package/dist/resources/guides.d.ts +7 -0
  100. package/dist/resources/guides.js +625 -0
  101. package/dist/resources/handlers.d.ts +31 -0
  102. package/dist/resources/handlers.js +322 -0
  103. package/package.json +47 -0
@@ -0,0 +1,322 @@
1
+ import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js";
2
+ import { DOCS_BASE_URL } from "../common/version.js";
3
+ import { guides } from "./guides.js";
4
+ import { getSlotRegistry, getEventCatalog, getContainerRegistry, getApiFunctionRegistry, getExtensionRegistry, getDesignTokenRegistry, getBlockPatternRegistry, getGraphqlRegistry, getSlotsByDropin, getSlotsByContainer, getEventsByDropin, getContainersByDropin, getApiFunctionsByDropin, getDesignTokensByCategory, getGraphqlByDropin, getAllDropinNames, getDocsIndex, getDocsSection, getExamplesIndex, getExamplesByDropin, getSdkRegistry, getSdkPackage, } from "../common/registry-loader.js";
5
+ const registryResources = [
6
+ {
7
+ uri: "storefront://registry/slots",
8
+ name: "Slot Registry",
9
+ mimeType: "application/json",
10
+ description: "Complete slot definitions for all dropin containers (118 slots across 9 dropins)",
11
+ },
12
+ {
13
+ uri: "storefront://registry/events",
14
+ name: "Event Catalog",
15
+ mimeType: "application/json",
16
+ description: "All cross-dropin events with payload types and producer/consumer info (45 events)",
17
+ },
18
+ {
19
+ uri: "storefront://registry/containers",
20
+ name: "Container Registry",
21
+ mimeType: "application/json",
22
+ description: "All dropin containers with props and slot names (80 containers across 9 dropins)",
23
+ },
24
+ {
25
+ uri: "storefront://registry/api-functions",
26
+ name: "API Function Registry",
27
+ mimeType: "application/json",
28
+ description: "Public API functions for all dropins with signatures and parameters",
29
+ },
30
+ {
31
+ uri: "storefront://registry/extensions",
32
+ name: "Extension Registry",
33
+ mimeType: "application/json",
34
+ description: "Checkout extension hooks, interface definitions, and reference examples",
35
+ },
36
+ {
37
+ uri: "storefront://registry/design-tokens",
38
+ name: "Design Token Registry",
39
+ mimeType: "application/json",
40
+ description: "CSS custom properties for theming across all categories (colors, typography, spacing, shapes, grid)",
41
+ },
42
+ {
43
+ uri: "storefront://registry/block-patterns",
44
+ name: "Block Pattern Registry",
45
+ mimeType: "application/json",
46
+ description: "AEM block templates and patterns for rendering dropin containers",
47
+ },
48
+ {
49
+ uri: "storefront://docs",
50
+ name: "Documentation Index",
51
+ mimeType: "application/json",
52
+ description: "Index of all official storefront documentation sections and pages (supplementary to registry data)",
53
+ },
54
+ {
55
+ uri: "storefront://registry/examples",
56
+ name: "Examples Index",
57
+ mimeType: "application/json",
58
+ description: "Index of working code examples from dropin repositories (extensions, block patterns)",
59
+ },
60
+ {
61
+ uri: "storefront://registry/sdk",
62
+ name: "SDK Package Registry",
63
+ mimeType: "application/json",
64
+ description: "StorefrontSDK packages — elsie UI components (with props, slots, exported types), event-bus, fetch-graphql, build-tools, recaptcha",
65
+ },
66
+ {
67
+ uri: "storefront://registry/graphql",
68
+ name: "GraphQL Query Registry",
69
+ mimeType: "application/json",
70
+ description: "GraphQL queries, mutations, and extensible fragments used by all dropins with fully resolved sources and extensibility metadata",
71
+ },
72
+ ];
73
+ const resourceTemplates = [
74
+ {
75
+ uriTemplate: "storefront://registry/slots/{dropinName}",
76
+ name: "Slots by Dropin",
77
+ mimeType: "application/json",
78
+ description: "Slot definitions for a specific dropin (e.g., storefront-cart)",
79
+ },
80
+ {
81
+ uriTemplate: "storefront://registry/slots/{dropinName}/{containerName}",
82
+ name: "Slots by Container",
83
+ mimeType: "application/json",
84
+ description: "Slot definitions for a specific container within a dropin",
85
+ },
86
+ {
87
+ uriTemplate: "storefront://registry/events/{dropinName}",
88
+ name: "Events by Dropin",
89
+ mimeType: "application/json",
90
+ description: "Events emitted and consumed by a specific dropin",
91
+ },
92
+ {
93
+ uriTemplate: "storefront://registry/containers/{dropinName}",
94
+ name: "Containers by Dropin",
95
+ mimeType: "application/json",
96
+ description: "Containers available in a specific dropin",
97
+ },
98
+ {
99
+ uriTemplate: "storefront://registry/api-functions/{dropinName}",
100
+ name: "API Functions by Dropin",
101
+ mimeType: "application/json",
102
+ description: "API functions available in a specific dropin",
103
+ },
104
+ {
105
+ uriTemplate: "storefront://registry/design-tokens/{category}",
106
+ name: "Design Tokens by Category",
107
+ mimeType: "application/json",
108
+ description: "Design tokens for a specific category (colors, typography, spacing, shapes, grid)",
109
+ },
110
+ {
111
+ uriTemplate: "storefront://docs/{section}",
112
+ name: "Documentation Section",
113
+ mimeType: "application/json",
114
+ description: "Official documentation pages for a specific section (e.g., dropins/cart, setup, merchants)",
115
+ },
116
+ {
117
+ uriTemplate: "storefront://registry/examples/{dropinName}",
118
+ name: "Examples by Dropin",
119
+ mimeType: "application/json",
120
+ description: "Working code examples for a specific dropin (extensions, blocks)",
121
+ },
122
+ {
123
+ uriTemplate: "storefront://registry/sdk/{packageName}",
124
+ name: "SDK Package Details",
125
+ mimeType: "application/json",
126
+ description: "Detailed API for a specific SDK package (elsie, event-bus, fetch-graphql, build-tools, recaptcha)",
127
+ },
128
+ {
129
+ uriTemplate: "storefront://registry/graphql/{dropinName}",
130
+ name: "GraphQL by Dropin",
131
+ mimeType: "application/json",
132
+ description: "GraphQL queries and mutations for a specific dropin with full resolved source",
133
+ },
134
+ ];
135
+ const registryLoaders = {
136
+ slots: getSlotRegistry,
137
+ events: getEventCatalog,
138
+ containers: getContainerRegistry,
139
+ "api-functions": getApiFunctionRegistry,
140
+ extensions: getExtensionRegistry,
141
+ "design-tokens": getDesignTokenRegistry,
142
+ "block-patterns": getBlockPatternRegistry,
143
+ examples: getExamplesIndex,
144
+ sdk: getSdkRegistry,
145
+ graphql: getGraphqlRegistry,
146
+ };
147
+ function readRegistryResource(registryType) {
148
+ const loader = registryLoaders[registryType];
149
+ if (!loader) {
150
+ throw new McpError(ErrorCode.InvalidRequest, `Unknown registry type: ${registryType}`);
151
+ }
152
+ return JSON.stringify(loader(), null, 2);
153
+ }
154
+ const paramLookups = {
155
+ slots: {
156
+ getter: getSlotsByDropin,
157
+ notFound: (key) => `Dropin not found: ${key}. Available: ${getAllDropinNames().join(", ")}`,
158
+ },
159
+ events: {
160
+ getter: getEventsByDropin,
161
+ },
162
+ containers: {
163
+ getter: getContainersByDropin,
164
+ notFound: (key) => `Dropin not found: ${key}. Available: ${getAllDropinNames().join(", ")}`,
165
+ },
166
+ "api-functions": {
167
+ getter: getApiFunctionsByDropin,
168
+ notFound: (key) => `Dropin not found: ${key}. Available: ${getAllDropinNames().join(", ")}`,
169
+ },
170
+ examples: {
171
+ getter: getExamplesByDropin,
172
+ notFound: (key) => {
173
+ const available = (getExamplesIndex().dropins ?? []).map((d) => d.dropin);
174
+ return `No examples found for dropin: ${key}. Available: ${available.join(", ")}`;
175
+ },
176
+ },
177
+ sdk: {
178
+ getter: getSdkPackage,
179
+ notFound: (key) => `SDK package not found: ${key}. Available: ${Object.keys(getSdkRegistry().packages).join(", ")}`,
180
+ },
181
+ "design-tokens": {
182
+ getter: getDesignTokensByCategory,
183
+ notFound: (key) => `Category not found: ${key}. Available: ${Object.keys(getDesignTokenRegistry().categories).join(", ")}`,
184
+ },
185
+ graphql: {
186
+ getter: getGraphqlByDropin,
187
+ notFound: (key) => {
188
+ const available = Object.keys(getGraphqlRegistry().dropins ?? {});
189
+ return `No GraphQL operations found for dropin: ${key}. Available: ${available.join(", ")}`;
190
+ },
191
+ },
192
+ };
193
+ function readParameterizedResource(parts) {
194
+ const registryType = parts[0];
195
+ if (registryType === "slots" && parts.length === 3) {
196
+ const data = getSlotsByContainer(parts[1], parts[2]);
197
+ if (!data) {
198
+ throw new McpError(ErrorCode.InvalidRequest, `Container not found: ${parts[2]} in dropin ${parts[1]}`);
199
+ }
200
+ return {
201
+ mimeType: "application/json",
202
+ text: JSON.stringify(data, null, 2),
203
+ };
204
+ }
205
+ if (parts.length === 2) {
206
+ const lookup = paramLookups[registryType];
207
+ if (lookup) {
208
+ const data = lookup.getter(parts[1]);
209
+ if (data == null && lookup.notFound) {
210
+ throw new McpError(ErrorCode.InvalidRequest, lookup.notFound(parts[1]));
211
+ }
212
+ return {
213
+ mimeType: "application/json",
214
+ text: JSON.stringify(data, null, 2),
215
+ };
216
+ }
217
+ }
218
+ throw new McpError(ErrorCode.InvalidRequest, `Unsupported parameterized resource path: ${parts.join("/")}`);
219
+ }
220
+ export const getResourceHandlers = () => ({
221
+ listResources: async () => {
222
+ const guideResources = guides.map((guide) => ({
223
+ uri: guide.uri,
224
+ name: guide.name,
225
+ mimeType: "text/markdown",
226
+ description: guide.description,
227
+ }));
228
+ return {
229
+ resources: [...guideResources, ...registryResources],
230
+ };
231
+ },
232
+ listResourceTemplates: async () => {
233
+ return {
234
+ resourceTemplates,
235
+ };
236
+ },
237
+ readResource: async (request) => {
238
+ const uri = request.params.uri;
239
+ if (!uri.startsWith("storefront://")) {
240
+ throw new McpError(ErrorCode.InvalidRequest, `Invalid URI scheme. Expected storefront://, got: ${uri}`);
241
+ }
242
+ const path = uri.replace("storefront://", "");
243
+ const segments = path.split("/");
244
+ if (segments[0] === "guides") {
245
+ const guidePath = segments.slice(1).join("/");
246
+ const guide = guides.find((g) => g.uri === uri);
247
+ if (!guide) {
248
+ throw new McpError(ErrorCode.InvalidRequest, `Guide not found: ${guidePath}. Available: ${guides.map((g) => g.uri).join(", ")}`);
249
+ }
250
+ return {
251
+ contents: [
252
+ {
253
+ uri,
254
+ mimeType: "text/markdown",
255
+ text: guide.content,
256
+ },
257
+ ],
258
+ };
259
+ }
260
+ if (segments[0] === "docs") {
261
+ if (segments.length === 1) {
262
+ return {
263
+ contents: [
264
+ {
265
+ uri,
266
+ mimeType: "application/json",
267
+ text: JSON.stringify(getDocsIndex(), null, 2),
268
+ },
269
+ ],
270
+ };
271
+ }
272
+ const sectionKey = segments.slice(1).join("/");
273
+ const sectionData = getDocsSection(sectionKey);
274
+ if (!sectionData) {
275
+ const index = getDocsIndex();
276
+ const available = index.sections?.map((s) => s.section) ?? [];
277
+ throw new McpError(ErrorCode.InvalidRequest, `Documentation section not found: ${sectionKey}. Available: ${available.join(", ")}`);
278
+ }
279
+ const enriched = {
280
+ ...sectionData,
281
+ pages: (sectionData.pages ?? []).map((page) => ({
282
+ ...page,
283
+ url: `${DOCS_BASE_URL}/${page.path}`,
284
+ })),
285
+ };
286
+ return {
287
+ contents: [
288
+ {
289
+ uri,
290
+ mimeType: "application/json",
291
+ text: JSON.stringify(enriched, null, 2),
292
+ },
293
+ ],
294
+ };
295
+ }
296
+ if (segments[0] === "registry") {
297
+ const registryParts = segments.slice(1);
298
+ if (registryParts.length === 1) {
299
+ return {
300
+ contents: [
301
+ {
302
+ uri,
303
+ mimeType: "application/json",
304
+ text: readRegistryResource(registryParts[0]),
305
+ },
306
+ ],
307
+ };
308
+ }
309
+ const result = readParameterizedResource(registryParts);
310
+ return {
311
+ contents: [
312
+ {
313
+ uri,
314
+ mimeType: result.mimeType,
315
+ text: result.text,
316
+ },
317
+ ],
318
+ };
319
+ }
320
+ throw new McpError(ErrorCode.InvalidRequest, `Unknown resource path: ${path}`);
321
+ },
322
+ });
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@dropins/mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP server for Adobe Commerce Storefront Dropins — provides AI assistants with deep knowledge of blocks, slots, extensions, events, and design tokens",
5
+ "license": "SEE LICENSE IN LICENSE.md",
6
+ "author": "Adobe Commerce Storefront Team",
7
+ "type": "module",
8
+ "bin": {
9
+ "mcp-server-dropins": "dist/index.js"
10
+ },
11
+ "engines": {
12
+ "node": ">=18.0.0"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build": "shx rm -rf dist && tsc && tsc --project tsconfig.scripts.json && shx cp -r registry dist/registry && tsx scripts/sanitize-registry.ts && shx chmod +x dist/*.js",
22
+ "sanitize:verbose": "tsx scripts/sanitize-registry.ts --verbose",
23
+ "typecheck": "tsc --noEmit && tsc --project tsconfig.scripts.json",
24
+ "prepare": "npm run build",
25
+ "watch": "tsc --watch",
26
+ "generate": "tsx scripts/generate.ts",
27
+ "generate:registry": "tsx scripts/generate-registry.ts",
28
+ "generate:docs": "tsx scripts/generate-docs.ts",
29
+ "generate:examples": "tsx scripts/generate-examples.ts",
30
+ "stats": "tsx scripts/stats.ts",
31
+ "test": "vitest run",
32
+ "test:watch": "vitest",
33
+ "audit:docs": "tsx scripts/audit-docs.ts"
34
+ },
35
+ "dependencies": {
36
+ "@modelcontextprotocol/sdk": "^1.6.1",
37
+ "zod": "^3.22.4",
38
+ "zod-to-json-schema": "^3.23.5"
39
+ },
40
+ "devDependencies": {
41
+ "@types/node": "^20.11.0",
42
+ "shx": "^0.3.4",
43
+ "tsx": "^4.21.0",
44
+ "typescript": "^5.6.2",
45
+ "vitest": "1"
46
+ }
47
+ }