@cloudgrid-io/mcp 0.20.22 → 0.20.23
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/package.json +3 -2
- package/src/tools/deploy.js +86 -29
- package/src/tools/register.js +3 -2
- package/src/tools.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudgrid-io/mcp",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.23",
|
|
4
4
|
"description": "Use CloudGrid via MCP to brainstorm, build, deploy, and improve apps, games, websites, dashboards, and tools and get a live URL - templates, recipes, managed databases and AI, instant single-page publish, and full-app deploys, for developers and non-technical users. Three editions: local stdio (full toolset), hosted web (light, CLI-free), and a public docs-search server, over MCP.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
"snapshot:corpus": "node scripts/snapshot-corpus.mjs",
|
|
51
51
|
"build:mcpb": "node scripts/build-mcpb.mjs",
|
|
52
52
|
"test:widgets": "node test/apps-widgets.test.mjs",
|
|
53
|
-
"test:fork": "node test/fork.test.mjs"
|
|
53
|
+
"test:fork": "node test/fork.test.mjs",
|
|
54
|
+
"test:set-sharing": "node test/set-sharing.test.mjs"
|
|
54
55
|
},
|
|
55
56
|
"dependencies": {
|
|
56
57
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
package/src/tools/deploy.js
CHANGED
|
@@ -1398,6 +1398,9 @@ export async function runPlug(ctx, input, deps = {}) {
|
|
|
1398
1398
|
ctx.state.lastDrop = {
|
|
1399
1399
|
entity_id: data.entity_id ?? null,
|
|
1400
1400
|
url: url ?? null,
|
|
1401
|
+
// Kind lets grid_set_sharing route to the right visibility surface
|
|
1402
|
+
// (inspirations vs runtime entities) without a re-detect round-trip.
|
|
1403
|
+
kind: data.detection?.kind ?? data.kind ?? null,
|
|
1401
1404
|
owner_token: useAnonWire ? (freshOwnerToken ?? ownerToken ?? null) : null,
|
|
1402
1405
|
};
|
|
1403
1406
|
}
|
|
@@ -1619,10 +1622,11 @@ export async function runDownload(ctx, { id, version }) {
|
|
|
1619
1622
|
};
|
|
1620
1623
|
}
|
|
1621
1624
|
|
|
1622
|
-
// Change an
|
|
1623
|
-
// edition where the CLI-wrapping share tool is
|
|
1624
|
-
//
|
|
1625
|
-
|
|
1625
|
+
// Change an entity's visibility — inspiration OR runtime app/agent. Authed,
|
|
1626
|
+
// direct API — works on the hosted edition where the CLI-wrapping share tool is
|
|
1627
|
+
// unavailable. Kind-aware routing (see below). Defaults to the drop made in this
|
|
1628
|
+
// session, so "make it private" needs no ids.
|
|
1629
|
+
export async function runVisibility(ctx, { target, visibility, kind, org }) {
|
|
1626
1630
|
const token = await ctx.getToken();
|
|
1627
1631
|
if (!token) {
|
|
1628
1632
|
throw new Error("Changing visibility needs an owner. Run grid_login first.");
|
|
@@ -1638,33 +1642,86 @@ export async function runVisibility(ctx, { target, visibility, org }) {
|
|
|
1638
1642
|
headers["X-CloudGrid-Grid"] = orgSlug;
|
|
1639
1643
|
headers["X-CloudGrid-Org"] = orgSlug;
|
|
1640
1644
|
}
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1645
|
+
|
|
1646
|
+
// Two visibility surfaces with two vocabularies:
|
|
1647
|
+
// - inspirations: PATCH /api/v2/inspirations/:id { private|space|authenticated|org|link }
|
|
1648
|
+
// - runtimes: PATCH /api/v2/entities/:id/visibility { private|authenticated|grid|link }
|
|
1649
|
+
// Whole-grid visibility is the legacy `org` on inspirations and the canonical
|
|
1650
|
+
// `grid` on runtimes. Normalize the caller's value to `grid`, then map per
|
|
1651
|
+
// route. `space` exists only on inspirations.
|
|
1652
|
+
const vis = visibility === "org" ? "grid" : visibility;
|
|
1653
|
+
const runtimeValue = vis; // private | authenticated | grid | link
|
|
1654
|
+
const inspirationValue = vis === "grid" ? "org" : vis; // private | space | authenticated | org | link
|
|
1655
|
+
|
|
1656
|
+
const k = kind || ctx.state.lastDrop?.kind || null;
|
|
1657
|
+
const isRuntimeKind = k === "app" || k === "agent";
|
|
1658
|
+
|
|
1659
|
+
if (vis === "space" && isRuntimeKind) {
|
|
1660
|
+
throw new Error(
|
|
1661
|
+
"'space' visibility isn't available for runtime apps/agents. Use grid, authenticated, private, or link.",
|
|
1662
|
+
);
|
|
1658
1663
|
}
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1664
|
+
|
|
1665
|
+
const patch = async (pathName, value) => {
|
|
1666
|
+
let res;
|
|
1667
|
+
try {
|
|
1668
|
+
res = await fetch(`${API_BASE}${pathName}`, {
|
|
1669
|
+
method: "PATCH",
|
|
1670
|
+
headers,
|
|
1671
|
+
body: JSON.stringify({ visibility: value }),
|
|
1672
|
+
});
|
|
1673
|
+
} catch (err) {
|
|
1674
|
+
throw new Error(`Could not reach CloudGrid at ${API_BASE}: ${err.message}`);
|
|
1675
|
+
}
|
|
1676
|
+
const raw = await res.text();
|
|
1677
|
+
let data = null;
|
|
1678
|
+
try { data = JSON.parse(raw); } catch { /* handled by caller */ }
|
|
1679
|
+
return { res, data, raw };
|
|
1667
1680
|
};
|
|
1681
|
+
|
|
1682
|
+
const runtimePath = `/api/v2/entities/${encodeURIComponent(id)}/visibility`;
|
|
1683
|
+
const inspirationPath = `/api/v2/inspirations/${encodeURIComponent(id)}`;
|
|
1684
|
+
|
|
1685
|
+
// Route order. `space` is inspiration-only; a known runtime kind goes straight
|
|
1686
|
+
// to the entities route; a known inspiration goes straight to the inspiration
|
|
1687
|
+
// route; an unknown kind tries the runtime route first and falls back to the
|
|
1688
|
+
// inspiration route on a not-found (mirrors runFork).
|
|
1689
|
+
let order;
|
|
1690
|
+
if (vis === "space") order = ["inspiration"];
|
|
1691
|
+
else if (isRuntimeKind) order = ["runtime"];
|
|
1692
|
+
else if (k === "inspiration") order = ["inspiration"];
|
|
1693
|
+
else order = ["runtime", "inspiration"];
|
|
1694
|
+
|
|
1695
|
+
let last;
|
|
1696
|
+
for (let i = 0; i < order.length; i++) {
|
|
1697
|
+
const route = order[i];
|
|
1698
|
+
last = route === "runtime"
|
|
1699
|
+
? await patch(runtimePath, runtimeValue)
|
|
1700
|
+
: await patch(inspirationPath, inspirationValue);
|
|
1701
|
+
if (last.res.ok) {
|
|
1702
|
+
const lines = [`Visibility is now ${vis}.`];
|
|
1703
|
+
if (last.data?.url) lines.push(last.data.url);
|
|
1704
|
+
return {
|
|
1705
|
+
text: lines.join("\n"),
|
|
1706
|
+
structured: {
|
|
1707
|
+
visibility: vis,
|
|
1708
|
+
...(last.data?.url ? { url: last.data.url } : {}),
|
|
1709
|
+
},
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1712
|
+
// Fall back runtime→inspiration only when the id isn't a runtime entity
|
|
1713
|
+
// (a genuine 4xx like NOT_OWNER must surface, not silently re-route).
|
|
1714
|
+
const code = last.data?.error?.code;
|
|
1715
|
+
const canFallback =
|
|
1716
|
+
route === "runtime" &&
|
|
1717
|
+
i < order.length - 1 &&
|
|
1718
|
+
(last.res.status === 404 || code === "NOT_FOUND" || code === "NOT_A_RUNTIME");
|
|
1719
|
+
if (!canFallback) break;
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
const msg = last?.data?.error?.message || last?.raw || `HTTP ${last?.res?.status}`;
|
|
1723
|
+
const hint = last?.data?.error?.details?.[0]?.hint;
|
|
1724
|
+
throw new Error(`Visibility change failed (HTTP ${last?.res?.status}): ${msg}${hint ? ` ${hint}` : ""}`);
|
|
1668
1725
|
}
|
|
1669
1726
|
|
|
1670
1727
|
// Max HTML we'll return inline from runSource. Past this, we return the first
|
package/src/tools/register.js
CHANGED
|
@@ -620,10 +620,11 @@ export function registerTools(server, ctx) {
|
|
|
620
620
|
reg(
|
|
621
621
|
"grid_set_sharing",
|
|
622
622
|
{
|
|
623
|
-
description: "Change who can see a CloudGrid inspiration: private,
|
|
623
|
+
description: "Change who can see a CloudGrid inspiration OR runtime app/agent: private, authenticated, grid (everyone in the grid), or link (anyone with the URL). `space` is inspiration-only. Use when the user wants to make something private, restrict who sees it, or open it up — including right after a drop, with no target id needed. Kind-aware: routes runtime apps/agents to the entities visibility surface and inspirations to the inspiration surface automatically. Defaults to the drop made in this session. Requires sign-in. Calls the API directly.",
|
|
624
624
|
inputSchema: {
|
|
625
|
-
visibility: z.enum(["private", "space", "authenticated", "org", "link"]).describe("The new scope."),
|
|
625
|
+
visibility: z.enum(["private", "space", "authenticated", "grid", "org", "link"]).describe("The new scope. Use `grid` for whole-grid visibility (`org` is the deprecated alias). `space` is inspiration-only."),
|
|
626
626
|
target: z.string().optional().describe("Entity id. Defaults to this session's last drop."),
|
|
627
|
+
kind: z.enum(["inspiration", "app", "agent"]).optional().describe("Entity kind. Omit to auto-detect from this session's last drop (falls back to trying the runtime surface, then the inspiration surface)."),
|
|
627
628
|
org: z.string().optional().describe("Grid of the entity. Defaults to the active grid."),
|
|
628
629
|
},
|
|
629
630
|
outputSchema: {
|