@dynamic-mockups/mcp 1.0.4 → 1.0.6
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/README.md +2 -48
- package/package.json +1 -1
- package/src/index.js +432 -4
package/README.md
CHANGED
|
@@ -64,6 +64,7 @@ If you want to connect via HTTP instead of NPX, use:
|
|
|
64
64
|
| Tool | Description |
|
|
65
65
|
|------|-------------|
|
|
66
66
|
| `get_api_info` | Get API knowledge base (billing, rate limits, formats, best practices, support) |
|
|
67
|
+
| `embed_mockup_editor` | Implement embeddable mockup editor in your app |
|
|
67
68
|
| `get_catalogs` | Retrieve all available catalogs |
|
|
68
69
|
| `get_collections` | Retrieve collections (optionally filter by catalog) |
|
|
69
70
|
| `create_collection` | Create a new collection |
|
|
@@ -81,6 +82,7 @@ Ask your AI assistant:
|
|
|
81
82
|
|
|
82
83
|
| Use Case | Example Prompt |
|
|
83
84
|
|----------|----------------|
|
|
85
|
+
| Embed editor | "Add the full mockup editor to my web application" |
|
|
84
86
|
| List catalogs | "Get my Dynamic Mockups catalogs" |
|
|
85
87
|
| Browse mockups | "Show me all mockups in my T-shirt collection" |
|
|
86
88
|
| Single render | "Create a mockup render using any T-shirt mockup with my artwork from url: https://example.com/my-design.png" |
|
|
@@ -90,54 +92,6 @@ Ask your AI assistant:
|
|
|
90
92
|
| API info | "What are the rate limits and supported file formats for Dynamic Mockups?" |
|
|
91
93
|
| Print files | "Export print-ready files at 300 DPI for my poster mockup" |
|
|
92
94
|
|
|
93
|
-
## Development
|
|
94
|
-
|
|
95
|
-
### Local Installation
|
|
96
|
-
|
|
97
|
-
```bash
|
|
98
|
-
git clone https://github.com/dynamic-mockups/mcp.git
|
|
99
|
-
cd mcp-server
|
|
100
|
-
npm install
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Run Locally (stdio mode - default)
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
DYNAMIC_MOCKUPS_API_KEY=your_key npm start
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### Run Locally (HTTP mode)
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
DYNAMIC_MOCKUPS_API_KEY=your_key npm run start:http
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Development Mode (with auto-reload)
|
|
116
|
-
|
|
117
|
-
```bash
|
|
118
|
-
# stdio mode
|
|
119
|
-
DYNAMIC_MOCKUPS_API_KEY=your_key npm run dev
|
|
120
|
-
|
|
121
|
-
# HTTP mode
|
|
122
|
-
DYNAMIC_MOCKUPS_API_KEY=your_key npm run dev:http
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Use Local Version in MCP Client
|
|
126
|
-
|
|
127
|
-
```json
|
|
128
|
-
{
|
|
129
|
-
"mcpServers": {
|
|
130
|
-
"dynamic-mockups": {
|
|
131
|
-
"command": "node",
|
|
132
|
-
"args": ["/path/to/mcp-server/src/index.js"],
|
|
133
|
-
"env": {
|
|
134
|
-
"DYNAMIC_MOCKUPS_API_KEY": "your_api_key_here"
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
```
|
|
140
|
-
|
|
141
95
|
## Error Handling
|
|
142
96
|
|
|
143
97
|
The server returns clear error messages for common issues:
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -36,6 +36,39 @@ const SERVER_VERSION = "1.0.0";
|
|
|
36
36
|
const API_KNOWLEDGE_BASE = {
|
|
37
37
|
overview: "Dynamic Mockups API allows you to generate product mockups programmatically.",
|
|
38
38
|
|
|
39
|
+
integration: {
|
|
40
|
+
base_url: "https://app.dynamicmockups.com/api/v1",
|
|
41
|
+
required_headers: {
|
|
42
|
+
"Accept": "application/json",
|
|
43
|
+
"x-api-key": "<YOUR_DYNAMIC_MOCKUPS_API_KEY>"
|
|
44
|
+
},
|
|
45
|
+
get_api_key_at: "https://app.dynamicmockups.com/dashboard-api",
|
|
46
|
+
example_endpoints: {
|
|
47
|
+
"GET /catalogs": "List all catalogs",
|
|
48
|
+
"GET /collections": "List collections",
|
|
49
|
+
"POST /collections": "Create a collection",
|
|
50
|
+
"GET /mockups": "List mockup templates",
|
|
51
|
+
"GET /mockup/{uuid}": "Get mockup by UUID",
|
|
52
|
+
"POST /renders": "Create a single render",
|
|
53
|
+
"POST /renders/batch": "Create batch renders",
|
|
54
|
+
"POST /renders/print-files": "Export print files",
|
|
55
|
+
"POST /psd/upload": "Upload a PSD file",
|
|
56
|
+
"POST /psd/delete": "Delete a PSD file"
|
|
57
|
+
},
|
|
58
|
+
code_examples: {
|
|
59
|
+
javascript_fetch: `fetch('https://app.dynamicmockups.com/api/v1/mockups', {
|
|
60
|
+
headers: { 'Accept': 'application/json', 'x-api-key': 'YOUR_API_KEY' }
|
|
61
|
+
})`,
|
|
62
|
+
javascript_axios: `axios.create({
|
|
63
|
+
baseURL: 'https://app.dynamicmockups.com/api/v1',
|
|
64
|
+
headers: { 'Accept': 'application/json', 'x-api-key': 'YOUR_API_KEY' }
|
|
65
|
+
})`,
|
|
66
|
+
python: `requests.get('https://app.dynamicmockups.com/api/v1/mockups',
|
|
67
|
+
headers={'Accept': 'application/json', 'x-api-key': 'YOUR_API_KEY'})`,
|
|
68
|
+
curl: `curl -H "Accept: application/json" -H "x-api-key: YOUR_API_KEY" https://app.dynamicmockups.com/api/v1/mockups`
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
|
|
39
72
|
billing: {
|
|
40
73
|
credits_per_image: 1,
|
|
41
74
|
free_credits: 50,
|
|
@@ -64,8 +97,10 @@ const API_KNOWLEDGE_BASE = {
|
|
|
64
97
|
|
|
65
98
|
best_practices: [
|
|
66
99
|
"Use create_batch_render for multiple images (more efficient than single renders)",
|
|
67
|
-
"Always include Accept: application/json header
|
|
100
|
+
"Always include Accept: application/json header",
|
|
101
|
+
"Always include x-api-key header with your API key",
|
|
68
102
|
"Store rendered image URLs promptly as they expire in 24 hours",
|
|
103
|
+
"Base URL for all API calls: https://app.dynamicmockups.com/api/v1",
|
|
69
104
|
],
|
|
70
105
|
|
|
71
106
|
support: {
|
|
@@ -75,6 +110,290 @@ const API_KNOWLEDGE_BASE = {
|
|
|
75
110
|
},
|
|
76
111
|
};
|
|
77
112
|
|
|
113
|
+
// =============================================================================
|
|
114
|
+
// Embed Editor Knowledge Base
|
|
115
|
+
// =============================================================================
|
|
116
|
+
|
|
117
|
+
const EMBED_EDITOR_KNOWLEDGE_BASE = {
|
|
118
|
+
overview: `Dynamic Mockups Embed Editor lets you add a powerful mockup editor directly to your website or app via iFrame.
|
|
119
|
+
Choose between the Classic Editor (template-based mockups) or MockAnything Editor (AI-powered, turn any image into a mockup).
|
|
120
|
+
No API implementation required - just embed with a few lines of JavaScript.`,
|
|
121
|
+
|
|
122
|
+
editor_types: {
|
|
123
|
+
classic: {
|
|
124
|
+
description: "Template-based mockup editor with catalog of pre-made mockup templates",
|
|
125
|
+
use_case: "Best for consistent, professional product mockups from your template library",
|
|
126
|
+
features: ["Browse mockup catalog", "Upload artwork", "Customize colors", "Export mockups"],
|
|
127
|
+
},
|
|
128
|
+
mockanything: {
|
|
129
|
+
description: "AI-powered editor that turns any image into a customizable mockup",
|
|
130
|
+
use_case: "Best for creative flexibility - generate mockups from any product photo",
|
|
131
|
+
features: ["AI scene generation", "Ethnicity/pose changes", "Environment replacement", "AI photoshoot", "Smart product detection"],
|
|
132
|
+
ai_credits: {
|
|
133
|
+
prompt_generation: "3 credits (SeeDream 4.0)",
|
|
134
|
+
ai_tools: "5 credits (NanoBanana) - scene change, ethnicity, camera angle, environment",
|
|
135
|
+
ai_photoshoot: "3 credits per variation",
|
|
136
|
+
free_features: ["Artwork placement", "Product color changes", "Smart detection", "Exports"],
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
quick_start: {
|
|
142
|
+
step_1_iframe: `<iframe
|
|
143
|
+
id="dm-iframe"
|
|
144
|
+
src="https://embed.dynamicmockups.com"
|
|
145
|
+
style="width: 100%; height: 90vh"
|
|
146
|
+
></iframe>`,
|
|
147
|
+
step_2_cdn_script: `<script src="https://cdn.jsdelivr.net/npm/@dynamic-mockups/mockup-editor-sdk@latest/dist/index.js"></script>`,
|
|
148
|
+
step_3_init: `<script>
|
|
149
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
150
|
+
DynamicMockups.initDynamicMockupsIframe({
|
|
151
|
+
iframeId: "dm-iframe",
|
|
152
|
+
data: { "x-website-key": "YOUR_WEBSITE_KEY" },
|
|
153
|
+
mode: "download",
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
</script>`,
|
|
157
|
+
get_website_key: "https://app.dynamicmockups.com/mockup-editor-embed-integrations",
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
npm_integration: {
|
|
161
|
+
install: "npm install @dynamic-mockups/mockup-editor-sdk@latest",
|
|
162
|
+
usage: `import { initDynamicMockupsIframe } from "@dynamic-mockups/mockup-editor-sdk";
|
|
163
|
+
|
|
164
|
+
initDynamicMockupsIframe({
|
|
165
|
+
iframeId: "dm-iframe",
|
|
166
|
+
data: { "x-website-key": "YOUR_WEBSITE_KEY" },
|
|
167
|
+
mode: "download",
|
|
168
|
+
});`,
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
specific_mockup: {
|
|
172
|
+
description: "Open a specific mockup directly instead of showing the full catalog",
|
|
173
|
+
iframe_src: "https://embed.dynamicmockups.com/mockup/{MOCKUP_UUID}/",
|
|
174
|
+
example: `<iframe
|
|
175
|
+
id="dm-iframe"
|
|
176
|
+
src="https://embed.dynamicmockups.com/mockup/43981bf4-3f1a-46cd-985e-3d9bb40cef36/"
|
|
177
|
+
style="width: 100%; height: 90vh"
|
|
178
|
+
></iframe>`,
|
|
179
|
+
get_uuid: "Use get_mockups API or find in the web app editor URL",
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
init_function_params: {
|
|
183
|
+
iframeId: { type: "string", required: true, default: "dm-iframe", description: "ID of the iframe element" },
|
|
184
|
+
data: { type: "object", required: true, description: "Configuration object for editor behavior" },
|
|
185
|
+
mode: { type: "string", required: true, options: ["download", "custom"], description: "download: user downloads image directly. custom: use callback to handle export" },
|
|
186
|
+
callback: { type: "function", required: false, description: "Required when mode='custom'. Receives export data when user exports mockup" },
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
data_options: {
|
|
190
|
+
"x-website-key": { type: "string", required: true, description: "Your website key from Dynamic Mockups dashboard" },
|
|
191
|
+
editorType: { type: "string", required: false, default: "classic", options: ["classic", "mockanything"], description: "Editor type to display" },
|
|
192
|
+
themeAppearance: { type: "string", required: false, default: "light", options: ["light", "dark"], description: "UI theme" },
|
|
193
|
+
showColorPicker: { type: "boolean", required: false, default: true, description: "Show color picker" },
|
|
194
|
+
showColorPresets: { type: "boolean", required: false, default: false, description: "Show color presets from your account" },
|
|
195
|
+
showCollectionsWidget: { type: "boolean", required: false, default: true, description: "Show collections widget" },
|
|
196
|
+
showSmartObjectArea: { type: "boolean", required: false, default: false, description: "Display smart object boundaries" },
|
|
197
|
+
showTransformControls: { type: "boolean", required: false, default: true, description: "Show width/height/rotate inputs" },
|
|
198
|
+
showArtworkLibrary: { type: "boolean", required: false, default: false, description: "Show artwork library" },
|
|
199
|
+
showUploadYourArtwork: { type: "boolean", required: false, default: true, description: "Show 'Upload your artwork' button" },
|
|
200
|
+
showArtworkEditor: { type: "boolean", required: false, default: true, description: "Show artwork editor" },
|
|
201
|
+
oneColorPerSmartObject: { type: "boolean", required: false, default: false, description: "Restrict to one color per smart object" },
|
|
202
|
+
enableColorOptions: { type: "boolean", required: false, default: true, description: "Display color options" },
|
|
203
|
+
enableCreatePrintFiles: { type: "boolean", required: false, default: false, description: "Enable print file export" },
|
|
204
|
+
enableCollectionExport: { type: "boolean", required: false, default: false, description: "Export all mockups in collection at once" },
|
|
205
|
+
exportMockupsButtonText: { type: "string", required: false, default: "Export Mockups", description: "Custom export button text" },
|
|
206
|
+
designUrl: { type: "string", required: false, description: "Pre-load design URL (disables user upload)" },
|
|
207
|
+
customFields: { type: "object", required: false, description: "Custom data to receive back in callback" },
|
|
208
|
+
mockupExportOptions: {
|
|
209
|
+
image_format: { type: "string", default: "webp", options: ["webp", "jpg", "png"] },
|
|
210
|
+
image_size: { type: "number", default: 1080, description: "Output width in pixels" },
|
|
211
|
+
mode: { type: "string", default: "download", options: ["download", "view"] },
|
|
212
|
+
},
|
|
213
|
+
colorPresets: {
|
|
214
|
+
type: "array",
|
|
215
|
+
required: false,
|
|
216
|
+
description: "Custom color presets for the color picker",
|
|
217
|
+
structure: {
|
|
218
|
+
name: "string (optional) - preset name",
|
|
219
|
+
autoApplyColors: "boolean (optional) - auto-apply colors when selected",
|
|
220
|
+
colors: "array (required) - array of { hex: string, name?: string }",
|
|
221
|
+
},
|
|
222
|
+
example: `[
|
|
223
|
+
{
|
|
224
|
+
name: "Brand Colors",
|
|
225
|
+
autoApplyColors: true,
|
|
226
|
+
colors: [
|
|
227
|
+
{ hex: "#FF5733", name: "Primary" },
|
|
228
|
+
{ hex: "#33FF57", name: "Secondary" }
|
|
229
|
+
]
|
|
230
|
+
}
|
|
231
|
+
]`,
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
integration_steps: {
|
|
236
|
+
classic_cdn: {
|
|
237
|
+
description: "Classic Editor with CDN (simplest setup)",
|
|
238
|
+
steps: [
|
|
239
|
+
"1. Add iframe element with id='dm-iframe' and src='https://embed.dynamicmockups.com'",
|
|
240
|
+
"2. Add SDK script tag from CDN: https://cdn.jsdelivr.net/npm/@dynamic-mockups/mockup-editor-sdk@latest/dist/index.js",
|
|
241
|
+
"3. Call DynamicMockups.initDynamicMockupsIframe() after DOMContentLoaded",
|
|
242
|
+
"4. Pass your x-website-key in the data object",
|
|
243
|
+
],
|
|
244
|
+
},
|
|
245
|
+
classic_npm: {
|
|
246
|
+
description: "Classic Editor with NPM (for React, Vue, etc.)",
|
|
247
|
+
steps: [
|
|
248
|
+
"1. Install package: npm install @dynamic-mockups/mockup-editor-sdk@latest",
|
|
249
|
+
"2. Add iframe element with id='dm-iframe' and src='https://embed.dynamicmockups.com'",
|
|
250
|
+
"3. Import and call initDynamicMockupsIframe() after component mounts",
|
|
251
|
+
"4. Pass your x-website-key in the data object",
|
|
252
|
+
],
|
|
253
|
+
},
|
|
254
|
+
mockanything_static: {
|
|
255
|
+
description: "MockAnything Editor with static iframe (same as Classic but with editorType)",
|
|
256
|
+
steps: [
|
|
257
|
+
"1. Add iframe element with id='dm-iframe' and src='https://embed.dynamicmockups.com'",
|
|
258
|
+
"2. Add SDK script or install NPM package",
|
|
259
|
+
"3. Call initDynamicMockupsIframe() with editorType: 'mockanything' in data object",
|
|
260
|
+
],
|
|
261
|
+
example: `DynamicMockups.initDynamicMockupsIframe({
|
|
262
|
+
iframeId: "dm-iframe",
|
|
263
|
+
data: {
|
|
264
|
+
"x-website-key": "YOUR_WEBSITE_KEY",
|
|
265
|
+
editorType: "mockanything",
|
|
266
|
+
themeAppearance: "dark"
|
|
267
|
+
},
|
|
268
|
+
mode: "download"
|
|
269
|
+
});`,
|
|
270
|
+
},
|
|
271
|
+
mockanything_api: {
|
|
272
|
+
description: "MockAnything Editor with API initialization (dynamic, supports prompts)",
|
|
273
|
+
steps: [
|
|
274
|
+
"1. Install SDK: npm install @dynamic-mockups/mockup-editor-sdk@latest",
|
|
275
|
+
"2. IMPORTANT: Expose initDynamicMockupsIframe globally: window.initDynamicMockupsIframe = initDynamicMockupsIframe",
|
|
276
|
+
"3. Call POST /api/v1/mock-anything/embed/initialize with prompt/image_url/artwork_url",
|
|
277
|
+
"4. Inject the returned iframe_editor HTML into your DOM",
|
|
278
|
+
"5. Execute the returned init_function (use eval() or new Function())",
|
|
279
|
+
"6. Set up window message event listener using the returned event_listener_name",
|
|
280
|
+
],
|
|
281
|
+
critical_note: "You MUST expose initDynamicMockupsIframe globally (step 2) before executing init_function, otherwise the editor won't initialize.",
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
|
|
285
|
+
callback_response: {
|
|
286
|
+
description: "When mode='custom', the callback receives this data on export",
|
|
287
|
+
fields: {
|
|
288
|
+
"mockupsExport[].export_label": "Export identifier/label",
|
|
289
|
+
"mockupsExport[].export_path": "URL to the rendered mockup image",
|
|
290
|
+
"customFields": "Your custom fields echoed back",
|
|
291
|
+
},
|
|
292
|
+
example: `initDynamicMockupsIframe({
|
|
293
|
+
iframeId: "dm-iframe",
|
|
294
|
+
data: {
|
|
295
|
+
"x-website-key": "YOUR_KEY",
|
|
296
|
+
customFields: { userId: "123", productId: "456" }
|
|
297
|
+
},
|
|
298
|
+
mode: "custom",
|
|
299
|
+
callback: (callbackData) => {
|
|
300
|
+
console.log(callbackData.mockupsExport[0].export_path); // Image URL
|
|
301
|
+
console.log(callbackData.customFields); // { userId: "123", productId: "456" }
|
|
302
|
+
},
|
|
303
|
+
});`,
|
|
304
|
+
},
|
|
305
|
+
|
|
306
|
+
mockanything_api_integration: {
|
|
307
|
+
description: "Initialize MockAnything editor dynamically via API (for React, Vue, etc.)",
|
|
308
|
+
endpoint: "POST https://app.dynamicmockups.com/api/v1/mock-anything/embed/initialize",
|
|
309
|
+
headers: { "Content-Type": "application/json", "x-api-key": "YOUR_API_KEY" },
|
|
310
|
+
request_body: {
|
|
311
|
+
prompt: "Optional. AI prompt to generate initial mockup (e.g., 'A guy wearing a Gildan 5000 in Belgrade')",
|
|
312
|
+
image_url: "Optional. URL to product image to use as base",
|
|
313
|
+
artwork_url: "Optional. URL to artwork/logo to pre-load",
|
|
314
|
+
},
|
|
315
|
+
response: {
|
|
316
|
+
iframe_editor: "Complete iframe HTML to inject into DOM",
|
|
317
|
+
init_function: "JavaScript code to initialize the editor",
|
|
318
|
+
event_listener_name: "Unique event name for this editor instance",
|
|
319
|
+
},
|
|
320
|
+
usage: `// 1. Call API
|
|
321
|
+
const response = await fetch("https://app.dynamicmockups.com/api/v1/mock-anything/embed/initialize", {
|
|
322
|
+
method: "POST",
|
|
323
|
+
headers: { "Content-Type": "application/json", "x-api-key": "YOUR_API_KEY" },
|
|
324
|
+
body: JSON.stringify({
|
|
325
|
+
prompt: "A guy wearing a Gildan 5000 t-shirt",
|
|
326
|
+
artwork_url: "https://example.com/logo.png"
|
|
327
|
+
})
|
|
328
|
+
});
|
|
329
|
+
const { data } = await response.json();
|
|
330
|
+
|
|
331
|
+
// 2. Inject iframe
|
|
332
|
+
document.getElementById("editor-container").innerHTML = data.iframe_editor;
|
|
333
|
+
|
|
334
|
+
// 3. Initialize editor
|
|
335
|
+
eval(data.init_function);
|
|
336
|
+
|
|
337
|
+
// 4. Listen for events
|
|
338
|
+
window.addEventListener("message", (event) => {
|
|
339
|
+
if (event.data.eventListenerName === data.event_listener_name) {
|
|
340
|
+
console.log("Editor event:", event.data.data);
|
|
341
|
+
}
|
|
342
|
+
});`,
|
|
343
|
+
},
|
|
344
|
+
|
|
345
|
+
mockanything_events: {
|
|
346
|
+
description: "Events emitted by MockAnything editor via postMessage",
|
|
347
|
+
events: ["editor_ready", "export_completed", "photoshoot_completed", "artwork_updated", "variant_changed"],
|
|
348
|
+
listening: `window.addEventListener("message", (event) => {
|
|
349
|
+
if (event.data.eventListenerName === "YOUR_EVENT_LISTENER_NAME") {
|
|
350
|
+
const payload = event.data.data;
|
|
351
|
+
console.log("Event received:", payload);
|
|
352
|
+
}
|
|
353
|
+
});`,
|
|
354
|
+
},
|
|
355
|
+
|
|
356
|
+
react_example: `import { useState, useEffect } from "react";
|
|
357
|
+
import { initDynamicMockupsIframe } from "@dynamic-mockups/mockup-editor-sdk";
|
|
358
|
+
|
|
359
|
+
// Expose globally for iframe communication
|
|
360
|
+
window.initDynamicMockupsIframe = initDynamicMockupsIframe;
|
|
361
|
+
|
|
362
|
+
export default function MockAnythingEditor() {
|
|
363
|
+
const [iframeData, setIframeData] = useState({ event_listener_name: "", iframe_editor: "", init_function: "" });
|
|
364
|
+
|
|
365
|
+
const launchEditor = async () => {
|
|
366
|
+
const response = await fetch("https://app.dynamicmockups.com/api/v1/mock-anything/embed/initialize", {
|
|
367
|
+
method: "POST",
|
|
368
|
+
headers: { "Content-Type": "application/json", "x-api-key": "YOUR_API_KEY" },
|
|
369
|
+
body: JSON.stringify({ prompt: "A person wearing a t-shirt", artwork_url: "https://example.com/logo.png" })
|
|
370
|
+
});
|
|
371
|
+
const { data } = await response.json();
|
|
372
|
+
setIframeData(data);
|
|
373
|
+
setTimeout(() => eval(data.init_function), 100);
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
useEffect(() => {
|
|
377
|
+
const handleMessage = (event) => {
|
|
378
|
+
if (event.data?.eventListenerName === iframeData.event_listener_name) {
|
|
379
|
+
console.log("Editor event:", event.data.data);
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
window.addEventListener("message", handleMessage);
|
|
383
|
+
return () => window.removeEventListener("message", handleMessage);
|
|
384
|
+
}, [iframeData.event_listener_name]);
|
|
385
|
+
|
|
386
|
+
return (
|
|
387
|
+
<div>
|
|
388
|
+
<button onClick={launchEditor}>Load MockAnything Editor</button>
|
|
389
|
+
<div dangerouslySetInnerHTML={{ __html: iframeData.iframe_editor }} />
|
|
390
|
+
</div>
|
|
391
|
+
);
|
|
392
|
+
}`,
|
|
393
|
+
|
|
394
|
+
docs_url: "https://docs.dynamicmockups.com/mockup-editor-sdk",
|
|
395
|
+
};
|
|
396
|
+
|
|
78
397
|
// =============================================================================
|
|
79
398
|
// Server Initialization
|
|
80
399
|
// =============================================================================
|
|
@@ -168,6 +487,7 @@ function getApiKey(extra) {
|
|
|
168
487
|
//
|
|
169
488
|
// WHEN TO USE EACH TOOL:
|
|
170
489
|
// - get_api_info: First call when user asks about limits, pricing, or capabilities
|
|
490
|
+
// - embed_mockup_editor: When user wants to embed the mockup editor in their website/app
|
|
171
491
|
// - get_catalogs: When user wants to see their workspace organization
|
|
172
492
|
// - get_collections: When user wants to browse mockup groups or find mockups by category
|
|
173
493
|
// - get_mockups: PRIMARY tool - lists templates WITH smart_object UUIDs ready for rendering
|
|
@@ -187,23 +507,74 @@ const tools = [
|
|
|
187
507
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
188
508
|
{
|
|
189
509
|
name: "get_api_info",
|
|
190
|
-
description: `Get Dynamic Mockups API knowledge base including billing, rate limits, supported formats, and best practices.
|
|
510
|
+
description: `Get Dynamic Mockups API knowledge base including integration details, billing, rate limits, supported formats, and best practices.
|
|
191
511
|
|
|
192
512
|
WHEN TO USE: Call this FIRST when user asks about:
|
|
513
|
+
- How to integrate the API directly (base URL, headers, code examples)
|
|
193
514
|
- Pricing, credits, or billing
|
|
194
515
|
- Rate limits or API constraints
|
|
195
516
|
- Supported file formats (input/output)
|
|
196
517
|
- Best practices for rendering
|
|
197
518
|
- How to contact support
|
|
198
519
|
|
|
520
|
+
IMPORTANT FOR DIRECT API INTEGRATION:
|
|
521
|
+
When users want to integrate the Dynamic Mockups API into their own systems (not using MCP tools), use topic="integration" to get:
|
|
522
|
+
- Base URL: https://app.dynamicmockups.com/api/v1
|
|
523
|
+
- Required headers (Accept, x-api-key)
|
|
524
|
+
- Code examples for JavaScript, Python, cURL
|
|
525
|
+
- List of all available endpoints
|
|
526
|
+
|
|
199
527
|
This tool does NOT require an API call - returns cached knowledge instantly.`,
|
|
200
528
|
inputSchema: {
|
|
201
529
|
type: "object",
|
|
202
530
|
properties: {
|
|
203
531
|
topic: {
|
|
204
532
|
type: "string",
|
|
205
|
-
enum: ["all", "billing", "rate_limits", "formats", "best_practices", "support"],
|
|
206
|
-
description: "Specific topic to retrieve. Use '
|
|
533
|
+
enum: ["all", "integration", "billing", "rate_limits", "formats", "best_practices", "support"],
|
|
534
|
+
description: "Specific topic to retrieve. Use 'integration' for API integration details (base URL, headers, code examples). Use 'all' for complete knowledge base.",
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
},
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
name: "embed_mockup_editor",
|
|
541
|
+
description: `Get comprehensive knowledge for embedding the Dynamic Mockups Editor into websites and apps.
|
|
542
|
+
|
|
543
|
+
WHEN TO USE: Call this when user asks about:
|
|
544
|
+
- Embedding a mockup editor in their website/app
|
|
545
|
+
- Adding product customization/personalization features
|
|
546
|
+
- Integrating the Classic Editor or MockAnything (AI) Editor
|
|
547
|
+
- iFrame integration for mockup editing
|
|
548
|
+
- Handling editor events and callbacks
|
|
549
|
+
- React/Vue/JavaScript integration examples
|
|
550
|
+
|
|
551
|
+
TWO EDITOR TYPES:
|
|
552
|
+
1. Classic Editor: Template-based mockups from your catalog
|
|
553
|
+
2. MockAnything Editor: AI-powered - turn any image into a mockup
|
|
554
|
+
|
|
555
|
+
INTEGRATION APPROACHES:
|
|
556
|
+
- CDN: Quick setup with script tag from jsdelivr
|
|
557
|
+
- NPM: @dynamic-mockups/mockup-editor-sdk package for frameworks
|
|
558
|
+
- API: Dynamic initialization via /mock-anything/embed/initialize endpoint
|
|
559
|
+
|
|
560
|
+
TOPICS AVAILABLE:
|
|
561
|
+
- quick_start: Basic iframe + SDK setup (CDN method)
|
|
562
|
+
- npm_integration: NPM package installation and usage
|
|
563
|
+
- data_options: All configuration options for customizing editor behavior
|
|
564
|
+
- callback_response: Handling export events when mode="custom"
|
|
565
|
+
- mockanything_api: Dynamic editor initialization via API
|
|
566
|
+
- mockanything_events: Event system for MockAnything editor
|
|
567
|
+
- react_example: Complete React component example
|
|
568
|
+
- all: Complete knowledge base
|
|
569
|
+
|
|
570
|
+
This tool does NOT require an API call - returns cached knowledge instantly.`,
|
|
571
|
+
inputSchema: {
|
|
572
|
+
type: "object",
|
|
573
|
+
properties: {
|
|
574
|
+
topic: {
|
|
575
|
+
type: "string",
|
|
576
|
+
enum: ["all", "quick_start", "npm_integration", "data_options", "callback_response", "mockanything_api", "mockanything_events", "react_example", "editor_types", "specific_mockup", "integration_steps"],
|
|
577
|
+
description: "Specific topic to retrieve. Use 'quick_start' for basic setup, 'integration_steps' for step-by-step guides, 'data_options' for configuration, 'mockanything_api' for AI editor API integration, 'react_example' for React code. Use 'all' for complete knowledge base.",
|
|
207
578
|
},
|
|
208
579
|
},
|
|
209
580
|
},
|
|
@@ -841,6 +1212,7 @@ async function handleGetApiInfo(args) {
|
|
|
841
1212
|
const topic = args?.topic || "all";
|
|
842
1213
|
|
|
843
1214
|
const topicMap = {
|
|
1215
|
+
integration: { integration: API_KNOWLEDGE_BASE.integration },
|
|
844
1216
|
billing: { billing: API_KNOWLEDGE_BASE.billing },
|
|
845
1217
|
rate_limits: { rate_limits: API_KNOWLEDGE_BASE.rate_limits },
|
|
846
1218
|
formats: { supported_formats: API_KNOWLEDGE_BASE.supported_formats, asset_upload: API_KNOWLEDGE_BASE.asset_upload },
|
|
@@ -852,6 +1224,61 @@ async function handleGetApiInfo(args) {
|
|
|
852
1224
|
return ResponseFormatter.ok(topicMap[topic] || API_KNOWLEDGE_BASE);
|
|
853
1225
|
}
|
|
854
1226
|
|
|
1227
|
+
async function handleGetEmbedEditorInfo(args) {
|
|
1228
|
+
const topic = args?.topic || "all";
|
|
1229
|
+
|
|
1230
|
+
const topicMap = {
|
|
1231
|
+
quick_start: {
|
|
1232
|
+
overview: EMBED_EDITOR_KNOWLEDGE_BASE.overview,
|
|
1233
|
+
quick_start: EMBED_EDITOR_KNOWLEDGE_BASE.quick_start,
|
|
1234
|
+
init_function_params: EMBED_EDITOR_KNOWLEDGE_BASE.init_function_params,
|
|
1235
|
+
integration_steps: EMBED_EDITOR_KNOWLEDGE_BASE.integration_steps,
|
|
1236
|
+
},
|
|
1237
|
+
npm_integration: {
|
|
1238
|
+
npm_integration: EMBED_EDITOR_KNOWLEDGE_BASE.npm_integration,
|
|
1239
|
+
init_function_params: EMBED_EDITOR_KNOWLEDGE_BASE.init_function_params,
|
|
1240
|
+
integration_steps: {
|
|
1241
|
+
classic_npm: EMBED_EDITOR_KNOWLEDGE_BASE.integration_steps.classic_npm,
|
|
1242
|
+
},
|
|
1243
|
+
},
|
|
1244
|
+
data_options: {
|
|
1245
|
+
data_options: EMBED_EDITOR_KNOWLEDGE_BASE.data_options,
|
|
1246
|
+
},
|
|
1247
|
+
callback_response: {
|
|
1248
|
+
callback_response: EMBED_EDITOR_KNOWLEDGE_BASE.callback_response,
|
|
1249
|
+
},
|
|
1250
|
+
mockanything_api: {
|
|
1251
|
+
mockanything_api_integration: EMBED_EDITOR_KNOWLEDGE_BASE.mockanything_api_integration,
|
|
1252
|
+
mockanything_events: EMBED_EDITOR_KNOWLEDGE_BASE.mockanything_events,
|
|
1253
|
+
integration_steps: {
|
|
1254
|
+
mockanything_static: EMBED_EDITOR_KNOWLEDGE_BASE.integration_steps.mockanything_static,
|
|
1255
|
+
mockanything_api: EMBED_EDITOR_KNOWLEDGE_BASE.integration_steps.mockanything_api,
|
|
1256
|
+
},
|
|
1257
|
+
},
|
|
1258
|
+
mockanything_events: {
|
|
1259
|
+
mockanything_events: EMBED_EDITOR_KNOWLEDGE_BASE.mockanything_events,
|
|
1260
|
+
},
|
|
1261
|
+
react_example: {
|
|
1262
|
+
react_example: EMBED_EDITOR_KNOWLEDGE_BASE.react_example,
|
|
1263
|
+
integration_steps: {
|
|
1264
|
+
mockanything_api: EMBED_EDITOR_KNOWLEDGE_BASE.integration_steps.mockanything_api,
|
|
1265
|
+
},
|
|
1266
|
+
},
|
|
1267
|
+
editor_types: {
|
|
1268
|
+
editor_types: EMBED_EDITOR_KNOWLEDGE_BASE.editor_types,
|
|
1269
|
+
},
|
|
1270
|
+
specific_mockup: {
|
|
1271
|
+
specific_mockup: EMBED_EDITOR_KNOWLEDGE_BASE.specific_mockup,
|
|
1272
|
+
},
|
|
1273
|
+
integration_steps: {
|
|
1274
|
+
integration_steps: EMBED_EDITOR_KNOWLEDGE_BASE.integration_steps,
|
|
1275
|
+
},
|
|
1276
|
+
all: EMBED_EDITOR_KNOWLEDGE_BASE,
|
|
1277
|
+
};
|
|
1278
|
+
|
|
1279
|
+
return ResponseFormatter.ok(topicMap[topic] || EMBED_EDITOR_KNOWLEDGE_BASE);
|
|
1280
|
+
}
|
|
1281
|
+
|
|
855
1282
|
async function handleGetCatalogs(args, extra) {
|
|
856
1283
|
const apiKey = getApiKey(extra);
|
|
857
1284
|
const error = validateApiKey(apiKey);
|
|
@@ -1035,6 +1462,7 @@ async function handleDeletePsd(args, extra) {
|
|
|
1035
1462
|
|
|
1036
1463
|
const toolHandlers = {
|
|
1037
1464
|
get_api_info: handleGetApiInfo,
|
|
1465
|
+
embed_mockup_editor: handleGetEmbedEditorInfo,
|
|
1038
1466
|
get_catalogs: handleGetCatalogs,
|
|
1039
1467
|
get_collections: handleGetCollections,
|
|
1040
1468
|
create_collection: handleCreateCollection,
|