@cloudgrid-io/mcp 0.2.5 → 0.2.7

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 CHANGED
@@ -6,8 +6,8 @@ It ships in two editions from one codebase:
6
6
 
7
7
  - **Local (stdio)** — runs on your machine, full toolset including the CLI-wrapping
8
8
  tools. This README covers it. For Claude Code, Cursor, Claude Desktop.
9
- - **Web (hosted HTTP)** — a light, CLI-free toolset (drop, claim, login) for
10
- web clients like claude.ai. See [REMOTE.md](REMOTE.md).
9
+ - **Web (hosted HTTP)** — a light, CLI-free toolset (drop, claim, login,
10
+ visibility) for web clients like claude.ai. See [REMOTE.md](REMOTE.md).
11
11
 
12
12
  The local edition wraps the `cloudgrid` CLI for authenticated operations (the CLI
13
13
  handles auth, org context, and error formatting) and calls the API directly for the
@@ -49,6 +49,7 @@ It speaks MCP over stdio. Point any MCP client at the `cloudgrid-mcp` command.
49
49
  | `cloudgrid_claim` | `POST /api/v2/anon-claim` | Claim an anonymous drop into the signed-in account. Direct API. |
50
50
  | `cloudgrid_login` | `GET /auth/login` | Start a CLI-free sign-in; returns a URL to open. Calls the API directly. |
51
51
  | `cloudgrid_login_status` | `GET /auth/status` | Finish the sign-in; saves the token to the shared CLI credentials. |
52
+ | `cloudgrid_visibility` | `PATCH /api/v2/inspirations/<id>` | Change who can see a drop (private, space, authenticated, org, link). Needs sign-in. Direct API; also in the web edition. |
52
53
  | `cloudgrid_init` | `cloudgrid init` | Register an app or agent; optionally seed a web service. |
53
54
  | `cloudgrid_plug` | `cloudgrid plug` | Deploy a directory or URL. |
54
55
  | `cloudgrid_logs` | `cloudgrid logs` | Snapshot of recent logs. Does not stream. |
@@ -56,11 +57,15 @@ It speaks MCP over stdio. Point any MCP client at the `cloudgrid-mcp` command.
56
57
  | `cloudgrid_feedback` | `cloudgrid feedback list` | Read the org feedback feed. |
57
58
  | `cloudgrid_brain` | `cloudgrid brain refresh` | Re-run the Grid Brain hooks. |
58
59
 
59
- `cloudgrid_drop` and the two `cloudgrid_login` tools are the ones that do not wrap
60
- the CLI both are about working without it. The anonymous drop has no identity to
61
- manage; login exists to get an identity without the CLI. Both call the API directly.
62
- `cloudgrid_login` writes the same `~/.cloudgrid/credentials` the CLI uses, so the two
63
- share one identity.
60
+ `cloudgrid_drop`, `cloudgrid_claim`, `cloudgrid_visibility`, and the two
61
+ `cloudgrid_login` tools do not wrap the CLI they call the API directly, so they
62
+ also work in the web edition where no CLI exists. `cloudgrid_login` writes the same
63
+ `~/.cloudgrid/credentials` the CLI uses, so the two share one identity.
64
+
65
+ `cloudgrid_share` and `cloudgrid_visibility` overlap on purpose: `cloudgrid_share`
66
+ wraps the CLI and defaults to `link`; `cloudgrid_visibility` is direct API, takes an
67
+ explicit scope, and defaults its target to the session's last drop — it is the one
68
+ the web edition gets.
64
69
 
65
70
  ## Test
66
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudgrid-io/mcp",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "MCP server for CloudGrid. Two editions: a local stdio server (full toolset) and a hosted web server (light, CLI-free toolset) over MCP Streamable HTTP.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -22,6 +22,7 @@
22
22
  "smoke:web": "node test/smoke-web.mjs",
23
23
  "smoke:redrop": "node test/smoke-redrop.mjs",
24
24
  "smoke:oauth": "node test/smoke-oauth.mjs",
25
+ "lint:cloudbuild": "npx -y yaml-lint cloudbuild.yaml",
25
26
  "test:auth": "node test/auth.test.mjs"
26
27
  },
27
28
  "dependencies": {
package/src/index.js CHANGED
@@ -25,7 +25,7 @@ const ctx = {
25
25
  savedLocationNote: () => `Credentials saved to ${credentialsPath()}.`,
26
26
  };
27
27
 
28
- const server = new McpServer({ name: "cloudgrid-mcp", version: "0.2.2" });
28
+ const server = new McpServer({ name: "cloudgrid-mcp", version: "0.2.7" });
29
29
  registerTools(server, ctx);
30
30
 
31
31
  const transport = new StdioServerTransport();
package/src/tools.js CHANGED
@@ -139,10 +139,12 @@ async function runDrop(ctx, { html, path: filePath, filename, anonymous, org, fr
139
139
 
140
140
  const form = new FormData();
141
141
  // Redrop (anon-redrop spec §6): a re-drop in the same session updates the previous
142
- // drop in place — same URL, new version. `fresh: true` forces a new drop. The
143
- // platform validates ownership and silently falls back to create, so this never
144
- // hard-fails. Field appended before the artifact so streaming parsers see it.
145
- if (isAnonymousCall && fresh !== true && ctx.state.lastDrop?.entity_id) {
142
+ // drop in place — same URL, new version. `fresh: true` forces a new drop. Sent for
143
+ // BOTH anonymous and authed callers: the platform validates ownership and silently
144
+ // falls back to create, so this never hard-fails (authed in-place lands when the
145
+ // platform extends the gate; until then the fallback equals today's behavior).
146
+ // Field appended before the artifact so streaming parsers see it.
147
+ if (fresh !== true && ctx.state.lastDrop?.entity_id) {
146
148
  form.append("previous_id", ctx.state.lastDrop.entity_id);
147
149
  }
148
150
  form.append("artifact", new Blob([bytes], { type }), name);
@@ -177,14 +179,7 @@ async function runDrop(ctx, { html, path: filePath, filename, anonymous, org, fr
177
179
  .find((c) => c.startsWith("cg_anon_session="));
178
180
  if (anonCookie) ctx.state.anonCookie = anonCookie;
179
181
 
180
- if (data.owned_by === "authenticated") {
181
- ctx.state.lastAnonClaim = null;
182
- const lines = [`Published to your org: ${data.url}`, "Owned by you."];
183
- if (data.expires_at) lines.push(`Expires ${data.expires_at}.`);
184
- return lines.join("\n");
185
- }
186
-
187
- // Anonymous: remember the drop for redrop continuity (any 2xx outcome).
182
+ // Remember the drop for redrop continuity — any caller class, any 2xx outcome.
188
183
  if (data.entity_id || data.url) {
189
184
  ctx.state.lastDrop = {
190
185
  entity_id: data.entity_id ?? ctx.state.lastDrop?.entity_id ?? null,
@@ -200,7 +195,16 @@ async function runDrop(ctx, { html, path: filePath, filename, anonymous, org, fr
200
195
  if (res.status === 200) {
201
196
  // Updated in place: same URL, new version, views/reactions intact.
202
197
  const lines = [`Updated in place — same link: ${data.url ?? ctx.state.lastDrop?.url ?? ""}`.trim()];
198
+ if (data.owned_by === "authenticated") lines.push("Owned by you.");
199
+ if (data.expires_at) lines.push(`Expires ${data.expires_at}.`);
200
+ return lines.join("\n");
201
+ }
202
+
203
+ if (data.owned_by === "authenticated") {
204
+ ctx.state.lastAnonClaim = null;
205
+ const lines = [`Published to your org: ${data.url}`, "Owned by you."];
203
206
  if (data.expires_at) lines.push(`Expires ${data.expires_at}.`);
207
+ lines.push("Drop again in this session to update it in place (same link); pass fresh to start a new one.");
204
208
  return lines.join("\n");
205
209
  }
206
210
 
@@ -273,6 +277,45 @@ async function runClaim(ctx, { claim_token, claim_url }) {
273
277
  return lines.join("\n");
274
278
  }
275
279
 
280
+
281
+ // Change an inspiration's visibility. Authed, direct API — works on the hosted
282
+ // edition where the CLI-wrapping share tool is unavailable. Defaults to the drop
283
+ // made in this session, so "make it private" needs no ids.
284
+ async function runVisibility(ctx, { target, visibility, org }) {
285
+ const token = await ctx.getToken();
286
+ if (!token) {
287
+ throw new Error("Changing visibility needs an owner. Run cloudgrid_login first.");
288
+ }
289
+ const id = target || ctx.state.lastDrop?.entity_id;
290
+ if (!id) {
291
+ throw new Error("No target. Pass the entity id, or drop something first in this session.");
292
+ }
293
+ const headers = { Authorization: `Bearer ${token}`, "Content-Type": "application/json" };
294
+ const orgSlug = org || (await ctx.getActiveOrg());
295
+ if (orgSlug) headers["X-CloudGrid-Org"] = orgSlug;
296
+ let res;
297
+ try {
298
+ res = await fetch(`${API_BASE}/api/v2/inspirations/${encodeURIComponent(id)}`, {
299
+ method: "PATCH",
300
+ headers,
301
+ body: JSON.stringify({ visibility }),
302
+ });
303
+ } catch (err) {
304
+ throw new Error(`Could not reach CloudGrid at ${API_BASE}: ${err.message}`);
305
+ }
306
+ const raw = await res.text();
307
+ let data = null;
308
+ try { data = JSON.parse(raw); } catch { /* handled below */ }
309
+ if (!res.ok) {
310
+ const msg = data?.error?.message || raw || `HTTP ${res.status}`;
311
+ const hint = data?.error?.details?.[0]?.hint;
312
+ throw new Error(`Visibility change failed (HTTP ${res.status}): ${msg}${hint ? ` ${hint}` : ""}`);
313
+ }
314
+ const lines = [`Visibility is now ${visibility}.`];
315
+ if (data?.url) lines.push(data.url);
316
+ return lines.join("\n");
317
+ }
318
+
276
319
  // ── Registration ───────────────────────────────────────────────────────────────
277
320
  // Registers the tools onto `server`. ctx.edition decides whether the CLI-wrapping
278
321
  // tools are included (they need a local machine).
@@ -372,6 +415,23 @@ export function registerTools(server, ctx) {
372
415
  },
373
416
  );
374
417
 
418
+ server.tool(
419
+ "cloudgrid_visibility",
420
+ "Change who can see a CloudGrid inspiration: private, space, authenticated, org, or link (anyone with the URL). Use when the user wants to make a drop private, restrict who sees it, or open it up. Defaults to the drop made in this session. Requires sign-in. Calls the API directly.",
421
+ {
422
+ visibility: z.enum(["private", "space", "authenticated", "org", "link"]).describe("The new scope."),
423
+ target: z.string().optional().describe("Entity id. Defaults to this session's last drop."),
424
+ org: z.string().optional().describe("Org of the entity. Defaults to the active org."),
425
+ },
426
+ async (input) => {
427
+ try {
428
+ return ok(await runVisibility(ctx, input || {}));
429
+ } catch (err) {
430
+ return fail(err.message);
431
+ }
432
+ },
433
+ );
434
+
375
435
  if (ctx.edition !== "local") return; // web edition stops here — no CLI tools
376
436
 
377
437
  // ── CLI-wrapping tools (local edition only) ──
package/src/web.js CHANGED
@@ -128,7 +128,7 @@ app.post("/mcp", async (req, res) => {
128
128
  delete sessionAuth[transport.sessionId];
129
129
  }
130
130
  };
131
- const server = new McpServer({ name: "cloudgrid-mcp-web", version: "0.2.5" });
131
+ const server = new McpServer({ name: "cloudgrid-mcp-web", version: "0.2.7" });
132
132
  registerTools(server, makeWebContext(newSessionId));
133
133
  await server.connect(transport);
134
134
  await transport.handleRequest(req, res, req.body);