hushdrop-mcp 0.3.2 → 0.4.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/mcp.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * hushdrop MCP server — the MCP-native publish primitive for HTML/artifacts your agents make.
3
+ * hushdrop MCP server: lets an agent turn the HTML it builds into a shareable (optionally locked) link.
4
4
  *
5
- * Open-source, self-hosted MCP publish primitive: an agent calls `publish_html` and gets
6
- * back a branded, password-protected, zero-knowledge link on YOUR own domain. Every tool
5
+ * Open source and self-hosted. When an agent calls `publish_html`, it receives
6
+ * a branded, password-protected, zero-knowledge link on YOUR own domain. Every tool
7
7
  * shells out to the `drop` CLI (drop.mjs --json) so the MCP and CLI share one pipeline.
8
8
  * Nothing is hosted by a third party — it's your Vercel Blob.
9
9
  *
@@ -30,13 +30,13 @@ const DROP = join(__dirname, "drop.mjs");
30
30
  // Run the drop CLI with --json and return the parsed result.
31
31
  function runDrop(args) {
32
32
  return new Promise((resolve, reject) => {
33
- const p = spawn(process.execPath, [DROP, ...args, "--json"], { stdio: ["ignore", "pipe", "pipe"] });
33
+ const p = spawn(process.execPath, [DROP, ...args, "--json"], { stdio: ["ignore", "pipe", "pipe"], env: { ...process.env, HUSH_CLIENT: "mcp" } });
34
34
  let out = "", err = "";
35
35
  p.stdout.on("data", (d) => (out += d));
36
36
  p.stderr.on("data", (d) => (err += d));
37
37
  p.on("error", reject);
38
38
  p.on("close", (code) => {
39
- if (code !== 0) return reject(new Error(err.trim() || `hush exited ${code}`));
39
+ if (code !== 0) return reject(new Error(err.trim() || out.trim() || `hush exited ${code}`)); // 402 paywall JSON comes on stdout
40
40
  const line = out.trim().split("\n").filter(Boolean).pop() || "{}";
41
41
  try { resolve(JSON.parse(line)); } catch { resolve({ raw: out.trim() }); }
42
42
  });
@@ -56,6 +56,89 @@ const errResult = (e) => ({ isError: true, content: [{ type: "text", text: `Erro
56
56
 
57
57
  const server = new McpServer({ name: "hushdrop", version: "1.0.0" });
58
58
 
59
+ // Tool titles + behavior hints. Directories (Claude connectors, Glama, Cursor) require or score
60
+ // these, and clients use them to decide when to ask before running a tool.
61
+ const W = { readOnlyHint: false, destructiveHint: false, openWorldHint: true };
62
+ const R = { readOnlyHint: true, destructiveHint: false, openWorldHint: false };
63
+ const D = { ...W, destructiveHint: true };
64
+ const I = { idempotentHint: true };
65
+ // Same titles and hints as the remote server (api/_lib/mcp-tools.mjs). Every tool must be here:
66
+ // tests/unit/mcp-annotations.test.mjs fails on a missing one.
67
+ const ANNOTATIONS = {
68
+ publish_html: ["Publish HTML as a locked link", W],
69
+ publish_file: ["Publish a file as a link", W],
70
+ update_site: ["Update a drop in place", { ...D, ...I }],
71
+ list_sites: ["List your drops", R],
72
+ search_drops: ["Search drops", R],
73
+ delete_site: ["Delete a drop", { ...D, ...I }],
74
+ set_password: ["Change a drop's password", { ...D, ...I }],
75
+ set_expiry: ["Set a drop's expiry", { ...D, ...I }],
76
+ set_email_gate: ["Restrict a drop to an email domain", { ...W, ...I }],
77
+ set_feedback: ["Toggle the feedback widget", { ...W, ...I }],
78
+ list_versions: ["List a drop's versions", R],
79
+ rollback_site: ["Roll a drop back", { ...D, ...I }],
80
+ list_editors: ["List a drop's editors", R],
81
+ add_editor: ["Add an editor to a drop", W],
82
+ remove_editor: ["Remove an editor", { ...D, ...I }],
83
+ list_shared_with_me: ["Drops shared with you", R],
84
+ add_domain: ["Connect a custom domain", { ...W, ...I }],
85
+ domain_status: ["Check a custom domain's DNS", { ...R, openWorldHint: true }],
86
+ list_domains: ["List custom domains", R],
87
+ remove_domain: ["Disconnect a custom domain", { ...D, ...I }],
88
+ list_teams: ["List your teams", R],
89
+ create_team: ["Create a team space", W],
90
+ list_team_members: ["List team members", R],
91
+ add_team_member: ["Add a team member", W],
92
+ remove_team_member: ["Remove a team member", { ...D, ...I }],
93
+ delete_team: ["Delete a team", { ...D, ...I }],
94
+ get_team_settings: ["Show a team's login settings", R],
95
+ set_team_domain: ["Set company login for a team", { ...W, ...I }],
96
+ set_team_sso: ["Set up SAML SSO for a team", { ...W, ...I }],
97
+ login: ["Sign in to Hushdrop", W],
98
+ finish_login: ["Finish signing in", W],
99
+ billing_status: ["Show plan and billing", R],
100
+ upgrade_pro: ["Upgrade to Pro", W],
101
+ upgrade_team: ["Upgrade a team", W],
102
+ drop_stats: ["Get a drop's view stats", R],
103
+ list_webhooks: ["List webhooks", R],
104
+ add_webhook: ["Add a webhook", W],
105
+ test_webhook: ["Send a test webhook", W],
106
+ remove_webhook: ["Remove a webhook", { ...D, ...I }],
107
+ get_open_alerts: ["Show open alert settings", R],
108
+ set_open_alerts: ["Set open alerts", { ...W, ...I }],
109
+ lead_capture: ["Configure lead capture", { ...W, ...I }],
110
+ list_leads: ["List captured leads", R],
111
+ list_recipients: ["Show who can open a drop", R],
112
+ set_recipient_lists: ["Set a drop's allow and block lists", { ...D, ...I }],
113
+ create_guest_link: ["Make a named guest link", W],
114
+ invite_recipients: ["Email a drop to people", W],
115
+ revoke_guest_link: ["Revoke a guest link", { ...D, ...I }],
116
+ set_nda: ["Set an NDA gate", { ...W, ...I }],
117
+ data_store: ["Configure a drop's data store", { ...W, ...I }],
118
+ list_data_records: ["Read a drop's saved records", R],
119
+ list_secrets: ["List stored API keys", R],
120
+ set_secret: ["Store an API key for a page", { ...D, ...I }],
121
+ remove_secret: ["Remove a stored API key", { ...D, ...I }],
122
+ list_portals: ["List client portals", R],
123
+ create_portal: ["Create a client portal", W],
124
+ add_to_portal: ["Add a drop to a portal", { ...W, ...I }],
125
+ remove_from_portal: ["Remove a drop from a portal", { ...D, ...I }],
126
+ delete_portal: ["Delete a client portal", { ...D, ...I }],
127
+ set_view_only: ["Turn view-only mode on or off", { ...W, ...I }],
128
+ drop_comments: ["Read viewer comments", R],
129
+ resolve_comments: ["Resolve viewer comments", { ...W, ...I }],
130
+ set_analytics_tag: ["Add your own analytics", { ...W, ...I }],
131
+ get_template: ["Get a starter template", R],
132
+ page_rules: ["Read the page-writing rules", R],
133
+ };
134
+ const registerTool = server.tool.bind(server);
135
+ server.tool = (name, ...rest) => {
136
+ const t = registerTool(name, ...rest);
137
+ const a = ANNOTATIONS[name];
138
+ if (a) t.update({ title: a[0], annotations: { title: a[0], ...a[1] } });
139
+ return t;
140
+ };
141
+
59
142
  server.tool(
60
143
  "publish_html",
61
144
  "Publish raw HTML as a branded, password-protected (zero-knowledge AES-256) link on your own domain. Returns the URL and (if locked) the password. Locked by default.",
@@ -65,11 +148,13 @@ server.tool(
65
148
  password: z.string().optional().describe("Set a specific password. Otherwise an unguessable one is generated when locked."),
66
149
  lock: z.boolean().optional().describe("Encrypt + password-protect (default true). Set false for a public branded page."),
67
150
  expire: z.string().optional().describe("Auto-expire after this long: '7d', '24h', '2w', or a date. Enforce deletion with the host's `hush gc` cron."),
151
+ to: z.string().optional().describe("Where to publish instead of your personal space: a team handle ('acme') you're on, or '<owner>/<slug>' for a drop someone made you an editor of. See list_teams / list_shared_with_me."),
68
152
  },
69
- async ({ html, slug, password, lock, expire }) => {
153
+ async ({ html, slug, password, lock, expire, to }) => {
70
154
  try {
71
155
  const args = [];
72
156
  if (slug) args.push("-s", slug);
157
+ if (to) args.push("--to", to);
73
158
  if (lock === false) args.push("--no-lock");
74
159
  else if (password) args.push("-p", password);
75
160
  if (expire) args.push("--expire", expire);
@@ -101,17 +186,19 @@ server.tool(
101
186
 
102
187
  server.tool(
103
188
  "update_site",
104
- "Replace the content of an existing drop in place — same URL/slug, new HTML. (Set a password to re-lock; zero-knowledge means content can't be re-keyed without re-supplying it.)",
189
+ "Swap in new HTML for a drop you already published — same URL/slug, new HTML. On the hosted tier every update is kept as a new version, so it can be undone with rollback_site. (Set a password to re-lock; zero-knowledge means content can't be re-keyed without re-supplying it.)",
105
190
  {
106
191
  slug: z.string().describe("The slug to overwrite."),
107
192
  html: z.string().describe("The new HTML document."),
108
193
  password: z.string().optional(),
109
194
  lock: z.boolean().optional(),
110
195
  expire: z.string().optional().describe("Auto-expire: '7d', '24h', '2w', or a date."),
196
+ to: z.string().optional().describe("Where to publish instead of your personal space: a team handle ('acme') you're on, or '<owner>/<slug>' for a drop someone made you an editor of. See list_teams / list_shared_with_me."),
111
197
  },
112
- async ({ slug, html, password, lock, expire }) => {
198
+ async ({ slug, html, password, lock, expire, to }) => {
113
199
  try {
114
200
  const args = ["-s", slug];
201
+ if (to) args.push("--to", to);
115
202
  if (lock === false) args.push("--no-lock");
116
203
  else if (password) args.push("-p", password);
117
204
  if (expire) args.push("--expire", expire);
@@ -188,5 +275,599 @@ server.tool(
188
275
  }
189
276
  );
190
277
 
278
+ // ---------- versions, editors, team (hosted tier, after `hush login`) ----------
279
+ const space = z.string().optional().describe("The owner's handle, when acting on a drop someone shared with you.");
280
+
281
+ server.tool(
282
+ "list_versions",
283
+ "List a hosted drop's version history (newest first): version number, when, size, who published it, and which one is live. Use before rollback_site.",
284
+ { slug: z.string().describe("The drop's slug."), space },
285
+ async ({ slug, space }) => {
286
+ try { return textResult(await runDrop(["versions", slug, ...(space ? ["--to", space] : [])])); }
287
+ catch (e) { return errResult(e); }
288
+ }
289
+ );
290
+
291
+ server.tool(
292
+ "rollback_site",
293
+ "Make an earlier version of a hosted drop live again, on the same URL. Use when an update broke the page. Get version numbers from list_versions. pin=true keeps that version live even when new versions are published (e.g. the client approved v3 while you keep iterating); unpin=true (no version needed) puts the latest version back live.",
294
+ { slug: z.string(), version: z.number().int().optional().describe("The version number to restore."), pin: z.boolean().optional(), unpin: z.boolean().optional(), space },
295
+ async ({ slug, version, pin, unpin, space }) => {
296
+ try {
297
+ if (unpin) return textResult(await runDrop(["versions", slug, "--unpin", ...(space ? ["--to", space] : [])]));
298
+ return textResult(await runDrop(["rollback", slug, String(version), ...(pin ? ["--pin"] : []), ...(space ? ["--to", space] : [])]));
299
+ } catch (e) { return errResult(e); }
300
+ }
301
+ );
302
+
303
+ server.tool(
304
+ "list_editors",
305
+ "Show who can update a hosted drop (its editors).",
306
+ { slug: z.string(), space },
307
+ async ({ slug, space }) => {
308
+ try { return textResult(await runDrop(["editors", slug, ...(space ? ["--to", space] : [])])); }
309
+ catch (e) { return errResult(e); }
310
+ }
311
+ );
312
+
313
+ server.tool(
314
+ "add_editor",
315
+ "Let another Hushdrop user update one of your hosted drops (publish new versions and roll back). Nothing else in your space is shared. They must have run `hush login` once; they then update it with publish_html/update_site using to='<you>/<slug>'.",
316
+ { slug: z.string().describe("Your drop's slug."), handle: z.string().describe("Their Hushdrop handle, e.g. '@krista'.") },
317
+ async ({ slug, handle }) => {
318
+ try { return textResult(await runDrop(["editors", "add", slug, handle])); }
319
+ catch (e) { return errResult(e); }
320
+ }
321
+ );
322
+
323
+ server.tool(
324
+ "remove_editor",
325
+ "Revoke someone's ability to update one of your drops (or stop editing someone else's: pass your own handle and space=<owner>).",
326
+ { slug: z.string(), handle: z.string(), space },
327
+ async ({ slug, handle, space }) => {
328
+ try { return textResult(await runDrop(["editors", "rm", slug, handle, ...(space ? ["--to", space] : [])])); }
329
+ catch (e) { return errResult(e); }
330
+ }
331
+ );
332
+
333
+ // ---------- hosted custom domains (Pro/Team) ----------
334
+ server.tool(
335
+ "add_domain",
336
+ "Serve hosted drops on the user's own domain (Pro/Team). Without slug, share.acme.com/<slug> serves every drop in the space; with slug, that one drop is served at the domain's root. Returns the DNS records the user must add (CNAME for a subdomain, A for an apex, plus a TXT if Vercel asks for ownership proof). HTTPS is automatic. Tell the user the exact records, then check with domain_status.",
337
+ { domain: z.string().describe("e.g. 'share.acme.com'"), slug: z.string().optional().describe("Map the domain to just this drop."), space: z.string().optional().describe("Team handle, to connect it to a team space.") },
338
+ async ({ domain, slug, space }) => {
339
+ try { return textResult(await runDrop(["domains", "add", domain, ...(slug ? [slug] : []), ...(space ? ["--to", space] : [])])); }
340
+ catch (e) { return errResult(e); }
341
+ }
342
+ );
343
+
344
+ server.tool(
345
+ "domain_status",
346
+ "Re-check a custom domain: whether DNS points at Hushdrop, whether ownership is verified, and which records are still missing. live=true means it's serving over HTTPS.",
347
+ { domain: z.string() },
348
+ async ({ domain }) => {
349
+ try { return textResult(await runDrop(["domains", "status", domain])); }
350
+ catch (e) { return errResult(e); }
351
+ }
352
+ );
353
+
354
+ server.tool(
355
+ "list_domains",
356
+ "List the custom domains connected to a space (personal by default) and what each one serves.",
357
+ { space: z.string().optional() },
358
+ async ({ space }) => {
359
+ try { return textResult(await runDrop(["domains", ...(space ? ["--to", space] : [])])); }
360
+ catch (e) { return errResult(e); }
361
+ }
362
+ );
363
+
364
+ server.tool(
365
+ "remove_domain",
366
+ "Disconnect a custom domain. Drops stay live on hushdrop.dev.",
367
+ { domain: z.string() },
368
+ async ({ domain }) => {
369
+ try { return textResult(await runDrop(["domains", "rm", domain])); }
370
+ catch (e) { return errResult(e); }
371
+ }
372
+ );
373
+
374
+ server.tool(
375
+ "list_shared_with_me",
376
+ "List drops other people have made you an editor of, with the `to` value to pass when updating each.",
377
+ {},
378
+ async () => {
379
+ try { return textResult(await runDrop(["shared"])); }
380
+ catch (e) { return errResult(e); }
381
+ }
382
+ );
383
+
384
+ server.tool(
385
+ "list_teams",
386
+ "List the spaces you can publish to: your personal handle and every team you're on (with your role). Pass a team's handle as `to` when publishing. Team-plan spaces include subdomain_url (acme.hushdrop.dev): links to their drops can use it.",
387
+ {},
388
+ async () => {
389
+ try { return textResult(await runDrop(["team", "ls"])); }
390
+ catch (e) { return errResult(e); }
391
+ }
392
+ );
393
+
394
+ server.tool(
395
+ "create_team",
396
+ "Create a team space with its own handle (hushdrop.dev/<handle>/...), like a shared account. You become its owner.",
397
+ { handle: z.string().describe("Team handle, e.g. 'acme'."), name: z.string().optional().describe("Display name.") },
398
+ async ({ handle, name }) => {
399
+ try { return textResult(await runDrop(["team", "create", handle, ...(name ? ["--title", name] : [])])); }
400
+ catch (e) { return errResult(e); }
401
+ }
402
+ );
403
+
404
+ server.tool(
405
+ "login",
406
+ "Sign the user in to Hushdrop (free account) without leaving the agent. Returns verify_url: show it to the user to open and approve, then call finish_login. A free account keeps drops at hushdrop.dev/<handle>/... instead of expiring in 24h, with version history, rollback and per-drop editors; teams are on the Team plan.",
407
+ { provider: z.enum(["google", "microsoft", "sso"]).optional().describe("Sign in with a Google or Microsoft work account, or 'sso' for the company's SAML sign-in (joins the company's team). Omit for GitHub or email link.") },
408
+ async ({ provider }) => {
409
+ try { return textResult(await runDrop(["login", "--start", ...(provider ? ["--with", provider] : [])])); }
410
+ catch (e) { return errResult(e); }
411
+ }
412
+ );
413
+
414
+ server.tool(
415
+ "finish_login",
416
+ "Finish a login started with the login tool: waits up to ~90s for the user to approve in the browser, then saves the key. If it returns status: pending, ask the user whether they've approved and call it again.",
417
+ {},
418
+ async () => {
419
+ try { return textResult(await runDrop(["login", "--finish"])); }
420
+ catch (e) { return errResult(e); }
421
+ }
422
+ );
423
+
424
+ server.tool(
425
+ "get_team_settings",
426
+ "Show a team's company email domain, the role new members get, and its SAML SSO setup.",
427
+ { team: z.string() },
428
+ async ({ team }) => {
429
+ try { return textResult([await runDrop(["team", "domain", team]), await runDrop(["team", "sso", team])].join("\n")); }
430
+ catch (e) { return errResult(e); }
431
+ }
432
+ );
433
+
434
+ server.tool(
435
+ "set_team_domain",
436
+ "Company login for a team (Team plan, owners only): anyone who signs in with a verified address on this email domain (Google, Microsoft or email link) joins the team automatically. The owner must be signed in with a verified address on that domain. domain='off' stops it. get_team_settings reads the current setting.",
437
+ { team: z.string(), domain: z.string(), role: z.enum(["editor", "admin"]).optional() },
438
+ async ({ team, domain, role }) => {
439
+ try { return textResult(await runDrop(["team", "domain", team, domain, ...(role ? ["--role", role] : [])])); }
440
+ catch (e) { return errResult(e); }
441
+ }
442
+ );
443
+
444
+ server.tool(
445
+ "set_team_sso",
446
+ "SAML SSO for a team (Team add-on, owners only; the company domain must be set first with set_team_domain). Pass the identity provider's SAML metadata URL; returns the ACS URL and Entity ID to paste into the IdP, plus a sign-in link for members. off=true removes it. get_team_settings reads the current setup.",
447
+ { team: z.string(), metadata_url: z.string().optional(), off: z.boolean().optional() },
448
+ async ({ team, metadata_url, off }) => {
449
+ try {
450
+ if (!off && !metadata_url) throw new Error("pass metadata_url, or off=true to remove SSO (get_team_settings reads the current setup)");
451
+ return textResult(await runDrop(["team", "sso", team, ...(off ? ["off"] : ["--metadata-url", metadata_url])]));
452
+ } catch (e) { return errResult(e); }
453
+ }
454
+ );
455
+
456
+ server.tool(
457
+ "upgrade_team",
458
+ "Upgrade a team space to Team ($29/mo flat, unlimited members). While checkout isn't live, this starts a 14-day free trial right away (no card), once per team. If a tool returned a 402 with paywall.then.add, pass that handle as `add` and the teammate is added once the trial starts. If the result has a `url`, give it to the user to open (Stripe checkout). Only team owners can upgrade; others get recorded as a request to the owners.",
459
+ { team: z.string().describe("Team handle, e.g. 'acme'."), add: z.string().optional().describe("Teammate to add once upgraded, e.g. '@ana'.") },
460
+ async ({ team, add }) => {
461
+ try { return textResult(await runDrop(["team", "upgrade", team, ...(add ? ["--add", add] : [])])); }
462
+ catch (e) { return errResult(e); }
463
+ }
464
+ );
465
+
466
+ server.tool(
467
+ "upgrade_pro",
468
+ "Upgrade the user's personal space to Pro ($9/mo). If the result has a `url`, give it to the user to open (checkout).",
469
+ {},
470
+ async () => {
471
+ try { return textResult(await runDrop(["upgrade"])); }
472
+ catch (e) { return errResult(e); }
473
+ }
474
+ );
475
+
476
+ server.tool(
477
+ "billing_status",
478
+ "Show the plan, status (trialing/active/past_due) and renewal date of the personal space or a team. When it's paid, also returns a Stripe billing-portal URL (change card, invoices, cancel).",
479
+ { team: z.string().optional().describe("Team handle; omit for the personal space.") },
480
+ async ({ team }) => {
481
+ try { return textResult(await runDrop(["billing", ...(team ? [team] : [])])); }
482
+ catch (e) { return errResult(e); }
483
+ }
484
+ );
485
+
486
+ server.tool(
487
+ "delete_team",
488
+ "Delete a team space and every drop in it. Owners only, and it can't be undone: confirm with the user first, then pass the team handle again as `confirm`.",
489
+ { team: z.string().describe("Team handle."), confirm: z.string().describe("The same team handle, typed again to confirm.") },
490
+ async ({ team, confirm }) => {
491
+ if (String(confirm).replace(/^@/, "") !== String(team).replace(/^@/, "")) return errResult(new Error("confirm must repeat the team handle"));
492
+ try { return textResult(await runDrop(["team", "delete", team, "--yes"])); }
493
+ catch (e) { return errResult(e); }
494
+ }
495
+ );
496
+
497
+ server.tool(
498
+ "list_team_members",
499
+ "Show a team's members and their roles.",
500
+ { team: z.string().describe("Team handle.") },
501
+ async ({ team }) => {
502
+ try { return textResult(await runDrop(["team", "members", team])); }
503
+ catch (e) { return errResult(e); }
504
+ }
505
+ );
506
+
507
+ server.tool(
508
+ "add_team_member",
509
+ "Add someone to a team (or change their role). editor = publish incl. new drops + rollback; admin = also delete drops, change settings, manage editors; owner = everything. They must have run `hush login` once.",
510
+ { team: z.string(), handle: z.string().describe("Their Hushdrop handle, e.g. '@ana'."), role: z.enum(["editor", "admin", "owner"]).optional() },
511
+ async ({ team, handle, role }) => {
512
+ try { return textResult(await runDrop(["team", "add", team, handle, ...(role ? ["--role", role] : [])])); }
513
+ catch (e) { return errResult(e); }
514
+ }
515
+ );
516
+
517
+ server.tool(
518
+ "remove_team_member",
519
+ "Remove someone from a team.",
520
+ { team: z.string(), handle: z.string() },
521
+ async ({ team, handle }) => {
522
+ try { return textResult(await runDrop(["team", "rm", team, handle])); }
523
+ catch (e) { return errResult(e); }
524
+ }
525
+ );
526
+
527
+ server.tool(
528
+ "drop_stats",
529
+ "Has my drop been opened yet? Returns views, unique viewers, first/last opened and daily views for a hosted drop (Pro adds referrers, countries, live viewers, recent views). Omit slug for a summary of every hosted drop.",
530
+ { slug: z.string().optional().describe("The drop's slug. Omit to list all hosted drops with their open status.") },
531
+ async ({ slug }) => {
532
+ try { return textResult(await runDrop(slug ? ["stats", slug] : ["stats"])); }
533
+ catch (e) { return errResult(e); }
534
+ }
535
+ );
536
+
537
+ server.tool(
538
+ "list_webhooks",
539
+ "List the account's signed webhooks: id, URL, events and drop.",
540
+ {},
541
+ async () => {
542
+ try { return textResult(await runDrop(["webhook", "list"])); }
543
+ catch (e) { return errResult(e); }
544
+ }
545
+ );
546
+
547
+ server.tool(
548
+ "add_webhook",
549
+ "Add a signed webhook (Pro) that POSTs to an https URL when a hosted drop is first opened, viewed, a lead is captured, data is submitted or a comment is added. Omit slug for every drop. The signing secret is returned once.",
550
+ { url: z.string(), slug: z.string().optional(), events: z.array(z.enum(["drop.viewed", "drop.first_opened", "lead.captured", "data.submitted", "comment.added"])).optional() },
551
+ async ({ url, slug, events }) => {
552
+ try { const a = ["webhook", "add", url]; if (slug) a.push("--slug", slug); if (events?.length) a.push("--events", events.join(",")); return textResult(await runDrop(a)); }
553
+ catch (e) { return errResult(e); }
554
+ }
555
+ );
556
+
557
+ server.tool(
558
+ "test_webhook",
559
+ "Send one signed test event to a webhook's URL.",
560
+ { id: z.string() },
561
+ async ({ id }) => {
562
+ try { return textResult(await runDrop(["webhook", "test", id])); }
563
+ catch (e) { return errResult(e); }
564
+ }
565
+ );
566
+
567
+ server.tool(
568
+ "remove_webhook",
569
+ "Delete a webhook by id.",
570
+ { id: z.string() },
571
+ async ({ id }) => {
572
+ try { return textResult(await runDrop(["webhook", "rm", id])); }
573
+ catch (e) { return errResult(e); }
574
+ }
575
+ );
576
+
577
+ server.tool(
578
+ "get_open_alerts",
579
+ "Show when the owner gets an email about a hosted drop being opened, for the account or one drop.",
580
+ { slug: z.string().optional() },
581
+ async ({ slug }) => {
582
+ try { const a = ["alerts"]; if (slug) a.push("--slug", slug); return textResult(await runDrop(a)); }
583
+ catch (e) { return errResult(e); }
584
+ }
585
+ );
586
+
587
+ server.tool(
588
+ "set_open_alerts",
589
+ "Email the owner when a hosted drop is opened. mode: off | first (first open, free) | every (each new viewer, Pro) | default (per-drop only: follow the account setting). Pass slug for one drop, omit for the account default.",
590
+ { mode: z.enum(["off", "first", "every", "default"]), slug: z.string().optional() },
591
+ async ({ mode, slug }) => {
592
+ try { const a = ["alerts", mode]; if (slug) a.push("--slug", slug); return textResult(await runDrop(a)); }
593
+ catch (e) { return errResult(e); }
594
+ }
595
+ );
596
+
597
+ server.tool(
598
+ "lead_capture",
599
+ "Require viewers of a hosted drop to enter their email before it opens (free), optionally with custom fields like name/company/phone (Pro). enabled=false turns it off.",
600
+ { slug: z.string(), enabled: z.boolean().optional(), fields: z.array(z.string()).optional().describe("Extra required fields, e.g. ['name','company'] (Pro).") },
601
+ async ({ slug, enabled, fields }) => {
602
+ try { const a = ["leads", slug, enabled === false ? "off" : "on"]; if (fields) a.push("--fields", fields.join(",")); return textResult(await runDrop(a)); }
603
+ catch (e) { return errResult(e); }
604
+ }
605
+ );
606
+
607
+ server.tool(
608
+ "list_leads",
609
+ "List the people who entered their email to open a hosted drop (email, custom fields, verified, country, time).",
610
+ { slug: z.string() },
611
+ async ({ slug }) => {
612
+ try { return textResult(await runDrop(["leads", slug])); }
613
+ catch (e) { return errResult(e); }
614
+ }
615
+ );
616
+
617
+ server.tool(
618
+ "list_recipients",
619
+ "Show who can open a hosted drop: allow and block lists, plus named guest links with their open counts.",
620
+ { slug: z.string() },
621
+ async ({ slug }) => {
622
+ try { return textResult(await runDrop(["recipients", slug])); }
623
+ catch (e) { return errResult(e); }
624
+ }
625
+ );
626
+
627
+ server.tool(
628
+ "set_recipient_lists",
629
+ "Replace who may open a hosted drop (Pro): allow and block take emails or @domains. An empty list clears it.",
630
+ { slug: z.string(), allow: z.array(z.string()).optional(), block: z.array(z.string()).optional() },
631
+ async ({ slug, allow, block }) => {
632
+ try {
633
+ if (!allow && !block) throw new Error("pass allow, block or both (list_recipients reads them)");
634
+ const a = ["recipients", slug];
635
+ if (allow) a.push("--allow", allow.length ? allow.join(",") : "off");
636
+ if (block) a.push("--block", block.length ? block.join(",") : "off");
637
+ return textResult(await runDrop(a));
638
+ } catch (e) { return errResult(e); }
639
+ }
640
+ );
641
+
642
+ server.tool(
643
+ "create_guest_link",
644
+ "Make a named guest link for one recipient so their opens are counted separately (Pro).",
645
+ { slug: z.string(), name: z.string().describe("Who the link is for, e.g. 'Ann at Acme'.") },
646
+ async ({ slug, name }) => {
647
+ try { return textResult(await runDrop(["recipients", slug, "--link", name])); }
648
+ catch (e) { return errResult(e); }
649
+ }
650
+ );
651
+
652
+ server.tool(
653
+ "invite_recipients",
654
+ "Email people a hosted drop's link. They are added to the allow list and confirm their address with a one-time code.",
655
+ { slug: z.string(), emails: z.array(z.string()).min(1), message: z.string().optional().describe("Optional note included in the invite email.") },
656
+ async ({ slug, emails, message }) => {
657
+ try { const a = ["recipients", slug, "--invite", emails.join(",")]; if (message) a.push("--note", message); return textResult(await runDrop(a)); }
658
+ catch (e) { return errResult(e); }
659
+ }
660
+ );
661
+
662
+ server.tool(
663
+ "revoke_guest_link",
664
+ "Revoke one guest link by its token. Other links to the drop keep working.",
665
+ { token: z.string() },
666
+ async ({ token }) => {
667
+ try { return textResult(await runDrop(["recipients", "--revoke-link", token])); }
668
+ catch (e) { return errResult(e); }
669
+ }
670
+ );
671
+
672
+ server.tool(
673
+ "set_nda",
674
+ "Require viewers of a hosted drop to accept terms (an NDA or confidentiality note) before it opens; acceptance is recorded per viewer email (Pro). Pass terms='off' to remove.",
675
+ { slug: z.string(), terms: z.string().describe("The terms text viewers must accept, or 'off'.") },
676
+ async ({ slug, terms }) => {
677
+ try { return textResult(await runDrop(["nda", slug, terms])); }
678
+ catch (e) { return errResult(e); }
679
+ }
680
+ );
681
+
682
+ server.tool(
683
+ "data_store",
684
+ "Page data store for a hosted drop (Pro). mode='collect' lets the drop's own JavaScript POST JSON records (form answers, RSVPs, votes) to /api/data?drop=<handle>/<slug>, readable only by the owner; 'public' also lets the page read them back; 'off' disables.",
685
+ { slug: z.string(), mode: z.enum(["collect", "public", "off"]) },
686
+ async ({ slug, mode }) => {
687
+ try { return textResult(await runDrop(["data", slug, mode])); }
688
+ catch (e) { return errResult(e); }
689
+ }
690
+ );
691
+
692
+ server.tool(
693
+ "list_data_records",
694
+ "Read the JSON records a hosted drop's page saved through its data store.",
695
+ { slug: z.string() },
696
+ async ({ slug }) => {
697
+ try { return textResult(await runDrop(["data", slug])); }
698
+ catch (e) { return errResult(e); }
699
+ }
700
+ );
701
+
702
+ server.tool(
703
+ "list_secrets",
704
+ "List the names and target URLs of API keys stored for the secrets proxy. Values are never returned.",
705
+ {},
706
+ async () => {
707
+ try { return textResult(await runDrop(["secret", "list"])); }
708
+ catch (e) { return errResult(e); }
709
+ }
710
+ );
711
+
712
+ server.tool(
713
+ "set_secret",
714
+ "Secrets proxy (Pro): store a third-party API key server-side so a published page can call that API without exposing the key. name is UPPER_SNAKE, base_url is the only upstream it may reach; optional slug, header (default authorization), template (default 'Bearer {value}'). The page then calls fetch('/api/proxy?drop=<handle>/<slug>&secret=<NAME>&path=/v1/...'). Replaces a key with the same name.",
715
+ { name: z.string(), value: z.string(), base_url: z.string(), slug: z.string().optional(), header: z.string().optional(), template: z.string().optional() },
716
+ async ({ name, value, base_url, slug, header, template }) => {
717
+ try {
718
+ const a = ["secret", "set", name, "--base", base_url, "--value", value];
719
+ if (slug) a.push("--slug", slug); if (header) a.push("--header", header); if (template) a.push("--template", template);
720
+ return textResult(await runDrop(a));
721
+ } catch (e) { return errResult(e); }
722
+ }
723
+ );
724
+
725
+ server.tool(
726
+ "remove_secret",
727
+ "Delete a stored API key by name. Pages using it stop reaching that API.",
728
+ { name: z.string() },
729
+ async ({ name }) => {
730
+ try { return textResult(await runDrop(["secret", "rm", name])); }
731
+ catch (e) { return errResult(e); }
732
+ }
733
+ );
734
+
735
+ server.tool(
736
+ "list_portals",
737
+ "List client portals with their permanent links and the drops in each.",
738
+ {},
739
+ async () => {
740
+ try { return textResult(await runDrop(["portal", "list"])); }
741
+ catch (e) { return errResult(e); }
742
+ }
743
+ );
744
+
745
+ server.tool(
746
+ "create_portal",
747
+ "Create a client portal (Pro): one permanent link (/p/<token>) that lists every drop added to it, so a client bookmarks one page.",
748
+ { name: z.string(), note: z.string().optional() },
749
+ async ({ name, note }) => {
750
+ try { const a = ["portal", "create", name]; if (note) a.push("--note", note); return textResult(await runDrop(a)); }
751
+ catch (e) { return errResult(e); }
752
+ }
753
+ );
754
+
755
+ server.tool(
756
+ "add_to_portal",
757
+ "Add a hosted drop to a client portal, with an optional label.",
758
+ { portal: z.string().describe("Portal name or id."), slug: z.string(), label: z.string().optional() },
759
+ async ({ portal, slug, label }) => {
760
+ try { const a = ["portal", "add", portal, slug]; if (label) a.push("--label", label); return textResult(await runDrop(a)); }
761
+ catch (e) { return errResult(e); }
762
+ }
763
+ );
764
+
765
+ server.tool(
766
+ "remove_from_portal",
767
+ "Take a drop off a client portal. The drop itself stays.",
768
+ { portal: z.string().describe("Portal name or id."), slug: z.string() },
769
+ async ({ portal, slug }) => {
770
+ try { return textResult(await runDrop(["portal", "remove", portal, slug])); }
771
+ catch (e) { return errResult(e); }
772
+ }
773
+ );
774
+
775
+ server.tool(
776
+ "delete_portal",
777
+ "Delete a client portal and its link. The drops in it stay.",
778
+ { portal: z.string().describe("Portal name or id.") },
779
+ async ({ portal }) => {
780
+ try { return textResult(await runDrop(["portal", "rm", portal])); }
781
+ catch (e) { return errResult(e); }
782
+ }
783
+ );
784
+
785
+ server.tool(
786
+ "set_view_only",
787
+ "View-only mode for a hosted drop (Pro): blocks text selection, right-click, copy, save and print, blurs the page while the window is in the background, and tiles a watermark with the viewer's email (when the drop collects emails) or 'Confidential'. These deter casual copying; they can't stop a phone camera. on=false turns it off. Locked drops pick it up on the next republish with protect on.",
788
+ { slug: z.string(), on: z.boolean().optional() },
789
+ async ({ slug, on }) => {
790
+ try { return textResult(await runDrop(["protect", slug, on === false ? "off" : "on"])); }
791
+ catch (e) { return errResult(e); }
792
+ }
793
+ );
794
+
795
+ server.tool(
796
+ "drop_comments",
797
+ "Open viewer comments pinned to spots on a hosted drop, with the CSS selector and nearby text of each spot, so the page can be fixed and republished with update_site. Turn the comment widget on or off with set_feedback.",
798
+ { slug: z.string() },
799
+ async ({ slug }) => {
800
+ try { return textResult(await runDrop(["comments", slug])); }
801
+ catch (e) { return errResult(e); }
802
+ }
803
+ );
804
+
805
+ server.tool(
806
+ "resolve_comments",
807
+ "Mark one comment (by id) or all of a hosted drop's open comments as done.",
808
+ { slug: z.string(), comment: z.string().describe("A comment id, or 'all'.") },
809
+ async ({ slug, comment }) => {
810
+ try { return textResult(await runDrop(["comments", slug, "resolve", comment])); }
811
+ catch (e) { return errResult(e); }
812
+ }
813
+ );
814
+
815
+ server.tool(
816
+ "set_analytics_tag",
817
+ "Add the owner's own analytics to hosted drops (Pro): a GA4 measurement id ('G-ABC123') or 'plausible:yourdomain.com'; 'off' removes it. Pass slug for one drop or all=true for every drop.",
818
+ { tag: z.string(), slug: z.string().optional(), all: z.boolean().optional() },
819
+ async ({ tag, slug, all }) => {
820
+ try { return textResult(await runDrop(all ? ["analytics-tag", "--all", tag] : ["analytics-tag", slug || "", tag])); }
821
+ catch (e) { return errResult(e); }
822
+ }
823
+ );
824
+
825
+ server.tool(
826
+ "get_template",
827
+ "Starter HTML templates for things people share: client proposal, statement of work, pitch deck, weekly status report, project handoff, quote, product spec, research brief, property listing, event RSVP. Omit id to list them (id, job, industry, placeholders). Pass an id to get the full HTML: replace every {{placeholder}} with real content, keep the inline CSS, then publish it with publish_html. Pass team to use a team's own saved templates. Gallery: https://hushdrop.dev/templates",
828
+ {
829
+ id: z.string().optional().describe("Template id from the list, e.g. 'proposal' or 'pitch-deck'. Omit to list all templates."),
830
+ team: z.string().optional().describe("A team handle: list or fetch that team's own saved templates instead of the built-in ones (you must be on the team)."),
831
+ },
832
+ async ({ id, team }) => {
833
+ try {
834
+ if (team) {
835
+ if (!id) return textResult(await runDrop(["template", "list", "--team", team]));
836
+ const t = await runDrop(["template", id, "--team", team]);
837
+ return { content: [
838
+ { type: "text", text: `Team template @${t.team}/${t.id}${t.title ? ` (${t.title})` : ""}. Fill it in, then publish into the team with publish_html (to: ${t.team}).` },
839
+ { type: "text", text: t.html },
840
+ ] };
841
+ }
842
+ if (!id) return textResult(await runDrop(["template", "list"]));
843
+ const t = await runDrop(["template", id]);
844
+ return { content: [
845
+ { type: "text", text: `Template ${t.id} (${t.title}). Fill these placeholders, then publish with publish_html: ${t.placeholders.map((p) => `{{${p}}}`).join(", ")}` },
846
+ { type: "text", text: t.html },
847
+ ] };
848
+ } catch (e) { return errResult(e); }
849
+ }
850
+ );
851
+
852
+ server.tool(
853
+ "page_rules",
854
+ "Rules for writing an HTML page that works as a Hushdrop link and reads as finished client work: single file, no outside requests, phone-first, light/dark, print, where forms post. Read this before generating a page you will publish. When publishing into a team, pass team to also get that team's house style (follow it where it differs from the general rules).",
855
+ { team: z.string().optional().describe("Team handle you're about to publish into; adds the team's house style to the rules.") },
856
+ async ({ team }) => {
857
+ try { return textResult(await runDrop(team ? ["rules", "--team", team] : ["rules"])); }
858
+ catch (e) { return errResult(e); }
859
+ }
860
+ );
861
+
862
+ server.tool(
863
+ "search_drops",
864
+ "Full-text search over hosted drops in your personal space and every team you belong to (or one space). Unlocked drops match on their text; locked drops on title and slug only, since their content is end-to-end encrypted. Use it to find an earlier report or proposal before writing a new one.",
865
+ { q: z.string().describe("Words to search for."), space: z.string().optional().describe("Limit to one handle or team.") },
866
+ async ({ q, space }) => {
867
+ try { return textResult(await runDrop(["search", q, ...(space ? ["--to", space] : [])])); }
868
+ catch (e) { return errResult(e); }
869
+ }
870
+ );
871
+
191
872
  const transport = new StdioServerTransport();
192
873
  await server.connect(transport);