@cascivo/mcp 0.2.0 → 0.3.3
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/LICENSE +1 -1
- package/README.md +53 -23
- package/dist/context/accordion.md +93 -0
- package/dist/context/action-sheet.md +117 -0
- package/dist/context/alert-dialog.md +122 -0
- package/dist/context/alert.md +110 -0
- package/dist/context/app-shell.md +98 -0
- package/dist/context/aspect-ratio.md +92 -0
- package/dist/context/avatar-group.md +111 -0
- package/dist/context/avatar.md +100 -0
- package/dist/context/badge.md +119 -0
- package/dist/context/block/console-app.md +66 -0
- package/dist/context/block/dashboard-charts.md +61 -0
- package/dist/context/block/empty-dashboard.md +60 -0
- package/dist/context/block/login-page.md +60 -0
- package/dist/context/block/notification-center.md +61 -0
- package/dist/context/block/page-with-breadcrumb.md +54 -0
- package/dist/context/block/settings-form-page.md +60 -0
- package/dist/context/block/sidebar-app.md +55 -0
- package/dist/context/block/stats-cards.md +61 -0
- package/dist/context/block/users-table-page.md +61 -0
- package/dist/context/blockquote.md +95 -0
- package/dist/context/bottom-sheet.md +112 -0
- package/dist/context/breadcrumb.md +106 -0
- package/dist/context/button-group.md +100 -0
- package/dist/context/button.md +117 -0
- package/dist/context/calendar.md +118 -0
- package/dist/context/card.md +90 -0
- package/dist/context/carousel.md +101 -0
- package/dist/context/chart/area-chart.md +99 -0
- package/dist/context/chart/bar-chart.md +114 -0
- package/dist/context/chart/boxplot.md +82 -0
- package/dist/context/chart/bubble-chart.md +80 -0
- package/dist/context/chart/bullet.md +75 -0
- package/dist/context/chart/calendar.md +79 -0
- package/dist/context/chart/candlestick.md +104 -0
- package/dist/context/chart/combo-chart.md +78 -0
- package/dist/context/chart/funnel.md +87 -0
- package/dist/context/chart/gauge.md +87 -0
- package/dist/context/chart/heatmap.md +77 -0
- package/dist/context/chart/histogram.md +74 -0
- package/dist/context/chart/kpi.md +70 -0
- package/dist/context/chart/line-chart.md +113 -0
- package/dist/context/chart/meter.md +71 -0
- package/dist/context/chart/pie-chart.md +126 -0
- package/dist/context/chart/polar.md +92 -0
- package/dist/context/chart/radar.md +81 -0
- package/dist/context/chart/radial-bar.md +96 -0
- package/dist/context/chart/sankey.md +89 -0
- package/dist/context/chart/scatter-chart.md +90 -0
- package/dist/context/chart/sparkline.md +69 -0
- package/dist/context/chart/stream.md +88 -0
- package/dist/context/chart/sunburst.md +93 -0
- package/dist/context/chart/treemap.md +84 -0
- package/dist/context/chat-bubble.md +116 -0
- package/dist/context/checkbox-card.md +104 -0
- package/dist/context/checkbox.md +104 -0
- package/dist/context/code-snippet.md +118 -0
- package/dist/context/code.md +103 -0
- package/dist/context/collapsible.md +104 -0
- package/dist/context/color-picker.md +101 -0
- package/dist/context/combobox.md +125 -0
- package/dist/context/command-menu.md +121 -0
- package/dist/context/comparison.md +117 -0
- package/dist/context/contained-list.md +103 -0
- package/dist/context/context-menu.md +103 -0
- package/dist/context/copy-button.md +106 -0
- package/dist/context/data-list.md +99 -0
- package/dist/context/data-table.md +149 -0
- package/dist/context/date-picker.md +116 -0
- package/dist/context/date-range-picker.md +113 -0
- package/dist/context/dock.md +117 -0
- package/dist/context/drawer.md +111 -0
- package/dist/context/dropdown.md +96 -0
- package/dist/context/editable.md +101 -0
- package/dist/context/editor/code-editor.md +146 -0
- package/dist/context/editor/highlight.md +74 -0
- package/dist/context/empty-state.md +101 -0
- package/dist/context/fab.md +128 -0
- package/dist/context/field.md +118 -0
- package/dist/context/file-uploader.md +121 -0
- package/dist/context/filter.md +129 -0
- package/dist/context/flow/flow-background.md +103 -0
- package/dist/context/flow/flow-canvas.md +82 -0
- package/dist/context/flow/flow-controls.md +84 -0
- package/dist/context/flow/flow-edge.md +128 -0
- package/dist/context/flow/flow-handle.md +83 -0
- package/dist/context/flow/flow-minimap.md +89 -0
- package/dist/context/flow/flow-node.md +97 -0
- package/dist/context/flow/flow-panel.md +75 -0
- package/dist/context/flow/flow-story.md +145 -0
- package/dist/context/flow/flow.md +139 -0
- package/dist/context/form.md +104 -0
- package/dist/context/header-panel.md +96 -0
- package/dist/context/header.md +104 -0
- package/dist/context/heading.md +107 -0
- package/dist/context/hover-card.md +108 -0
- package/dist/context/icon-button.md +115 -0
- package/dist/context/image.md +115 -0
- package/dist/context/indicator.md +95 -0
- package/dist/context/inline-loading.md +101 -0
- package/dist/context/input-group.md +122 -0
- package/dist/context/input.md +101 -0
- package/dist/context/item.md +109 -0
- package/dist/context/join.md +97 -0
- package/dist/context/kbd.md +100 -0
- package/dist/context/label.md +117 -0
- package/dist/context/layout/app-shell.md +85 -0
- package/dist/context/layout/auth-layout.md +74 -0
- package/dist/context/layout/auto-grid.md +69 -0
- package/dist/context/layout/center.md +67 -0
- package/dist/context/layout/columns.md +70 -0
- package/dist/context/layout/dashboard-layout.md +68 -0
- package/dist/context/layout/grid.md +70 -0
- package/dist/context/layout/masonry.md +70 -0
- package/dist/context/layout/page-header.md +75 -0
- package/dist/context/layout/section.md +69 -0
- package/dist/context/layout/settings-layout.md +68 -0
- package/dist/context/layout/spacer.md +64 -0
- package/dist/context/layout/split-view.md +71 -0
- package/dist/context/layout/stack.md +93 -0
- package/dist/context/link.md +112 -0
- package/dist/context/list.md +109 -0
- package/dist/context/log-viewer.md +124 -0
- package/dist/context/menu-button.md +137 -0
- package/dist/context/menu.md +108 -0
- package/dist/context/menubar.md +92 -0
- package/dist/context/modal.md +96 -0
- package/dist/context/multi-select.md +104 -0
- package/dist/context/native-select.md +118 -0
- package/dist/context/navigation-menu.md +95 -0
- package/dist/context/notification.md +116 -0
- package/dist/context/number-input.md +117 -0
- package/dist/context/otp-input.md +98 -0
- package/dist/context/overflow-menu.md +107 -0
- package/dist/context/pagination.md +123 -0
- package/dist/context/password-input.md +100 -0
- package/dist/context/popover.md +108 -0
- package/dist/context/progress-bar.md +107 -0
- package/dist/context/progress-circle.md +101 -0
- package/dist/context/progress-indicator.md +105 -0
- package/dist/context/progress.md +109 -0
- package/dist/context/prose.md +110 -0
- package/dist/context/pull-to-refresh.md +101 -0
- package/dist/context/qr-code.md +101 -0
- package/dist/context/radial-progress.md +117 -0
- package/dist/context/radio-card.md +95 -0
- package/dist/context/radio.md +94 -0
- package/dist/context/rating-group.md +97 -0
- package/dist/context/relative-time.md +90 -0
- package/dist/context/resizable.md +102 -0
- package/dist/context/scroll-area.md +101 -0
- package/dist/context/search.md +113 -0
- package/dist/context/section/cta.md +83 -0
- package/dist/context/section/feature-grid.md +98 -0
- package/dist/context/section/hero.md +101 -0
- package/dist/context/section/media-masonry.md +77 -0
- package/dist/context/section/page-footer.md +101 -0
- package/dist/context/section/stats-band.md +81 -0
- package/dist/context/segmented-control.md +101 -0
- package/dist/context/select.md +101 -0
- package/dist/context/separator.md +88 -0
- package/dist/context/sheet.md +100 -0
- package/dist/context/shell-header.md +105 -0
- package/dist/context/side-nav.md +134 -0
- package/dist/context/skeleton.md +101 -0
- package/dist/context/skip-nav.md +103 -0
- package/dist/context/slider.md +98 -0
- package/dist/context/spinner.md +89 -0
- package/dist/context/stack.md +96 -0
- package/dist/context/stat.md +101 -0
- package/dist/context/status.md +105 -0
- package/dist/context/steps.md +124 -0
- package/dist/context/structured-list.md +107 -0
- package/dist/context/swap.md +100 -0
- package/dist/context/swipe-item.md +110 -0
- package/dist/context/switcher.md +97 -0
- package/dist/context/tabs.md +93 -0
- package/dist/context/tag.md +110 -0
- package/dist/context/tags-input.md +94 -0
- package/dist/context/text.md +111 -0
- package/dist/context/textarea.md +98 -0
- package/dist/context/tile.md +116 -0
- package/dist/context/time-picker.md +102 -0
- package/dist/context/timeline.md +93 -0
- package/dist/context/toast.md +91 -0
- package/dist/context/toc.md +110 -0
- package/dist/context/toggle-group.md +118 -0
- package/dist/context/toggle.md +103 -0
- package/dist/context/toggletip.md +119 -0
- package/dist/context/tooltip.md +92 -0
- package/dist/context/tree-view.md +107 -0
- package/dist/context/user.md +100 -0
- package/dist/context/visually-hidden.md +90 -0
- package/dist/context.json +22456 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +73 -32
- package/dist/index.mjs.map +1 -1
- package/dist/marketplace.json +70 -0
- package/dist/registry.json +2832 -358
- package/dist/tokens.catalog.json +2375 -0
- package/dist/tokens.variants.json +3291 -0
- package/package.json +4 -3
- package/readme.body.md +53 -23
package/dist/index.d.mts
CHANGED
|
@@ -75,6 +75,8 @@ interface RegistryComponent {
|
|
|
75
75
|
category: string;
|
|
76
76
|
version: string;
|
|
77
77
|
files: string[];
|
|
78
|
+
/** filename → sha256 of upstream content — lets agents detect drift between installed and current source. */
|
|
79
|
+
fileHashes?: Record<string, string>;
|
|
78
80
|
dependencies: string[];
|
|
79
81
|
tags: string[];
|
|
80
82
|
meta: ComponentManifest;
|
|
@@ -139,7 +141,7 @@ interface GenerationPromptOptions {
|
|
|
139
141
|
declare function buildGenerationPrompt(registry: Registry, options?: GenerationPromptOptions): string;
|
|
140
142
|
//#endregion
|
|
141
143
|
//#region src/index.d.ts
|
|
142
|
-
declare const VERSION
|
|
144
|
+
declare const VERSION: string;
|
|
143
145
|
/** Start the MCP server over stdio. */
|
|
144
146
|
declare function main(): Promise<void>;
|
|
145
147
|
//#endregion
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/server.ts","../src/theme.ts","../src/scaffold.ts","../src/registry.ts","../src/grammar.ts","../src/prompt.ts","../src/index.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/server.ts","../src/theme.ts","../src/scaffold.ts","../src/registry.ts","../src/grammar.ts","../src/prompt.ts","../src/index.ts"],"mappings":";;;KA4BK,OAAA,IAAW,GAAA,UAAa,IAAA,GAAO,WAAA,KAAgB,OAAA,CAAQ,QAAA;AAAA,UAE3C,aAAA;EACf,YAAA;EACA,OAAA;;EAEA,OAAA,GAAU,OAAO;AAAA;;iBAeH,YAAA,CAAa,OAAA,GAAS,aAAA,GAAqB,SAAS;;;UCjDnD,WAAA;;EAEf,OAAA;ED0BG;ECxBH,OAAA;;EAEA,MAAA;AAAA;;;;;AD4BiB;iBCkJH,gBAAA,CAAiB,MAAA,EAAQ,WAAW,EAAE,IAAA;;;UCpLrC,eAAA;EACf,WAAA;EACA,UAAU;AAAA;;;;;iBAgCI,YAAA,CAAa,OAAwB,EAAf,eAAe;;;UC7BpC,YAAA;EACf,IAAA;EACA,IAAA;EACA,QAAA;EACA,OAAA;EACA,WAAA;AAAA;AAAA,UAGe,iBAAA;EACf,IAAA;EACA,WAAA;EACA,QAAA;EACA,MAAA;EACA,QAAA;EACA,KAAA;EACA,KAAA,EAAO,YAAY;EACnB,MAAA;EACA,aAAA;IAAiB,IAAA;IAAc,IAAA;IAAc,QAAA;EAAA;EAC7C,QAAA;IAAY,KAAA;IAAe,IAAA;IAAc,WAAA;EAAA;EACzC,YAAA;EACA,IAAA;AAAA;AAAA,UAGe,iBAAA;EACf,IAAA;EACA,IAAA;EACA,WAAA;EACA,QAAA;EACA,OAAA;EACA,KAAA;EHekE;EGblE,UAAA,GAAa,MAAA;EACb,YAAA;EACA,IAAA;EACA,IAAA,EAAM,iBAAiB;AAAA;AAAA,UAGR,QAAA;EACf,OAAA;EACA,WAAA;EACA,UAAA,EAAY,iBAAiB;AAAA;AAAA,iBAwBf,YAAA,CAAa,IAAA,YAAgB,QAAQ;;iBAUrC,cAAA,CACd,QAAA,EAAU,QAAA,EACV,QAAA,WACA,IAAA,YACC,iBAAiB;;iBAQJ,YAAA,CAAa,QAAA,EAAU,QAAA,EAAU,IAAA,WAAe,iBAAiB;AA9EjF;AAAA,iBA0MgB,gBAAA,CAAiB,QAAA,EAAU,QAAA,EAAU,KAAA,WAAgB,iBAAiB;;;UC3MrE,WAAA;EACf,IAAA;EACA,QAAA;EJcU;EIZV,IAAA;EJYkC;EIVlC,IAAA;AAAA;AAAA,UAGe,gBAAA;EACf,IAAA;EACA,QAAA;EACA,KAAA,EAAO,WAAW;EAClB,QAAA;EACA,KAAA;AAAA;AAAA,UAGe,WAAA;EACf,UAAA,EAAY,gBAAgB;AAAA;;;;;;iBAQd,SAAA,CAAU,IAAY;AAAA,iBA8BtB,YAAA,CAAa,QAAA,EAAU,QAAA,EAAU,MAAA,cAAoB,WAAW;;AJlC7D;AAenB;;;;iBI0EgB,aAAA,CAAc,OAAoB,EAAX,WAAW;;;UChHjC,uBAAA;;EAEf,UAAU;AAAA;;;;;;iBAsCI,qBAAA,CACd,QAAA,EAAU,QAAA,EACV,OAAA,GAAS,uBAA4B;;;cC5C1B,OAAA;;iBA4BS,IAAA,IAAQ,OAAO"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import { argv } from "node:process";
|
|
3
4
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
5
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
@@ -7,6 +8,15 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
7
8
|
import { z } from "zod";
|
|
8
9
|
import { existsSync, readFileSync } from "node:fs";
|
|
9
10
|
import { dirname, join } from "node:path";
|
|
11
|
+
//#region src/host.ts
|
|
12
|
+
/**
|
|
13
|
+
* Canonical host for hosted cascivo artifacts (registry.json, context.json,
|
|
14
|
+
* tokens.catalog.json, marketplace.json, per-item r/<name>.json, llms.txt).
|
|
15
|
+
* docs.cascivo.com serves the same tree as a mirror — code always fetches the
|
|
16
|
+
* canonical host. Keep in sync with CASCIVO_HOST in packages/cli.
|
|
17
|
+
*/
|
|
18
|
+
const CASCIVO_HOST = "https://cascivo.com";
|
|
19
|
+
//#endregion
|
|
10
20
|
//#region src/registry.ts
|
|
11
21
|
const HERE$4 = dirname(fileURLToPath(import.meta.url));
|
|
12
22
|
/**
|
|
@@ -42,7 +52,23 @@ function getComponent(registry, name) {
|
|
|
42
52
|
const target = name.toLowerCase();
|
|
43
53
|
return registry.components.find((c) => c.name.toLowerCase() === target || c.meta.name.toLowerCase() === target)?.meta;
|
|
44
54
|
}
|
|
45
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Manifest enriched with distribution facts (version, file hashes) so an agent
|
|
57
|
+
* can compare its installed copy against upstream — `getComponent` alone
|
|
58
|
+
* drops those registry-entry fields.
|
|
59
|
+
*/
|
|
60
|
+
function getComponentWithVersion(registry, name) {
|
|
61
|
+
const target = name.toLowerCase();
|
|
62
|
+
const entry = registry.components.find((c) => c.name.toLowerCase() === target || c.meta.name.toLowerCase() === target);
|
|
63
|
+
if (!entry) return void 0;
|
|
64
|
+
return {
|
|
65
|
+
...entry.meta,
|
|
66
|
+
version: entry.version,
|
|
67
|
+
files: entry.files,
|
|
68
|
+
...entry.fileHashes ? { fileHashes: entry.fileHashes } : {}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const DIRECTORY_URL = `${CASCIVO_HOST}/r/registries.json`;
|
|
46
72
|
const FETCH_TIMEOUT_MS = 15e3;
|
|
47
73
|
const MAX_BODY_BYTES = 1048576;
|
|
48
74
|
async function fetchWithGuards(url, fetchFn = fetch) {
|
|
@@ -608,18 +634,18 @@ function buildGenerationPrompt(registry, options = {}) {
|
|
|
608
634
|
//#endregion
|
|
609
635
|
//#region src/tokens.ts
|
|
610
636
|
const HERE$3 = dirname(fileURLToPath(import.meta.url));
|
|
611
|
-
const CATALOG_BASE_URL =
|
|
637
|
+
const CATALOG_BASE_URL$1 = CASCIVO_HOST;
|
|
612
638
|
async function loadTokenCatalog(fetchFn) {
|
|
613
639
|
const localPaths = [join(HERE$3, "..", "..", "..", "apps", "site", "public", "tokens.catalog.json"), join(HERE$3, "tokens.catalog.json")];
|
|
614
640
|
for (const p of localPaths) if (existsSync(p)) return JSON.parse(readFileSync(p, "utf8"));
|
|
615
|
-
const res = await (fetchFn ?? fetch)(`${CATALOG_BASE_URL}/tokens.catalog.json`);
|
|
641
|
+
const res = await (fetchFn ?? fetch)(`${CATALOG_BASE_URL$1}/tokens.catalog.json`);
|
|
616
642
|
if (!res.ok) throw new Error(`Failed to fetch token catalog: ${res.status}`);
|
|
617
643
|
return res.json();
|
|
618
644
|
}
|
|
619
645
|
//#endregion
|
|
620
646
|
//#region src/variants.ts
|
|
621
647
|
const HERE$2 = dirname(fileURLToPath(import.meta.url));
|
|
622
|
-
const BASE_URL =
|
|
648
|
+
const BASE_URL = CASCIVO_HOST;
|
|
623
649
|
async function loadVariantMatrix(fetchFn) {
|
|
624
650
|
const localPaths = [join(HERE$2, "..", "..", "..", "apps", "site", "public", "tokens.variants.json"), join(HERE$2, "tokens.variants.json")];
|
|
625
651
|
for (const p of localPaths) if (existsSync(p)) return JSON.parse(readFileSync(p, "utf8"));
|
|
@@ -799,7 +825,7 @@ function validateComponentSource(input, options = {}) {
|
|
|
799
825
|
//#endregion
|
|
800
826
|
//#region src/context.ts
|
|
801
827
|
const HERE$1 = dirname(fileURLToPath(import.meta.url));
|
|
802
|
-
const CONTEXT_BASE_URL =
|
|
828
|
+
const CONTEXT_BASE_URL = CASCIVO_HOST;
|
|
803
829
|
async function loadContext(fetchFn) {
|
|
804
830
|
const localPaths = [join(HERE$1, "..", "..", "..", "apps", "site", "public", "context.json"), join(HERE$1, "context.json")];
|
|
805
831
|
for (const p of localPaths) if (existsSync(p)) return JSON.parse(readFileSync(p, "utf8"));
|
|
@@ -874,39 +900,42 @@ function selectComponent(need, components) {
|
|
|
874
900
|
//#endregion
|
|
875
901
|
//#region src/templates.ts
|
|
876
902
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
877
|
-
const
|
|
878
|
-
generatedAt: "",
|
|
879
|
-
templates: [],
|
|
880
|
-
facets: {
|
|
881
|
-
categories: [],
|
|
882
|
-
frameworks: [],
|
|
883
|
-
tags: []
|
|
884
|
-
}
|
|
885
|
-
};
|
|
903
|
+
const CATALOG_BASE_URL = CASCIVO_HOST;
|
|
886
904
|
/**
|
|
887
|
-
* Resolve
|
|
905
|
+
* Resolve a local marketplace catalog. Checks, in order: an explicit path,
|
|
888
906
|
* the `CASCIVO_MARKETPLACE_PATH` env var, a copy bundled next to the built
|
|
889
907
|
* server, and the in-repo `apps/site/public/marketplace.json` (dev).
|
|
908
|
+
* Returns null when no candidate exists on disk.
|
|
890
909
|
*/
|
|
891
910
|
function resolveCatalogPath(explicit) {
|
|
892
|
-
|
|
911
|
+
return [
|
|
893
912
|
explicit,
|
|
894
913
|
process.env.CASCIVO_MARKETPLACE_PATH,
|
|
895
914
|
join(HERE, "marketplace.json"),
|
|
896
915
|
join(HERE, "..", "..", "..", "apps", "site", "public", "marketplace.json"),
|
|
897
916
|
join(HERE, "..", "..", "apps", "site", "public", "marketplace.json")
|
|
898
|
-
].filter((p) => typeof p === "string" && p.length > 0);
|
|
899
|
-
return candidates.find((p) => existsSync(p)) ?? candidates[candidates.length - 1] ?? "";
|
|
917
|
+
].filter((p) => typeof p === "string" && p.length > 0).find((p) => existsSync(p)) ?? null;
|
|
900
918
|
}
|
|
901
|
-
/**
|
|
902
|
-
|
|
919
|
+
/**
|
|
920
|
+
* Load the marketplace catalog: bundled/local copy first, then the hosted one.
|
|
921
|
+
* Throws when neither is available — an empty catalog would silently make
|
|
922
|
+
* every template invisible, which is worse than a visible error.
|
|
923
|
+
*/
|
|
924
|
+
async function loadCatalog(explicit, fetchFn) {
|
|
903
925
|
const path = resolveCatalogPath(explicit);
|
|
904
|
-
if (
|
|
905
|
-
try {
|
|
926
|
+
if (path) try {
|
|
906
927
|
return JSON.parse(readFileSync(path, "utf8"));
|
|
907
|
-
} catch {
|
|
908
|
-
|
|
928
|
+
} catch {}
|
|
929
|
+
const url = `${CATALOG_BASE_URL}/marketplace.json`;
|
|
930
|
+
const fn = fetchFn ?? fetch;
|
|
931
|
+
let res;
|
|
932
|
+
try {
|
|
933
|
+
res = await fn(url);
|
|
934
|
+
} catch (e) {
|
|
935
|
+
throw new Error(`Marketplace catalog unavailable: no local copy and ${url} unreachable (${e instanceof Error ? e.message : e})`);
|
|
909
936
|
}
|
|
937
|
+
if (!res.ok) throw new Error(`Marketplace catalog unavailable: no local copy and ${url} returned ${res.status}`);
|
|
938
|
+
return res.json();
|
|
910
939
|
}
|
|
911
940
|
/** Filter the catalog's templates. Pure. */
|
|
912
941
|
function listTemplates(catalog, filter = {}) {
|
|
@@ -999,7 +1028,7 @@ function createServer(options = {}) {
|
|
|
999
1028
|
const meta = getComponent(remoteRegistry, name);
|
|
1000
1029
|
return meta ? json(meta) : error(`Component "${name}" not found in registry "${ns}".`);
|
|
1001
1030
|
}
|
|
1002
|
-
const meta =
|
|
1031
|
+
const meta = getComponentWithVersion(registry, name);
|
|
1003
1032
|
return meta ? json(meta) : error(`Component "${name}" not found.`);
|
|
1004
1033
|
});
|
|
1005
1034
|
server.registerTool("search_components", {
|
|
@@ -1053,8 +1082,13 @@ function createServer(options = {}) {
|
|
|
1053
1082
|
framework: z.enum(["react-vite", "react-next"]).optional().describe("Filter by target framework"),
|
|
1054
1083
|
verifiedOnly: z.boolean().optional().describe("Only verified templates")
|
|
1055
1084
|
}
|
|
1056
|
-
}, ({ category, tag, framework, verifiedOnly }) => {
|
|
1057
|
-
|
|
1085
|
+
}, async ({ category, tag, framework, verifiedOnly }) => {
|
|
1086
|
+
let catalog;
|
|
1087
|
+
try {
|
|
1088
|
+
catalog = await loadCatalog(void 0, fetchFn);
|
|
1089
|
+
} catch (e) {
|
|
1090
|
+
return error(e instanceof Error ? e.message : String(e));
|
|
1091
|
+
}
|
|
1058
1092
|
const filter = {};
|
|
1059
1093
|
if (category) filter.category = category;
|
|
1060
1094
|
if (tag) filter.tag = tag;
|
|
@@ -1066,8 +1100,14 @@ function createServer(options = {}) {
|
|
|
1066
1100
|
title: "Get template",
|
|
1067
1101
|
description: "Get one marketplace template by name or install spec — its components, install command, demo link, and screenshots.",
|
|
1068
1102
|
inputSchema: { name: z.string().describe("Template name or install spec, e.g. \"@cascivo/dashboard\"") }
|
|
1069
|
-
}, ({ name }) => {
|
|
1070
|
-
|
|
1103
|
+
}, async ({ name }) => {
|
|
1104
|
+
let catalog;
|
|
1105
|
+
try {
|
|
1106
|
+
catalog = await loadCatalog(void 0, fetchFn);
|
|
1107
|
+
} catch (e) {
|
|
1108
|
+
return error(e instanceof Error ? e.message : String(e));
|
|
1109
|
+
}
|
|
1110
|
+
const tpl = getTemplate(catalog, name);
|
|
1071
1111
|
if (!tpl) return error(`Template "${name}" not found in the marketplace catalog.`);
|
|
1072
1112
|
return json(tpl);
|
|
1073
1113
|
});
|
|
@@ -1078,8 +1118,9 @@ function createServer(options = {}) {
|
|
|
1078
1118
|
name: z.string().describe("Template name or install spec, e.g. \"@cascivo/dashboard\""),
|
|
1079
1119
|
cwd: z.string().optional().describe("Project directory (default: current directory)")
|
|
1080
1120
|
}
|
|
1081
|
-
}, ({ name, cwd }) => {
|
|
1082
|
-
const
|
|
1121
|
+
}, async ({ name, cwd }) => {
|
|
1122
|
+
const catalog = await loadCatalog(void 0, fetchFn).catch(() => null);
|
|
1123
|
+
const spec = (catalog ? getTemplate(catalog, name)?.installSpec : void 0) ?? name;
|
|
1083
1124
|
const result = spawnSync("npx", [
|
|
1084
1125
|
"-y",
|
|
1085
1126
|
"cascivo",
|
|
@@ -1374,7 +1415,7 @@ export function Diagram() {
|
|
|
1374
1415
|
}
|
|
1375
1416
|
//#endregion
|
|
1376
1417
|
//#region src/index.ts
|
|
1377
|
-
const VERSION = "
|
|
1418
|
+
const VERSION = createRequire(import.meta.url)("../package.json").version;
|
|
1378
1419
|
/** Start the MCP server over stdio. */
|
|
1379
1420
|
async function main() {
|
|
1380
1421
|
await createServer({ version: VERSION }).connect(new StdioServerTransport());
|