@cloudgrid-io/mcp 0.2.6 → 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.6",
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
@@ -277,6 +277,45 @@ async function runClaim(ctx, { claim_token, claim_url }) {
277
277
  return lines.join("\n");
278
278
  }
279
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
+
280
319
  // ── Registration ───────────────────────────────────────────────────────────────
281
320
  // Registers the tools onto `server`. ctx.edition decides whether the CLI-wrapping
282
321
  // tools are included (they need a local machine).
@@ -376,6 +415,23 @@ export function registerTools(server, ctx) {
376
415
  },
377
416
  );
378
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
+
379
435
  if (ctx.edition !== "local") return; // web edition stops here — no CLI tools
380
436
 
381
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.6" });
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);