@curenorway/kode-mcp 1.0.1 → 1.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.
- package/dist/index.js +208 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -70,6 +70,17 @@ var KodeApiClient = class {
|
|
|
70
70
|
async listPages(siteId) {
|
|
71
71
|
return this.request(`/api/cdn/sites/${siteId}/pages`);
|
|
72
72
|
}
|
|
73
|
+
async assignScriptToPage(pageId, scriptId, loadOrderOverride) {
|
|
74
|
+
await this.request(`/api/cdn/pages/${pageId}/scripts`, {
|
|
75
|
+
method: "POST",
|
|
76
|
+
body: JSON.stringify({ scriptId, loadOrderOverride })
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async removeScriptFromPage(pageId, scriptId) {
|
|
80
|
+
await this.request(`/api/cdn/pages/${pageId}/scripts/${scriptId}`, {
|
|
81
|
+
method: "DELETE"
|
|
82
|
+
});
|
|
83
|
+
}
|
|
73
84
|
// Deployment operations
|
|
74
85
|
async deploy(siteId, options = {}) {
|
|
75
86
|
return this.request("/api/cdn/deploy", {
|
|
@@ -255,7 +266,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
255
266
|
},
|
|
256
267
|
{
|
|
257
268
|
name: "kode_create_script",
|
|
258
|
-
description: "Create a new script on the Cure Kode CDN. The script will be available at the CDN URL after deployment.",
|
|
269
|
+
description: "Create a new script on the Cure Kode CDN. The script will be available at the CDN URL after deployment. Global scripts auto-load by default; page-specific scripts do not.",
|
|
259
270
|
inputSchema: {
|
|
260
271
|
type: "object",
|
|
261
272
|
properties: {
|
|
@@ -276,6 +287,10 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
276
287
|
type: "string",
|
|
277
288
|
enum: ["global", "page-specific"],
|
|
278
289
|
description: 'Script scope - "global" loads on all pages, "page-specific" only on assigned pages. Default: global'
|
|
290
|
+
},
|
|
291
|
+
autoLoad: {
|
|
292
|
+
type: "boolean",
|
|
293
|
+
description: "Whether to auto-load the script. Default: true for global scripts, false for page-specific. Set to false for scripts you want to load manually via CK.loadScript()."
|
|
279
294
|
}
|
|
280
295
|
},
|
|
281
296
|
required: ["name", "type", "content"]
|
|
@@ -283,7 +298,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
283
298
|
},
|
|
284
299
|
{
|
|
285
300
|
name: "kode_update_script",
|
|
286
|
-
description: "Update an existing script's content. This creates a new version of the script.",
|
|
301
|
+
description: "Update an existing script's content or settings. This creates a new version of the script when content changes.",
|
|
287
302
|
inputSchema: {
|
|
288
303
|
type: "object",
|
|
289
304
|
properties: {
|
|
@@ -295,12 +310,21 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
295
310
|
type: "string",
|
|
296
311
|
description: "New script content"
|
|
297
312
|
},
|
|
313
|
+
autoLoad: {
|
|
314
|
+
type: "boolean",
|
|
315
|
+
description: "Whether to auto-load the script. Set to true to load automatically, false for manual loading via CK.loadScript()."
|
|
316
|
+
},
|
|
317
|
+
scope: {
|
|
318
|
+
type: "string",
|
|
319
|
+
enum: ["global", "page-specific"],
|
|
320
|
+
description: "Change script scope. Note: changing to page-specific requires assigning to pages."
|
|
321
|
+
},
|
|
298
322
|
changeSummary: {
|
|
299
323
|
type: "string",
|
|
300
324
|
description: "Brief description of the changes (for version history)"
|
|
301
325
|
}
|
|
302
326
|
},
|
|
303
|
-
required: ["slug"
|
|
327
|
+
required: ["slug"]
|
|
304
328
|
}
|
|
305
329
|
},
|
|
306
330
|
{
|
|
@@ -377,6 +401,46 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
377
401
|
required: []
|
|
378
402
|
}
|
|
379
403
|
},
|
|
404
|
+
{
|
|
405
|
+
name: "kode_assign_script_to_page",
|
|
406
|
+
description: "Assign a page-specific script to a page. Required for page-specific scripts to load on their target pages.",
|
|
407
|
+
inputSchema: {
|
|
408
|
+
type: "object",
|
|
409
|
+
properties: {
|
|
410
|
+
scriptSlug: {
|
|
411
|
+
type: "string",
|
|
412
|
+
description: "Script slug or ID to assign"
|
|
413
|
+
},
|
|
414
|
+
pageSlug: {
|
|
415
|
+
type: "string",
|
|
416
|
+
description: "Page slug or ID to assign the script to"
|
|
417
|
+
},
|
|
418
|
+
loadOrderOverride: {
|
|
419
|
+
type: "number",
|
|
420
|
+
description: "Optional load order for this page (overrides script default)"
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
required: ["scriptSlug", "pageSlug"]
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
name: "kode_remove_script_from_page",
|
|
428
|
+
description: "Remove a script from a page assignment.",
|
|
429
|
+
inputSchema: {
|
|
430
|
+
type: "object",
|
|
431
|
+
properties: {
|
|
432
|
+
scriptSlug: {
|
|
433
|
+
type: "string",
|
|
434
|
+
description: "Script slug or ID to remove"
|
|
435
|
+
},
|
|
436
|
+
pageSlug: {
|
|
437
|
+
type: "string",
|
|
438
|
+
description: "Page slug or ID to remove the script from"
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
required: ["scriptSlug", "pageSlug"]
|
|
442
|
+
}
|
|
443
|
+
},
|
|
380
444
|
{
|
|
381
445
|
name: "kode_site_info",
|
|
382
446
|
description: "Get information about the current Cure Kode site including domains and CDN URLs.",
|
|
@@ -556,20 +620,26 @@ ${script.content}`
|
|
|
556
620
|
};
|
|
557
621
|
}
|
|
558
622
|
case "kode_create_script": {
|
|
559
|
-
const { name: scriptName, type, content, scope } = args;
|
|
623
|
+
const { name: scriptName, type, content, scope, autoLoad } = args;
|
|
624
|
+
const scriptScope = scope || "global";
|
|
560
625
|
const script = await client.createScript(siteId, {
|
|
561
626
|
name: scriptName,
|
|
562
627
|
slug: scriptName,
|
|
563
628
|
type,
|
|
564
629
|
content,
|
|
565
|
-
scope:
|
|
630
|
+
scope: scriptScope,
|
|
631
|
+
autoLoad
|
|
632
|
+
// Let API handle default based on scope
|
|
566
633
|
});
|
|
634
|
+
const autoLoadStatus = script.auto_load ? "will auto-load" : "manual load only (use CK.loadScript())";
|
|
567
635
|
return {
|
|
568
636
|
content: [
|
|
569
637
|
{
|
|
570
638
|
type: "text",
|
|
571
639
|
text: `Created script "${script.name}" (${script.type})
|
|
572
640
|
Slug: ${script.slug}
|
|
641
|
+
Scope: ${script.scope}
|
|
642
|
+
Auto-load: ${autoLoadStatus}
|
|
573
643
|
Version: ${script.current_version}
|
|
574
644
|
|
|
575
645
|
Note: Run kode_deploy to make it live.`
|
|
@@ -578,7 +648,7 @@ Note: Run kode_deploy to make it live.`
|
|
|
578
648
|
};
|
|
579
649
|
}
|
|
580
650
|
case "kode_update_script": {
|
|
581
|
-
const { slug, content, changeSummary } = args;
|
|
651
|
+
const { slug, content, autoLoad, scope, changeSummary } = args;
|
|
582
652
|
const scripts = await client.listScripts(siteId);
|
|
583
653
|
const script = scripts.find((s) => s.slug === slug || s.id === slug);
|
|
584
654
|
if (!script) {
|
|
@@ -587,16 +657,22 @@ Note: Run kode_deploy to make it live.`
|
|
|
587
657
|
isError: true
|
|
588
658
|
};
|
|
589
659
|
}
|
|
590
|
-
const
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
660
|
+
const updateData = {};
|
|
661
|
+
if (content !== void 0) updateData.content = content;
|
|
662
|
+
if (autoLoad !== void 0) updateData.autoLoad = autoLoad;
|
|
663
|
+
if (scope !== void 0) updateData.scope = scope;
|
|
664
|
+
updateData.changeSummary = changeSummary || "Updated via MCP";
|
|
665
|
+
const updated = await client.updateScript(script.id, updateData);
|
|
666
|
+
const changes = [];
|
|
667
|
+
if (content !== void 0) changes.push(`content \u2192 v${updated.current_version}`);
|
|
668
|
+
if (autoLoad !== void 0) changes.push(`auto_load \u2192 ${autoLoad}`);
|
|
669
|
+
if (scope !== void 0) changes.push(`scope \u2192 ${scope}`);
|
|
594
670
|
return {
|
|
595
671
|
content: [
|
|
596
672
|
{
|
|
597
673
|
type: "text",
|
|
598
674
|
text: `Updated script "${updated.name}"
|
|
599
|
-
|
|
675
|
+
Changes: ${changes.join(", ")}
|
|
600
676
|
|
|
601
677
|
Note: Run kode_deploy to make changes live.`
|
|
602
678
|
}
|
|
@@ -764,6 +840,83 @@ Webflow Components:
|
|
|
764
840
|
]
|
|
765
841
|
};
|
|
766
842
|
}
|
|
843
|
+
case "kode_assign_script_to_page": {
|
|
844
|
+
const { scriptSlug, pageSlug, loadOrderOverride } = args;
|
|
845
|
+
const scripts = await client.listScripts(siteId);
|
|
846
|
+
const script = scripts.find((s) => s.slug === scriptSlug || s.id === scriptSlug);
|
|
847
|
+
if (!script) {
|
|
848
|
+
return {
|
|
849
|
+
content: [{ type: "text", text: `Script "${scriptSlug}" not found` }],
|
|
850
|
+
isError: true
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
const pages = await client.listPages(siteId);
|
|
854
|
+
const page = pages.find((p) => p.slug === pageSlug || p.id === pageSlug);
|
|
855
|
+
if (!page) {
|
|
856
|
+
return {
|
|
857
|
+
content: [{ type: "text", text: `Page "${pageSlug}" not found` }],
|
|
858
|
+
isError: true
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
try {
|
|
862
|
+
await client.assignScriptToPage(page.id, script.id, loadOrderOverride);
|
|
863
|
+
return {
|
|
864
|
+
content: [
|
|
865
|
+
{
|
|
866
|
+
type: "text",
|
|
867
|
+
text: `Assigned script "${script.name}" to page "${page.name}"
|
|
868
|
+
URL patterns: ${page.url_patterns.join(", ")}
|
|
869
|
+
|
|
870
|
+
Note: Run kode_deploy to make changes live.`
|
|
871
|
+
}
|
|
872
|
+
]
|
|
873
|
+
};
|
|
874
|
+
} catch (error) {
|
|
875
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
876
|
+
return {
|
|
877
|
+
content: [{ type: "text", text: `Failed to assign script: ${message}` }],
|
|
878
|
+
isError: true
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
case "kode_remove_script_from_page": {
|
|
883
|
+
const { scriptSlug, pageSlug } = args;
|
|
884
|
+
const scripts = await client.listScripts(siteId);
|
|
885
|
+
const script = scripts.find((s) => s.slug === scriptSlug || s.id === scriptSlug);
|
|
886
|
+
if (!script) {
|
|
887
|
+
return {
|
|
888
|
+
content: [{ type: "text", text: `Script "${scriptSlug}" not found` }],
|
|
889
|
+
isError: true
|
|
890
|
+
};
|
|
891
|
+
}
|
|
892
|
+
const pages = await client.listPages(siteId);
|
|
893
|
+
const page = pages.find((p) => p.slug === pageSlug || p.id === pageSlug);
|
|
894
|
+
if (!page) {
|
|
895
|
+
return {
|
|
896
|
+
content: [{ type: "text", text: `Page "${pageSlug}" not found` }],
|
|
897
|
+
isError: true
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
try {
|
|
901
|
+
await client.removeScriptFromPage(page.id, script.id);
|
|
902
|
+
return {
|
|
903
|
+
content: [
|
|
904
|
+
{
|
|
905
|
+
type: "text",
|
|
906
|
+
text: `Removed script "${script.name}" from page "${page.name}"
|
|
907
|
+
|
|
908
|
+
Note: Run kode_deploy to make changes live.`
|
|
909
|
+
}
|
|
910
|
+
]
|
|
911
|
+
};
|
|
912
|
+
} catch (error) {
|
|
913
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
914
|
+
return {
|
|
915
|
+
content: [{ type: "text", text: `Failed to remove script: ${message}` }],
|
|
916
|
+
isError: true
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
}
|
|
767
920
|
case "kode_site_info": {
|
|
768
921
|
const config = getConfig();
|
|
769
922
|
if (!config) {
|
|
@@ -1145,7 +1298,7 @@ Use kode_list_pages_context to see cached pages, or kode_refresh_page to cache a
|
|
|
1145
1298
|
text += `Cached: ${context.extractedAt}${isStale ? ` \u26A0\uFE0F (${cacheAgeDays} days old - consider refreshing with kode_refresh_page)` : ""}
|
|
1146
1299
|
`;
|
|
1147
1300
|
if (context.stats) {
|
|
1148
|
-
text += `Stats: ${context.stats.sectionCount} sections, ${context.stats.ctaCount} CTAs, ${context.stats.formCount} forms, ${context.stats.
|
|
1301
|
+
text += `Stats: ${context.stats.sectionCount} sections, ${context.stats.ctaCount} CTAs, ${context.stats.formCount} forms, ${context.stats.linkCount} links, ${context.stats.gridCount || 0} grids, ${context.stats.imageCount} images, ${context.stats.interactiveCount || 0} interactive
|
|
1149
1302
|
`;
|
|
1150
1303
|
}
|
|
1151
1304
|
text += "\n";
|
|
@@ -1161,6 +1314,17 @@ Use kode_list_pages_context to see cached pages, or kode_refresh_page to cache a
|
|
|
1161
1314
|
`;
|
|
1162
1315
|
if (flags) text += `Flags: [${flags}]
|
|
1163
1316
|
`;
|
|
1317
|
+
if (s.children) {
|
|
1318
|
+
const c = s.children;
|
|
1319
|
+
const childInfo = [
|
|
1320
|
+
c.divs && `${c.divs} divs`,
|
|
1321
|
+
c.links && `${c.links} links`,
|
|
1322
|
+
c.buttons && `${c.buttons} buttons`,
|
|
1323
|
+
c.images && `${c.images} images`
|
|
1324
|
+
].filter(Boolean).join(", ");
|
|
1325
|
+
if (childInfo) text += `Contains: ${childInfo}
|
|
1326
|
+
`;
|
|
1327
|
+
}
|
|
1164
1328
|
if (s.textSample) text += `Preview: ${s.textSample.slice(0, 120)}...
|
|
1165
1329
|
`;
|
|
1166
1330
|
text += "\n";
|
|
@@ -1313,6 +1477,38 @@ Use kode_list_pages_context to see cached pages, or kode_refresh_page to cache a
|
|
|
1313
1477
|
}
|
|
1314
1478
|
text += "\n";
|
|
1315
1479
|
}
|
|
1480
|
+
if (context.grids && context.grids.length > 0) {
|
|
1481
|
+
text += `## Grids/Lists (${context.grids.length})
|
|
1482
|
+
|
|
1483
|
+
`;
|
|
1484
|
+
for (const g of context.grids) {
|
|
1485
|
+
text += `- \`${g.selector}\` (${g.gridType}, ${g.itemCount} items)
|
|
1486
|
+
`;
|
|
1487
|
+
text += ` Item: \`${g.itemSelector}\`
|
|
1488
|
+
`;
|
|
1489
|
+
}
|
|
1490
|
+
text += "\n";
|
|
1491
|
+
}
|
|
1492
|
+
if (context.interactiveElements && context.interactiveElements.length > 0) {
|
|
1493
|
+
text += `## Interactive Elements (${context.interactiveElements.length})
|
|
1494
|
+
|
|
1495
|
+
`;
|
|
1496
|
+
for (const el of context.interactiveElements) {
|
|
1497
|
+
text += `- ${el.type}: \`${el.selector}\`${el.trigger ? ` [${el.trigger}]` : ""}
|
|
1498
|
+
`;
|
|
1499
|
+
}
|
|
1500
|
+
text += "\n";
|
|
1501
|
+
}
|
|
1502
|
+
if (context.links && context.links.length > 0) {
|
|
1503
|
+
const internal = context.links.filter((l) => !l.isExternal).length;
|
|
1504
|
+
const external = context.links.filter((l) => l.isExternal).length;
|
|
1505
|
+
text += `## Links (${context.links.length})
|
|
1506
|
+
|
|
1507
|
+
`;
|
|
1508
|
+
text += `Internal: ${internal}, External: ${external}
|
|
1509
|
+
|
|
1510
|
+
`;
|
|
1511
|
+
}
|
|
1316
1512
|
if (context.notes && context.notes.length > 0) {
|
|
1317
1513
|
text += `## Notes
|
|
1318
1514
|
|