@tryghost/ghst 0.12.0 → 0.14.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/dist/index.js CHANGED
@@ -1271,11 +1271,30 @@ function getGlobalOptions(command) {
1271
1271
  site: options.site,
1272
1272
  url: options.url,
1273
1273
  staffToken: options.staffToken,
1274
+ enableDestructiveActions: options.enableDestructiveActions,
1274
1275
  debug: options.debug,
1275
1276
  color: options.color !== false && !noColorFromEnv
1276
1277
  };
1277
1278
  }
1278
1279
 
1280
+ // src/lib/destructive-actions.ts
1281
+ function assertDestructiveActionsEnabled(global, action = "this operation") {
1282
+ if (global.enableDestructiveActions) {
1283
+ return;
1284
+ }
1285
+ throw new GhstError(
1286
+ `Destructive actions are disabled for ${action}. Re-run with --enable-destructive-actions to continue.`,
1287
+ {
1288
+ code: "DESTRUCTIVE_ACTIONS_DISABLED",
1289
+ exitCode: 2 /* USAGE_ERROR */
1290
+ }
1291
+ );
1292
+ }
1293
+ function isReadOnlyHttpMethod(method) {
1294
+ const normalized = (method ?? "GET").toUpperCase();
1295
+ return normalized === "GET" || normalized === "HEAD" || normalized === "OPTIONS";
1296
+ }
1297
+
1279
1298
  // src/lib/output.ts
1280
1299
  import process2 from "process";
1281
1300
  import chalk from "chalk";
@@ -2392,6 +2411,9 @@ function registerApiCommands(program) {
2392
2411
  const requestApi = options.contentApi ? "content" : "admin";
2393
2412
  const normalizedEndpointPath = normalizeGhostApiPath(endpointPath, requestApi);
2394
2413
  const global = getGlobalOptions(command);
2414
+ if (!isReadOnlyHttpMethod(options.method)) {
2415
+ assertDestructiveActionsEnabled(global, "raw API write request");
2416
+ }
2395
2417
  const connection = await resolveConnectionConfig(global);
2396
2418
  const client = new GhostClient({
2397
2419
  url: connection.url,
@@ -2559,16 +2581,16 @@ Reason: ${reason}`;
2559
2581
  console.error(useColor ? chalk2.yellow(warning) : warning);
2560
2582
  }
2561
2583
  async function openGhostAdminForLogin(adminOrigin, useColor) {
2562
- const staffSettingsUrl = getGhostStaffSettingsUrl(adminOrigin);
2563
- const preflight = `Opening Ghost Admin in your browser: ${staffSettingsUrl}`;
2584
+ const staffProfileUrl = getGhostStaffProfileUrl(adminOrigin);
2585
+ const preflight = `Opening Ghost Admin in your browser: ${staffProfileUrl}`;
2564
2586
  console.log("");
2565
2587
  console.log(useColor ? chalk2.cyan(preflight) : preflight);
2566
2588
  console.log("");
2567
2589
  try {
2568
- await openUrlFn(staffSettingsUrl);
2590
+ await openUrlFn(staffProfileUrl);
2569
2591
  } catch (error) {
2570
2592
  const detail = formatOpenError(error);
2571
- printOpenWarning(staffSettingsUrl, useColor, detail);
2593
+ printOpenWarning(staffProfileUrl, useColor, detail);
2572
2594
  }
2573
2595
  }
2574
2596
  var promptFn = prompt;
@@ -2614,9 +2636,9 @@ function getGhostAdminEntryUrl(url) {
2614
2636
  const normalizedUrl = normalizeGhostUrl(url);
2615
2637
  return `${normalizedUrl}/ghost`;
2616
2638
  }
2617
- function getGhostStaffSettingsUrl(url) {
2639
+ function getGhostStaffProfileUrl(url) {
2618
2640
  const normalizedUrl = normalizeGhostUrl(url);
2619
- return `${normalizedUrl}/ghost/#/settings/staff`;
2641
+ return `${normalizedUrl}/ghost/#/my-profile`;
2620
2642
  }
2621
2643
  function formatConfiguredSiteDisplay(alias, sites) {
2622
2644
  if (!alias) {
@@ -2964,6 +2986,7 @@ function registerAuthCommands(program) {
2964
2986
  code: "SITE_NOT_FOUND"
2965
2987
  });
2966
2988
  }
2989
+ assertDestructiveActionsEnabled(global, "logout site");
2967
2990
  if (site.credentialRef) {
2968
2991
  await store.delete(site.credentialRef).catch(() => void 0);
2969
2992
  }
@@ -2975,6 +2998,7 @@ function registerAuthCommands(program) {
2975
2998
  console.log(`Removed site '${targetSite}'.`);
2976
2999
  return;
2977
3000
  }
3001
+ assertDestructiveActionsEnabled(global, "logout all sites");
2978
3002
  if (!options.yes) {
2979
3003
  if (isNonInteractive()) {
2980
3004
  throw new GhstError("Removing all sites in non-interactive mode requires --yes.", {
@@ -3021,6 +3045,7 @@ function registerAuthCommands(program) {
3021
3045
  const projectConfig = await readProjectConfig();
3022
3046
  const projectConfigCwd = await resolveProjectConfigCwd();
3023
3047
  if (projectConfig && projectConfig.site !== siteAlias) {
3048
+ assertDestructiveActionsEnabled(global, "replace project link");
3024
3049
  if (!options.yes) {
3025
3050
  if (isNonInteractive()) {
3026
3051
  throw new GhstError(
@@ -3431,6 +3456,7 @@ function registerCommentCommands(program) {
3431
3456
  if (!parsed.success) {
3432
3457
  throwValidationError(parsed.error);
3433
3458
  }
3459
+ assertDestructiveActionsEnabled(global, "delete comment");
3434
3460
  if (!parsed.data.yes) {
3435
3461
  if (isNonInteractive()) {
3436
3462
  throw new GhstError("Deleting in non-interactive mode requires --yes.", {
@@ -4062,6 +4088,7 @@ function registerLabelCommands(program) {
4062
4088
  if (!parsed.success) {
4063
4089
  throwValidationError3(parsed.error);
4064
4090
  }
4091
+ assertDestructiveActionsEnabled(global, "delete label");
4065
4092
  if (!parsed.data.yes) {
4066
4093
  if (isNonInteractive()) {
4067
4094
  throw new GhstError("Deleting in non-interactive mode requires --yes.", {
@@ -4100,6 +4127,9 @@ function registerLabelCommands(program) {
4100
4127
  if (!parsed.success) {
4101
4128
  throwValidationError3(parsed.error);
4102
4129
  }
4130
+ if (parsed.data.action === "delete") {
4131
+ assertDestructiveActionsEnabled(global, "bulk delete labels");
4132
+ }
4103
4133
  const payload = await bulkLabels(global, {
4104
4134
  filter: parsed.data.filter,
4105
4135
  delete: parsed.data.action === "delete",
@@ -4601,6 +4631,19 @@ async function bulkPages(global, options) {
4601
4631
  }
4602
4632
 
4603
4633
  // src/lib/posts.ts
4634
+ function buildEmailParams(options = {}) {
4635
+ const params = {};
4636
+ if (options.newsletter) {
4637
+ params.newsletter = options.newsletter;
4638
+ }
4639
+ if (options.email_segment) {
4640
+ params.email_segment = options.email_segment;
4641
+ }
4642
+ if (options.email_only !== void 0) {
4643
+ params.email_only = String(options.email_only);
4644
+ }
4645
+ return Object.keys(params).length > 0 ? params : void 0;
4646
+ }
4604
4647
  function getFirstPost(payload) {
4605
4648
  const posts = payload.posts;
4606
4649
  if (!Array.isArray(posts) || posts.length === 0) {
@@ -4682,32 +4725,18 @@ async function deletePost(global, id) {
4682
4725
  async function publishPost(global, id, options) {
4683
4726
  return updatePost(global, {
4684
4727
  id,
4685
- patch: {
4686
- status: "published",
4687
- newsletter: options?.newsletter,
4688
- email_only: options?.email_only,
4689
- email_segment: options?.email_segment
4690
- }
4728
+ patch: { status: "published" },
4729
+ params: buildEmailParams(options)
4691
4730
  });
4692
4731
  }
4693
4732
  async function schedulePost(global, id, at, options) {
4694
- const params = {};
4695
- if (options?.newsletter) {
4696
- params.newsletter = options.newsletter;
4697
- }
4698
- if (options?.email_segment) {
4699
- params.email_segment = options.email_segment;
4700
- }
4701
- if (options?.email_only !== void 0) {
4702
- params.email_only = String(options.email_only);
4703
- }
4704
4733
  return updatePost(global, {
4705
4734
  id,
4706
4735
  patch: {
4707
4736
  status: "scheduled",
4708
4737
  published_at: at
4709
4738
  },
4710
- params: Object.keys(params).length > 0 ? params : void 0
4739
+ params: buildEmailParams(options)
4711
4740
  });
4712
4741
  }
4713
4742
  async function unschedulePost(global, id) {
@@ -7022,6 +7051,66 @@ var MCP_TOOL_GROUPS = [
7022
7051
  "socialweb",
7023
7052
  "stats"
7024
7053
  ];
7054
+ var MCP_TOOL_GROUP_METADATA = {
7055
+ posts: { title: "Posts" },
7056
+ pages: { title: "Pages" },
7057
+ tags: { title: "Tags" },
7058
+ members: { title: "Members" },
7059
+ comments: { title: "Comments" },
7060
+ site: { title: "Site" },
7061
+ settings: { title: "Settings" },
7062
+ users: { title: "Users" },
7063
+ api: { title: "API" },
7064
+ search: { title: "Search" },
7065
+ socialweb: { title: "Social web" },
7066
+ stats: { title: "Stats" }
7067
+ };
7068
+ var mcpSiteArgSchema = SiteAliasSchema.optional();
7069
+ var mcpSiteSchema = z6.object({
7070
+ site: mcpSiteArgSchema
7071
+ });
7072
+ var mcpOptionalSiteOnlySchema = z6.union([mcpSiteSchema, z6.undefined()]).transform((value) => value ?? {});
7073
+ function withMcpSiteSchema(inputSchema) {
7074
+ if (!inputSchema) {
7075
+ return mcpOptionalSiteOnlySchema;
7076
+ }
7077
+ const objectSchema = inputSchema;
7078
+ const siteShape = { site: mcpSiteArgSchema };
7079
+ if (typeof objectSchema.safeExtend === "function") {
7080
+ return objectSchema.safeExtend(siteShape);
7081
+ }
7082
+ if (typeof objectSchema.extend === "function") {
7083
+ return objectSchema.extend(siteShape);
7084
+ }
7085
+ return z6.intersection(inputSchema, mcpSiteSchema);
7086
+ }
7087
+ function scopedGlobalForTool(global, args) {
7088
+ return args.site ? { ...global, site: args.site } : global;
7089
+ }
7090
+ function argsWithoutSite(args) {
7091
+ const { site: _site, ...rest } = args;
7092
+ return rest;
7093
+ }
7094
+ function registerGroupedTool(server, global, group, name, config, handler) {
7095
+ const metadata = MCP_TOOL_GROUP_METADATA[group];
7096
+ const groupedConfig = {
7097
+ ...config,
7098
+ inputSchema: withMcpSiteSchema(config.inputSchema),
7099
+ _meta: {
7100
+ ...config._meta,
7101
+ "ghst/toolGroup": group,
7102
+ "ghst/toolGroupTitle": metadata.title
7103
+ }
7104
+ };
7105
+ const groupedHandler = async (args) => {
7106
+ const mcpArgs = args;
7107
+ return await handler(
7108
+ scopedGlobalForTool(global, mcpArgs),
7109
+ argsWithoutSite(mcpArgs)
7110
+ );
7111
+ };
7112
+ server.registerTool(name, groupedConfig, groupedHandler);
7113
+ }
7025
7114
  var statsRangeArgs = {
7026
7115
  range: z6.enum(["7d", "30d", "90d", "365d", "all"]).optional(),
7027
7116
  from: z6.string().optional(),
@@ -7194,6 +7283,9 @@ async function runSearch(global, query, limit) {
7194
7283
  };
7195
7284
  }
7196
7285
  async function callApi(global, options) {
7286
+ if (!isReadOnlyHttpMethod(options.method)) {
7287
+ assertDestructiveActionsEnabled(global, "raw API write request");
7288
+ }
7197
7289
  const connection = await resolveConnectionConfig(global);
7198
7290
  const client = new GhostClient({
7199
7291
  url: connection.url,
@@ -7212,9 +7304,22 @@ async function callApi(global, options) {
7212
7304
  );
7213
7305
  return payload;
7214
7306
  }
7307
+ async function listConfiguredSites() {
7308
+ const config = await readUserConfig();
7309
+ const sites = Object.entries(config.sites).map(([alias, site]) => ({
7310
+ alias,
7311
+ url: site.url,
7312
+ apiVersion: site.apiVersion,
7313
+ active: config.active === alias
7314
+ }));
7315
+ return { sites };
7316
+ }
7215
7317
  function registerCoreTools(server, global, enabledGroups) {
7216
7318
  if (enabledGroups.has("posts")) {
7217
- server.registerTool(
7319
+ registerGroupedTool(
7320
+ server,
7321
+ global,
7322
+ "posts",
7218
7323
  "ghost_post_list",
7219
7324
  {
7220
7325
  description: "List Ghost posts.",
@@ -7226,12 +7331,15 @@ function registerCoreTools(server, global, enabledGroups) {
7226
7331
  include: z6.string().optional()
7227
7332
  })
7228
7333
  },
7229
- async (args) => {
7230
- const payload = await listPosts(global, { ...args }, false);
7334
+ async (global2, args) => {
7335
+ const payload = await listPosts(global2, { ...args }, false);
7231
7336
  return toolResult(payload);
7232
7337
  }
7233
7338
  );
7234
- server.registerTool(
7339
+ registerGroupedTool(
7340
+ server,
7341
+ global,
7342
+ "posts",
7235
7343
  "ghost_post_get",
7236
7344
  {
7237
7345
  description: "Get a Ghost post by id or slug.",
@@ -7241,8 +7349,8 @@ function registerCoreTools(server, global, enabledGroups) {
7241
7349
  include: z6.string().optional()
7242
7350
  })
7243
7351
  },
7244
- async (args) => {
7245
- const payload = await getPost(global, args.slug ?? args.id ?? "", {
7352
+ async (global2, args) => {
7353
+ const payload = await getPost(global2, args.slug ?? args.id ?? "", {
7246
7354
  bySlug: Boolean(args.slug),
7247
7355
  params: {
7248
7356
  include: args.include
@@ -7251,7 +7359,10 @@ function registerCoreTools(server, global, enabledGroups) {
7251
7359
  return toolResult(payload);
7252
7360
  }
7253
7361
  );
7254
- server.registerTool(
7362
+ registerGroupedTool(
7363
+ server,
7364
+ global,
7365
+ "posts",
7255
7366
  "ghost_post_create",
7256
7367
  {
7257
7368
  description: "Create a Ghost post.",
@@ -7264,9 +7375,9 @@ function registerCoreTools(server, global, enabledGroups) {
7264
7375
  visibility: z6.enum(["public", "members", "paid", "tiers"]).optional()
7265
7376
  })
7266
7377
  },
7267
- async (args) => {
7378
+ async (global2, args) => {
7268
7379
  const payload = await createPost(
7269
- global,
7380
+ global2,
7270
7381
  {
7271
7382
  title: args.title,
7272
7383
  html: args.html,
@@ -7280,10 +7391,13 @@ function registerCoreTools(server, global, enabledGroups) {
7280
7391
  return toolResult(payload);
7281
7392
  }
7282
7393
  );
7283
- server.registerTool(
7394
+ registerGroupedTool(
7395
+ server,
7396
+ global,
7397
+ "posts",
7284
7398
  "ghost_post_update",
7285
7399
  {
7286
- description: "Update a Ghost post by id or slug.",
7400
+ description: "Update a Ghost post by id or slug, with optional email delivery settings on the publish transition.",
7287
7401
  inputSchema: z6.object({
7288
7402
  id: z6.string().optional(),
7289
7403
  slug: z6.string().optional(),
@@ -7292,11 +7406,14 @@ function registerCoreTools(server, global, enabledGroups) {
7292
7406
  status: z6.enum(["draft", "published", "scheduled"]).optional(),
7293
7407
  publish_at: z6.string().datetime().optional(),
7294
7408
  tags: z6.array(z6.string()).optional(),
7295
- visibility: z6.enum(["public", "members", "paid", "tiers"]).optional()
7409
+ visibility: z6.enum(["public", "members", "paid", "tiers"]).optional(),
7410
+ newsletter: z6.string().optional(),
7411
+ email_only: z6.boolean().optional(),
7412
+ email_segment: z6.string().optional()
7296
7413
  })
7297
7414
  },
7298
- async (args) => {
7299
- const payload = await updatePost(global, {
7415
+ async (global2, args) => {
7416
+ const payload = await updatePost(global2, {
7300
7417
  id: args.id,
7301
7418
  slug: args.slug,
7302
7419
  patch: {
@@ -7307,12 +7424,20 @@ function registerCoreTools(server, global, enabledGroups) {
7307
7424
  tags: args.tags,
7308
7425
  visibility: args.visibility
7309
7426
  },
7310
- source: args.html ? "html" : void 0
7427
+ source: args.html ? "html" : void 0,
7428
+ params: buildEmailParams({
7429
+ newsletter: args.newsletter,
7430
+ email_only: args.email_only,
7431
+ email_segment: args.email_segment
7432
+ })
7311
7433
  });
7312
7434
  return toolResult(payload);
7313
7435
  }
7314
7436
  );
7315
- server.registerTool(
7437
+ registerGroupedTool(
7438
+ server,
7439
+ global,
7440
+ "posts",
7316
7441
  "ghost_post_delete",
7317
7442
  {
7318
7443
  description: "Delete a Ghost post.",
@@ -7321,25 +7446,39 @@ function registerCoreTools(server, global, enabledGroups) {
7321
7446
  confirm: z6.literal(true)
7322
7447
  })
7323
7448
  },
7324
- async (args) => {
7325
- const payload = await deletePost(global, args.id);
7449
+ async (global2, args) => {
7450
+ assertDestructiveActionsEnabled(global2, "delete post");
7451
+ const payload = await deletePost(global2, args.id);
7326
7452
  return toolResult(payload);
7327
7453
  }
7328
7454
  );
7329
- server.registerTool(
7455
+ registerGroupedTool(
7456
+ server,
7457
+ global,
7458
+ "posts",
7330
7459
  "ghost_post_publish",
7331
7460
  {
7332
- description: "Publish a Ghost post.",
7461
+ description: "Publish a Ghost post, with optional email delivery settings.",
7333
7462
  inputSchema: z6.object({
7334
- id: z6.string()
7463
+ id: z6.string(),
7464
+ newsletter: z6.string().optional(),
7465
+ email_only: z6.boolean().optional(),
7466
+ email_segment: z6.string().optional()
7335
7467
  })
7336
7468
  },
7337
- async (args) => {
7338
- const payload = await publishPost(global, args.id);
7469
+ async (global2, args) => {
7470
+ const payload = await publishPost(global2, args.id, {
7471
+ newsletter: args.newsletter,
7472
+ email_only: args.email_only,
7473
+ email_segment: args.email_segment
7474
+ });
7339
7475
  return toolResult(payload);
7340
7476
  }
7341
7477
  );
7342
- server.registerTool(
7478
+ registerGroupedTool(
7479
+ server,
7480
+ global,
7481
+ "posts",
7343
7482
  "ghost_post_schedule",
7344
7483
  {
7345
7484
  description: "Schedule a Ghost post, with optional email delivery settings.",
@@ -7351,8 +7490,8 @@ function registerCoreTools(server, global, enabledGroups) {
7351
7490
  email_segment: z6.string().optional()
7352
7491
  })
7353
7492
  },
7354
- async (args) => {
7355
- const payload = await schedulePost(global, args.id, args.at, {
7493
+ async (global2, args) => {
7494
+ const payload = await schedulePost(global2, args.id, args.at, {
7356
7495
  newsletter: args.newsletter,
7357
7496
  email_only: args.email_only,
7358
7497
  email_segment: args.email_segment
@@ -7360,7 +7499,10 @@ function registerCoreTools(server, global, enabledGroups) {
7360
7499
  return toolResult(payload);
7361
7500
  }
7362
7501
  );
7363
- server.registerTool(
7502
+ registerGroupedTool(
7503
+ server,
7504
+ global,
7505
+ "posts",
7364
7506
  "ghost_image_upload",
7365
7507
  {
7366
7508
  description: "Upload an image and return the uploaded image payload.",
@@ -7370,8 +7512,8 @@ function registerCoreTools(server, global, enabledGroups) {
7370
7512
  ref: z6.string().optional()
7371
7513
  })
7372
7514
  },
7373
- async (args) => toolResult(
7374
- await uploadImage(global, {
7515
+ async (global2, args) => toolResult(
7516
+ await uploadImage(global2, {
7375
7517
  filePath: args.file_path,
7376
7518
  purpose: args.purpose,
7377
7519
  ref: args.ref
@@ -7380,7 +7522,10 @@ function registerCoreTools(server, global, enabledGroups) {
7380
7522
  );
7381
7523
  }
7382
7524
  if (enabledGroups.has("pages")) {
7383
- server.registerTool(
7525
+ registerGroupedTool(
7526
+ server,
7527
+ global,
7528
+ "pages",
7384
7529
  "ghost_page_list",
7385
7530
  {
7386
7531
  description: "List Ghost pages.",
@@ -7392,12 +7537,15 @@ function registerCoreTools(server, global, enabledGroups) {
7392
7537
  include: z6.string().optional()
7393
7538
  })
7394
7539
  },
7395
- async (args) => {
7396
- const payload = await listPages(global, { ...args }, false);
7540
+ async (global2, args) => {
7541
+ const payload = await listPages(global2, { ...args }, false);
7397
7542
  return toolResult(payload);
7398
7543
  }
7399
7544
  );
7400
- server.registerTool(
7545
+ registerGroupedTool(
7546
+ server,
7547
+ global,
7548
+ "pages",
7401
7549
  "ghost_page_get",
7402
7550
  {
7403
7551
  description: "Get a Ghost page by id or slug.",
@@ -7407,8 +7555,8 @@ function registerCoreTools(server, global, enabledGroups) {
7407
7555
  include: z6.string().optional()
7408
7556
  })
7409
7557
  },
7410
- async (args) => {
7411
- const payload = await getPage(global, args.slug ?? args.id ?? "", {
7558
+ async (global2, args) => {
7559
+ const payload = await getPage(global2, args.slug ?? args.id ?? "", {
7412
7560
  bySlug: Boolean(args.slug),
7413
7561
  params: {
7414
7562
  include: args.include
@@ -7417,7 +7565,10 @@ function registerCoreTools(server, global, enabledGroups) {
7417
7565
  return toolResult(payload);
7418
7566
  }
7419
7567
  );
7420
- server.registerTool(
7568
+ registerGroupedTool(
7569
+ server,
7570
+ global,
7571
+ "pages",
7421
7572
  "ghost_page_create",
7422
7573
  {
7423
7574
  description: "Create a Ghost page.",
@@ -7429,9 +7580,9 @@ function registerCoreTools(server, global, enabledGroups) {
7429
7580
  visibility: z6.enum(["public", "members", "paid", "tiers"]).optional()
7430
7581
  })
7431
7582
  },
7432
- async (args) => {
7583
+ async (global2, args) => {
7433
7584
  const payload = await createPage(
7434
- global,
7585
+ global2,
7435
7586
  {
7436
7587
  title: args.title,
7437
7588
  html: args.html,
@@ -7444,7 +7595,10 @@ function registerCoreTools(server, global, enabledGroups) {
7444
7595
  return toolResult(payload);
7445
7596
  }
7446
7597
  );
7447
- server.registerTool(
7598
+ registerGroupedTool(
7599
+ server,
7600
+ global,
7601
+ "pages",
7448
7602
  "ghost_page_update",
7449
7603
  {
7450
7604
  description: "Update a Ghost page by id or slug.",
@@ -7458,8 +7612,8 @@ function registerCoreTools(server, global, enabledGroups) {
7458
7612
  visibility: z6.enum(["public", "members", "paid", "tiers"]).optional()
7459
7613
  })
7460
7614
  },
7461
- async (args) => {
7462
- const payload = await updatePage(global, {
7615
+ async (global2, args) => {
7616
+ const payload = await updatePage(global2, {
7463
7617
  id: args.id,
7464
7618
  slug: args.slug,
7465
7619
  patch: {
@@ -7474,7 +7628,10 @@ function registerCoreTools(server, global, enabledGroups) {
7474
7628
  return toolResult(payload);
7475
7629
  }
7476
7630
  );
7477
- server.registerTool(
7631
+ registerGroupedTool(
7632
+ server,
7633
+ global,
7634
+ "pages",
7478
7635
  "ghost_page_delete",
7479
7636
  {
7480
7637
  description: "Delete a Ghost page.",
@@ -7483,14 +7640,18 @@ function registerCoreTools(server, global, enabledGroups) {
7483
7640
  confirm: z6.literal(true)
7484
7641
  })
7485
7642
  },
7486
- async (args) => {
7487
- const payload = await deletePage(global, args.id);
7643
+ async (global2, args) => {
7644
+ assertDestructiveActionsEnabled(global2, "delete page");
7645
+ const payload = await deletePage(global2, args.id);
7488
7646
  return toolResult(payload);
7489
7647
  }
7490
7648
  );
7491
7649
  }
7492
7650
  if (enabledGroups.has("tags")) {
7493
- server.registerTool(
7651
+ registerGroupedTool(
7652
+ server,
7653
+ global,
7654
+ "tags",
7494
7655
  "ghost_tag_list",
7495
7656
  {
7496
7657
  description: "List Ghost tags.",
@@ -7500,9 +7661,12 @@ function registerCoreTools(server, global, enabledGroups) {
7500
7661
  filter: z6.string().optional()
7501
7662
  })
7502
7663
  },
7503
- async (args) => toolResult(await listTags(global, { ...args }, false))
7664
+ async (global2, args) => toolResult(await listTags(global2, { ...args }, false))
7504
7665
  );
7505
- server.registerTool(
7666
+ registerGroupedTool(
7667
+ server,
7668
+ global,
7669
+ "tags",
7506
7670
  "ghost_tag_get",
7507
7671
  {
7508
7672
  description: "Get a Ghost tag by id or slug.",
@@ -7511,13 +7675,16 @@ function registerCoreTools(server, global, enabledGroups) {
7511
7675
  slug: z6.string().optional()
7512
7676
  })
7513
7677
  },
7514
- async (args) => toolResult(
7515
- await getTag(global, args.slug ?? args.id ?? "", {
7678
+ async (global2, args) => toolResult(
7679
+ await getTag(global2, args.slug ?? args.id ?? "", {
7516
7680
  bySlug: Boolean(args.slug)
7517
7681
  })
7518
7682
  )
7519
7683
  );
7520
- server.registerTool(
7684
+ registerGroupedTool(
7685
+ server,
7686
+ global,
7687
+ "tags",
7521
7688
  "ghost_tag_create",
7522
7689
  {
7523
7690
  description: "Create a Ghost tag.",
@@ -7527,9 +7694,12 @@ function registerCoreTools(server, global, enabledGroups) {
7527
7694
  description: z6.string().optional()
7528
7695
  })
7529
7696
  },
7530
- async (args) => toolResult(await createTag(global, args))
7697
+ async (global2, args) => toolResult(await createTag(global2, args))
7531
7698
  );
7532
- server.registerTool(
7699
+ registerGroupedTool(
7700
+ server,
7701
+ global,
7702
+ "tags",
7533
7703
  "ghost_tag_update",
7534
7704
  {
7535
7705
  description: "Update a Ghost tag.",
@@ -7540,8 +7710,8 @@ function registerCoreTools(server, global, enabledGroups) {
7540
7710
  description: z6.string().optional()
7541
7711
  })
7542
7712
  },
7543
- async (args) => toolResult(
7544
- await updateTag(global, {
7713
+ async (global2, args) => toolResult(
7714
+ await updateTag(global2, {
7545
7715
  id: args.id,
7546
7716
  slug: args.slug,
7547
7717
  patch: {
@@ -7551,7 +7721,10 @@ function registerCoreTools(server, global, enabledGroups) {
7551
7721
  })
7552
7722
  )
7553
7723
  );
7554
- server.registerTool(
7724
+ registerGroupedTool(
7725
+ server,
7726
+ global,
7727
+ "tags",
7555
7728
  "ghost_tag_delete",
7556
7729
  {
7557
7730
  description: "Delete a Ghost tag.",
@@ -7560,11 +7733,17 @@ function registerCoreTools(server, global, enabledGroups) {
7560
7733
  confirm: z6.literal(true)
7561
7734
  })
7562
7735
  },
7563
- async (args) => toolResult(await deleteTag(global, args.id))
7736
+ async (global2, args) => {
7737
+ assertDestructiveActionsEnabled(global2, "delete tag");
7738
+ return toolResult(await deleteTag(global2, args.id));
7739
+ }
7564
7740
  );
7565
7741
  }
7566
7742
  if (enabledGroups.has("members")) {
7567
- server.registerTool(
7743
+ registerGroupedTool(
7744
+ server,
7745
+ global,
7746
+ "members",
7568
7747
  "ghost_member_list",
7569
7748
  {
7570
7749
  description: "List Ghost members.",
@@ -7575,9 +7754,12 @@ function registerCoreTools(server, global, enabledGroups) {
7575
7754
  search: z6.string().optional()
7576
7755
  })
7577
7756
  },
7578
- async (args) => toolResult(await listMembers(global, { ...args }, false))
7757
+ async (global2, args) => toolResult(await listMembers(global2, { ...args }, false))
7579
7758
  );
7580
- server.registerTool(
7759
+ registerGroupedTool(
7760
+ server,
7761
+ global,
7762
+ "members",
7581
7763
  "ghost_member_get",
7582
7764
  {
7583
7765
  description: "Get Ghost member by id or email.",
@@ -7586,14 +7768,17 @@ function registerCoreTools(server, global, enabledGroups) {
7586
7768
  email: z6.string().optional()
7587
7769
  })
7588
7770
  },
7589
- async (args) => toolResult(
7590
- await getMember(global, {
7771
+ async (global2, args) => toolResult(
7772
+ await getMember(global2, {
7591
7773
  id: args.id,
7592
7774
  email: args.email
7593
7775
  })
7594
7776
  )
7595
7777
  );
7596
- server.registerTool(
7778
+ registerGroupedTool(
7779
+ server,
7780
+ global,
7781
+ "members",
7597
7782
  "ghost_member_create",
7598
7783
  {
7599
7784
  description: "Create Ghost member.",
@@ -7604,8 +7789,8 @@ function registerCoreTools(server, global, enabledGroups) {
7604
7789
  newsletters: z6.array(z6.string()).optional()
7605
7790
  })
7606
7791
  },
7607
- async (args) => toolResult(
7608
- await createMember(global, {
7792
+ async (global2, args) => toolResult(
7793
+ await createMember(global2, {
7609
7794
  email: args.email,
7610
7795
  name: args.name,
7611
7796
  labels: args.labels,
@@ -7613,7 +7798,10 @@ function registerCoreTools(server, global, enabledGroups) {
7613
7798
  })
7614
7799
  )
7615
7800
  );
7616
- server.registerTool(
7801
+ registerGroupedTool(
7802
+ server,
7803
+ global,
7804
+ "members",
7617
7805
  "ghost_member_update",
7618
7806
  {
7619
7807
  description: "Update Ghost member.",
@@ -7624,8 +7812,8 @@ function registerCoreTools(server, global, enabledGroups) {
7624
7812
  note: z6.string().optional()
7625
7813
  })
7626
7814
  },
7627
- async (args) => toolResult(
7628
- await updateMember(global, {
7815
+ async (global2, args) => toolResult(
7816
+ await updateMember(global2, {
7629
7817
  id: args.id,
7630
7818
  email: args.email,
7631
7819
  patch: {
@@ -7635,7 +7823,10 @@ function registerCoreTools(server, global, enabledGroups) {
7635
7823
  })
7636
7824
  )
7637
7825
  );
7638
- server.registerTool(
7826
+ registerGroupedTool(
7827
+ server,
7828
+ global,
7829
+ "members",
7639
7830
  "ghost_member_delete",
7640
7831
  {
7641
7832
  description: "Delete Ghost member.",
@@ -7644,9 +7835,15 @@ function registerCoreTools(server, global, enabledGroups) {
7644
7835
  confirm: z6.literal(true)
7645
7836
  })
7646
7837
  },
7647
- async (args) => toolResult(await deleteMember(global, args.id))
7838
+ async (global2, args) => {
7839
+ assertDestructiveActionsEnabled(global2, "delete member");
7840
+ return toolResult(await deleteMember(global2, args.id));
7841
+ }
7648
7842
  );
7649
- server.registerTool(
7843
+ registerGroupedTool(
7844
+ server,
7845
+ global,
7846
+ "members",
7650
7847
  "ghost_member_import",
7651
7848
  {
7652
7849
  description: "Import members from a CSV file path.",
@@ -7655,14 +7852,17 @@ function registerCoreTools(server, global, enabledGroups) {
7655
7852
  labels: z6.array(z6.string()).optional()
7656
7853
  })
7657
7854
  },
7658
- async (args) => toolResult(
7659
- await importMembersCsv(global, {
7855
+ async (global2, args) => toolResult(
7856
+ await importMembersCsv(global2, {
7660
7857
  filePath: args.file_path,
7661
7858
  labels: args.labels
7662
7859
  })
7663
7860
  )
7664
7861
  );
7665
- server.registerTool(
7862
+ registerGroupedTool(
7863
+ server,
7864
+ global,
7865
+ "members",
7666
7866
  "ghost_newsletter_list",
7667
7867
  {
7668
7868
  description: "List Ghost newsletters.",
@@ -7672,9 +7872,12 @@ function registerCoreTools(server, global, enabledGroups) {
7672
7872
  filter: z6.string().optional()
7673
7873
  })
7674
7874
  },
7675
- async (args) => toolResult(await listNewsletters(global, { ...args }, false))
7875
+ async (global2, args) => toolResult(await listNewsletters(global2, { ...args }, false))
7676
7876
  );
7677
- server.registerTool(
7877
+ registerGroupedTool(
7878
+ server,
7879
+ global,
7880
+ "members",
7678
7881
  "ghost_tier_list",
7679
7882
  {
7680
7883
  description: "List Ghost tiers.",
@@ -7684,9 +7887,12 @@ function registerCoreTools(server, global, enabledGroups) {
7684
7887
  filter: z6.string().optional()
7685
7888
  })
7686
7889
  },
7687
- async (args) => toolResult(await listTiers(global, { ...args }, false))
7890
+ async (global2, args) => toolResult(await listTiers(global2, { ...args }, false))
7688
7891
  );
7689
- server.registerTool(
7892
+ registerGroupedTool(
7893
+ server,
7894
+ global,
7895
+ "members",
7690
7896
  "ghost_offer_list",
7691
7897
  {
7692
7898
  description: "List Ghost offers.",
@@ -7696,11 +7902,14 @@ function registerCoreTools(server, global, enabledGroups) {
7696
7902
  filter: z6.string().optional()
7697
7903
  })
7698
7904
  },
7699
- async (args) => toolResult(await listOffers(global, { ...args }, false))
7905
+ async (global2, args) => toolResult(await listOffers(global2, { ...args }, false))
7700
7906
  );
7701
7907
  }
7702
7908
  if (enabledGroups.has("comments")) {
7703
- server.registerTool(
7909
+ registerGroupedTool(
7910
+ server,
7911
+ global,
7912
+ "comments",
7704
7913
  "ghost_comment_list",
7705
7914
  {
7706
7915
  description: "List Ghost comments from the Admin moderation view.",
@@ -7710,9 +7919,9 @@ function registerCoreTools(server, global, enabledGroups) {
7710
7919
  top_level_only: z6.boolean().optional()
7711
7920
  })
7712
7921
  },
7713
- async (args) => toolResult(
7922
+ async (global2, args) => toolResult(
7714
7923
  await listComments(
7715
- global,
7924
+ global2,
7716
7925
  {
7717
7926
  limit: args.limit,
7718
7927
  page: args.page,
@@ -7724,7 +7933,10 @@ function registerCoreTools(server, global, enabledGroups) {
7724
7933
  )
7725
7934
  )
7726
7935
  );
7727
- server.registerTool(
7936
+ registerGroupedTool(
7937
+ server,
7938
+ global,
7939
+ "comments",
7728
7940
  "ghost_comment_get",
7729
7941
  {
7730
7942
  description: "Get a Ghost comment with Admin moderation fields.",
@@ -7732,9 +7944,12 @@ function registerCoreTools(server, global, enabledGroups) {
7732
7944
  id: z6.string()
7733
7945
  })
7734
7946
  },
7735
- async (args) => toolResult(await getComment(global, args.id))
7947
+ async (global2, args) => toolResult(await getComment(global2, args.id))
7736
7948
  );
7737
- server.registerTool(
7949
+ registerGroupedTool(
7950
+ server,
7951
+ global,
7952
+ "comments",
7738
7953
  "ghost_comment_thread",
7739
7954
  {
7740
7955
  description: "Get a Ghost comment thread using the Admin moderation thread view.",
@@ -7742,9 +7957,12 @@ function registerCoreTools(server, global, enabledGroups) {
7742
7957
  id: z6.string()
7743
7958
  })
7744
7959
  },
7745
- async (args) => toolResult(await getCommentThread(global, args.id))
7960
+ async (global2, args) => toolResult(await getCommentThread(global2, args.id))
7746
7961
  );
7747
- server.registerTool(
7962
+ registerGroupedTool(
7963
+ server,
7964
+ global,
7965
+ "comments",
7748
7966
  "ghost_comment_replies",
7749
7967
  {
7750
7968
  description: "List replies for a Ghost comment using the raw replies endpoint.",
@@ -7753,9 +7971,9 @@ function registerCoreTools(server, global, enabledGroups) {
7753
7971
  ...commentBrowseArgs
7754
7972
  })
7755
7973
  },
7756
- async (args) => toolResult(
7974
+ async (global2, args) => toolResult(
7757
7975
  await listCommentReplies(
7758
- global,
7976
+ global2,
7759
7977
  args.id,
7760
7978
  {
7761
7979
  limit: args.limit,
@@ -7766,7 +7984,10 @@ function registerCoreTools(server, global, enabledGroups) {
7766
7984
  )
7767
7985
  )
7768
7986
  );
7769
- server.registerTool(
7987
+ registerGroupedTool(
7988
+ server,
7989
+ global,
7990
+ "comments",
7770
7991
  "ghost_comment_likes",
7771
7992
  {
7772
7993
  description: "List likes for a Ghost comment.",
@@ -7776,9 +7997,9 @@ function registerCoreTools(server, global, enabledGroups) {
7776
7997
  page: z6.number().int().positive().optional()
7777
7998
  })
7778
7999
  },
7779
- async (args) => toolResult(
8000
+ async (global2, args) => toolResult(
7780
8001
  await listCommentLikes(
7781
- global,
8002
+ global2,
7782
8003
  args.id,
7783
8004
  {
7784
8005
  limit: args.limit,
@@ -7788,7 +8009,10 @@ function registerCoreTools(server, global, enabledGroups) {
7788
8009
  )
7789
8010
  )
7790
8011
  );
7791
- server.registerTool(
8012
+ registerGroupedTool(
8013
+ server,
8014
+ global,
8015
+ "comments",
7792
8016
  "ghost_comment_reports",
7793
8017
  {
7794
8018
  description: "List reports for a Ghost comment.",
@@ -7798,9 +8022,9 @@ function registerCoreTools(server, global, enabledGroups) {
7798
8022
  page: z6.number().int().positive().optional()
7799
8023
  })
7800
8024
  },
7801
- async (args) => toolResult(
8025
+ async (global2, args) => toolResult(
7802
8026
  await listCommentReports(
7803
- global,
8027
+ global2,
7804
8028
  args.id,
7805
8029
  {
7806
8030
  limit: args.limit,
@@ -7810,7 +8034,10 @@ function registerCoreTools(server, global, enabledGroups) {
7810
8034
  )
7811
8035
  )
7812
8036
  );
7813
- server.registerTool(
8037
+ registerGroupedTool(
8038
+ server,
8039
+ global,
8040
+ "comments",
7814
8041
  "ghost_comment_hide",
7815
8042
  {
7816
8043
  description: "Hide a Ghost comment.",
@@ -7818,9 +8045,12 @@ function registerCoreTools(server, global, enabledGroups) {
7818
8045
  id: z6.string()
7819
8046
  })
7820
8047
  },
7821
- async (args) => toolResult(await setCommentStatus(global, args.id, "hidden"))
8048
+ async (global2, args) => toolResult(await setCommentStatus(global2, args.id, "hidden"))
7822
8049
  );
7823
- server.registerTool(
8050
+ registerGroupedTool(
8051
+ server,
8052
+ global,
8053
+ "comments",
7824
8054
  "ghost_comment_show",
7825
8055
  {
7826
8056
  description: "Show a previously hidden Ghost comment.",
@@ -7828,9 +8058,12 @@ function registerCoreTools(server, global, enabledGroups) {
7828
8058
  id: z6.string()
7829
8059
  })
7830
8060
  },
7831
- async (args) => toolResult(await setCommentStatus(global, args.id, "published"))
8061
+ async (global2, args) => toolResult(await setCommentStatus(global2, args.id, "published"))
7832
8062
  );
7833
- server.registerTool(
8063
+ registerGroupedTool(
8064
+ server,
8065
+ global,
8066
+ "comments",
7834
8067
  "ghost_comment_delete",
7835
8068
  {
7836
8069
  description: "Soft-delete a Ghost comment.",
@@ -7839,18 +8072,37 @@ function registerCoreTools(server, global, enabledGroups) {
7839
8072
  confirm: z6.literal(true)
7840
8073
  })
7841
8074
  },
7842
- async (args) => toolResult(await setCommentStatus(global, args.id, "deleted"))
8075
+ async (global2, args) => {
8076
+ assertDestructiveActionsEnabled(global2, "delete comment");
8077
+ return toolResult(await setCommentStatus(global2, args.id, "deleted"));
8078
+ }
7843
8079
  );
7844
8080
  }
7845
8081
  if (enabledGroups.has("site")) {
7846
- server.registerTool(
8082
+ registerGroupedTool(
8083
+ server,
8084
+ global,
8085
+ "site",
7847
8086
  "ghost_site_info",
7848
8087
  {
7849
8088
  description: "Get Ghost site metadata."
7850
8089
  },
7851
- async () => toolResult(await getSiteInfo(global))
8090
+ async (global2) => toolResult(await getSiteInfo(global2))
8091
+ );
8092
+ registerGroupedTool(
8093
+ server,
8094
+ global,
8095
+ "site",
8096
+ "ghost_site_list",
8097
+ {
8098
+ description: "List configured Ghost site aliases without credentials."
8099
+ },
8100
+ async () => toolResult(await listConfiguredSites())
7852
8101
  );
7853
- server.registerTool(
8102
+ registerGroupedTool(
8103
+ server,
8104
+ global,
8105
+ "site",
7854
8106
  "ghost_theme_upload",
7855
8107
  {
7856
8108
  description: "Upload a Ghost theme zip path and optionally activate it.",
@@ -7859,20 +8111,23 @@ function registerCoreTools(server, global, enabledGroups) {
7859
8111
  activate: z6.boolean().optional()
7860
8112
  })
7861
8113
  },
7862
- async (args) => {
7863
- const payload = await uploadTheme(global, args.file_path);
8114
+ async (global2, args) => {
8115
+ const payload = await uploadTheme(global2, args.file_path);
7864
8116
  let resultPayload = payload;
7865
8117
  if (args.activate) {
7866
8118
  const name = getUploadedThemeName(payload);
7867
8119
  if (!name) {
7868
8120
  throw new Error("Theme uploaded, but activation could not determine the theme name.");
7869
8121
  }
7870
- resultPayload = await activateTheme(global, name);
8122
+ resultPayload = await activateTheme(global2, name);
7871
8123
  }
7872
8124
  return toolResult(resultPayload);
7873
8125
  }
7874
8126
  );
7875
- server.registerTool(
8127
+ registerGroupedTool(
8128
+ server,
8129
+ global,
8130
+ "site",
7876
8131
  "ghost_webhook_create",
7877
8132
  {
7878
8133
  description: "Create a Ghost webhook.",
@@ -7884,8 +8139,8 @@ function registerCoreTools(server, global, enabledGroups) {
7884
8139
  api_version: z6.string().optional()
7885
8140
  })
7886
8141
  },
7887
- async (args) => toolResult(
7888
- await createWebhook(global, {
8142
+ async (global2, args) => toolResult(
8143
+ await createWebhook(global2, {
7889
8144
  event: args.event,
7890
8145
  target_url: args.target_url,
7891
8146
  name: args.name,
@@ -7896,14 +8151,20 @@ function registerCoreTools(server, global, enabledGroups) {
7896
8151
  );
7897
8152
  }
7898
8153
  if (enabledGroups.has("settings")) {
7899
- server.registerTool(
8154
+ registerGroupedTool(
8155
+ server,
8156
+ global,
8157
+ "settings",
7900
8158
  "ghost_setting_list",
7901
8159
  {
7902
8160
  description: "List Ghost settings."
7903
8161
  },
7904
- async () => toolResult(await listSettings(global))
8162
+ async (global2) => toolResult(await listSettings(global2))
7905
8163
  );
7906
- server.registerTool(
8164
+ registerGroupedTool(
8165
+ server,
8166
+ global,
8167
+ "settings",
7907
8168
  "ghost_setting_get",
7908
8169
  {
7909
8170
  description: "Get a Ghost setting by key.",
@@ -7911,9 +8172,12 @@ function registerCoreTools(server, global, enabledGroups) {
7911
8172
  key: z6.string()
7912
8173
  })
7913
8174
  },
7914
- async (args) => toolResult(await getSetting(global, args.key))
8175
+ async (global2, args) => toolResult(await getSetting(global2, args.key))
7915
8176
  );
7916
- server.registerTool(
8177
+ registerGroupedTool(
8178
+ server,
8179
+ global,
8180
+ "settings",
7917
8181
  "ghost_setting_set",
7918
8182
  {
7919
8183
  description: "Set a Ghost setting by key.",
@@ -7922,11 +8186,14 @@ function registerCoreTools(server, global, enabledGroups) {
7922
8186
  value: z6.union([z6.string(), z6.number(), z6.boolean(), z6.null()])
7923
8187
  })
7924
8188
  },
7925
- async (args) => toolResult(await setSetting(global, args.key, args.value))
8189
+ async (global2, args) => toolResult(await setSetting(global2, args.key, args.value))
7926
8190
  );
7927
8191
  }
7928
8192
  if (enabledGroups.has("users")) {
7929
- server.registerTool(
8193
+ registerGroupedTool(
8194
+ server,
8195
+ global,
8196
+ "users",
7930
8197
  "ghost_user_list",
7931
8198
  {
7932
8199
  description: "List Ghost staff users.",
@@ -7935,11 +8202,14 @@ function registerCoreTools(server, global, enabledGroups) {
7935
8202
  page: z6.number().int().positive().optional()
7936
8203
  })
7937
8204
  },
7938
- async (args) => toolResult(await listUsers(global, { ...args }, false))
8205
+ async (global2, args) => toolResult(await listUsers(global2, { ...args }, false))
7939
8206
  );
7940
8207
  }
7941
8208
  if (enabledGroups.has("api")) {
7942
- server.registerTool(
8209
+ registerGroupedTool(
8210
+ server,
8211
+ global,
8212
+ "api",
7943
8213
  "ghost_api_request",
7944
8214
  {
7945
8215
  description: "Run a raw Ghost API request.",
@@ -7951,8 +8221,8 @@ function registerCoreTools(server, global, enabledGroups) {
7951
8221
  content_api: z6.boolean().optional()
7952
8222
  })
7953
8223
  },
7954
- async (args) => toolResult(
7955
- await callApi(global, {
8224
+ async (global2, args) => toolResult(
8225
+ await callApi(global2, {
7956
8226
  path: args.path,
7957
8227
  method: args.method,
7958
8228
  body: args.body,
@@ -7963,7 +8233,10 @@ function registerCoreTools(server, global, enabledGroups) {
7963
8233
  );
7964
8234
  }
7965
8235
  if (enabledGroups.has("search")) {
7966
- server.registerTool(
8236
+ registerGroupedTool(
8237
+ server,
8238
+ global,
8239
+ "search",
7967
8240
  "ghost_search",
7968
8241
  {
7969
8242
  description: "Search posts, pages, tags and members.",
@@ -7972,32 +8245,44 @@ function registerCoreTools(server, global, enabledGroups) {
7972
8245
  limit: z6.number().int().positive().max(50).optional()
7973
8246
  })
7974
8247
  },
7975
- async (args) => toolResult(await runSearch(global, args.query, args.limit ?? 10))
8248
+ async (global2, args) => toolResult(await runSearch(global2, args.query, args.limit ?? 10))
7976
8249
  );
7977
8250
  }
7978
8251
  if (enabledGroups.has("socialweb")) {
7979
- server.registerTool(
8252
+ registerGroupedTool(
8253
+ server,
8254
+ global,
8255
+ "socialweb",
7980
8256
  "ghost_socialweb_status",
7981
8257
  {
7982
8258
  description: "Show Ghost social web settings and connectivity status."
7983
8259
  },
7984
- async () => toolResult(await getSocialWebStatus(global))
8260
+ async (global2) => toolResult(await getSocialWebStatus(global2))
7985
8261
  );
7986
- server.registerTool(
8262
+ registerGroupedTool(
8263
+ server,
8264
+ global,
8265
+ "socialweb",
7987
8266
  "ghost_socialweb_enable",
7988
8267
  {
7989
8268
  description: "Enable Ghost social web and return the resulting status."
7990
8269
  },
7991
- async () => toolResult(await enableSocialWeb(global))
8270
+ async (global2) => toolResult(await enableSocialWeb(global2))
7992
8271
  );
7993
- server.registerTool(
8272
+ registerGroupedTool(
8273
+ server,
8274
+ global,
8275
+ "socialweb",
7994
8276
  "ghost_socialweb_disable",
7995
8277
  {
7996
8278
  description: "Disable Ghost social web and return the resulting status."
7997
8279
  },
7998
- async () => toolResult(await disableSocialWeb(global))
8280
+ async (global2) => toolResult(await disableSocialWeb(global2))
7999
8281
  );
8000
- server.registerTool(
8282
+ registerGroupedTool(
8283
+ server,
8284
+ global,
8285
+ "socialweb",
8001
8286
  "ghost_socialweb_profile",
8002
8287
  {
8003
8288
  description: "Get a social web profile by federated handle or me.",
@@ -8005,16 +8290,19 @@ function registerCoreTools(server, global, enabledGroups) {
8005
8290
  handle: socialWebHandleSchema.optional()
8006
8291
  })
8007
8292
  },
8008
- async (args) => toolResult(await getSocialWebProfile(global, args.handle ?? "me"))
8293
+ async (global2, args) => toolResult(await getSocialWebProfile(global2, args.handle ?? "me"))
8009
8294
  );
8010
- server.registerTool(
8295
+ registerGroupedTool(
8296
+ server,
8297
+ global,
8298
+ "socialweb",
8011
8299
  "ghost_socialweb_profile_update",
8012
8300
  {
8013
8301
  description: "Update the current social web profile.",
8014
8302
  inputSchema: socialWebProfileUpdateSchema
8015
8303
  },
8016
- async (args) => toolResult(
8017
- await updateSocialWebProfile(global, {
8304
+ async (global2, args) => toolResult(
8305
+ await updateSocialWebProfile(global2, {
8018
8306
  name: args.name,
8019
8307
  username: args.username,
8020
8308
  bio: args.bio,
@@ -8023,7 +8311,10 @@ function registerCoreTools(server, global, enabledGroups) {
8023
8311
  })
8024
8312
  )
8025
8313
  );
8026
- server.registerTool(
8314
+ registerGroupedTool(
8315
+ server,
8316
+ global,
8317
+ "socialweb",
8027
8318
  "ghost_socialweb_search",
8028
8319
  {
8029
8320
  description: "Search social web accounts.",
@@ -8031,59 +8322,74 @@ function registerCoreTools(server, global, enabledGroups) {
8031
8322
  query: z6.string().min(1)
8032
8323
  })
8033
8324
  },
8034
- async (args) => toolResult(await searchSocialWeb(global, args.query))
8325
+ async (global2, args) => toolResult(await searchSocialWeb(global2, args.query))
8035
8326
  );
8036
- server.registerTool(
8327
+ registerGroupedTool(
8328
+ server,
8329
+ global,
8330
+ "socialweb",
8037
8331
  "ghost_socialweb_notes",
8038
8332
  {
8039
8333
  description: "List the social web note feed.",
8040
8334
  inputSchema: socialWebPaginationSchema
8041
8335
  },
8042
- async (args) => {
8336
+ async (global2, args) => {
8043
8337
  const pagination = mapSocialWebPaginationArgs(args);
8044
- return toolResult(await listNotes(global, pagination.params, pagination.allPages));
8338
+ return toolResult(await listNotes(global2, pagination.params, pagination.allPages));
8045
8339
  }
8046
8340
  );
8047
- server.registerTool(
8341
+ registerGroupedTool(
8342
+ server,
8343
+ global,
8344
+ "socialweb",
8048
8345
  "ghost_socialweb_reader",
8049
8346
  {
8050
8347
  description: "List the social web reader feed.",
8051
8348
  inputSchema: socialWebPaginationSchema
8052
8349
  },
8053
- async (args) => {
8350
+ async (global2, args) => {
8054
8351
  const pagination = mapSocialWebPaginationArgs(args);
8055
- return toolResult(await listReader(global, pagination.params, pagination.allPages));
8352
+ return toolResult(await listReader(global2, pagination.params, pagination.allPages));
8056
8353
  }
8057
8354
  );
8058
- server.registerTool(
8355
+ registerGroupedTool(
8356
+ server,
8357
+ global,
8358
+ "socialweb",
8059
8359
  "ghost_socialweb_notifications",
8060
8360
  {
8061
8361
  description: "List social web notifications.",
8062
8362
  inputSchema: socialWebPaginationSchema
8063
8363
  },
8064
- async (args) => {
8364
+ async (global2, args) => {
8065
8365
  const pagination = mapSocialWebPaginationArgs(args);
8066
- return toolResult(await listNotifications(global, pagination.params, pagination.allPages));
8366
+ return toolResult(await listNotifications(global2, pagination.params, pagination.allPages));
8067
8367
  }
8068
8368
  );
8069
- server.registerTool(
8369
+ registerGroupedTool(
8370
+ server,
8371
+ global,
8372
+ "socialweb",
8070
8373
  "ghost_socialweb_notifications_count",
8071
8374
  {
8072
8375
  description: "Get the unread social web notification count."
8073
8376
  },
8074
- async () => toolResult(await getNotificationsCount(global))
8377
+ async (global2) => toolResult(await getNotificationsCount(global2))
8075
8378
  );
8076
- server.registerTool(
8379
+ registerGroupedTool(
8380
+ server,
8381
+ global,
8382
+ "socialweb",
8077
8383
  "ghost_socialweb_posts",
8078
8384
  {
8079
8385
  description: "List posts for a social web account.",
8080
8386
  inputSchema: socialWebHandlePaginationSchema
8081
8387
  },
8082
- async (args) => {
8388
+ async (global2, args) => {
8083
8389
  const pagination = mapSocialWebPaginationArgs(args);
8084
8390
  return toolResult(
8085
8391
  await listSocialWebPosts(
8086
- global,
8392
+ global2,
8087
8393
  args.handle ?? "me",
8088
8394
  pagination.params,
8089
8395
  pagination.allPages
@@ -8091,44 +8397,56 @@ function registerCoreTools(server, global, enabledGroups) {
8091
8397
  );
8092
8398
  }
8093
8399
  );
8094
- server.registerTool(
8400
+ registerGroupedTool(
8401
+ server,
8402
+ global,
8403
+ "socialweb",
8095
8404
  "ghost_socialweb_likes",
8096
8405
  {
8097
8406
  description: "List posts liked by the current social web account.",
8098
8407
  inputSchema: socialWebPaginationSchema
8099
8408
  },
8100
- async (args) => {
8409
+ async (global2, args) => {
8101
8410
  const pagination = mapSocialWebPaginationArgs(args);
8102
- return toolResult(await listSocialWebLikes(global, pagination.params, pagination.allPages));
8411
+ return toolResult(await listSocialWebLikes(global2, pagination.params, pagination.allPages));
8103
8412
  }
8104
8413
  );
8105
- server.registerTool(
8414
+ registerGroupedTool(
8415
+ server,
8416
+ global,
8417
+ "socialweb",
8106
8418
  "ghost_socialweb_followers",
8107
8419
  {
8108
8420
  description: "List followers for a social web account.",
8109
8421
  inputSchema: socialWebHandlePaginationSchema
8110
8422
  },
8111
- async (args) => {
8423
+ async (global2, args) => {
8112
8424
  const pagination = mapSocialWebPaginationArgs(args);
8113
8425
  return toolResult(
8114
- await listFollowers(global, args.handle ?? "me", pagination.params, pagination.allPages)
8426
+ await listFollowers(global2, args.handle ?? "me", pagination.params, pagination.allPages)
8115
8427
  );
8116
8428
  }
8117
8429
  );
8118
- server.registerTool(
8430
+ registerGroupedTool(
8431
+ server,
8432
+ global,
8433
+ "socialweb",
8119
8434
  "ghost_socialweb_following",
8120
8435
  {
8121
8436
  description: "List followed accounts for a social web account.",
8122
8437
  inputSchema: socialWebHandlePaginationSchema
8123
8438
  },
8124
- async (args) => {
8439
+ async (global2, args) => {
8125
8440
  const pagination = mapSocialWebPaginationArgs(args);
8126
8441
  return toolResult(
8127
- await listFollowing(global, args.handle ?? "me", pagination.params, pagination.allPages)
8442
+ await listFollowing(global2, args.handle ?? "me", pagination.params, pagination.allPages)
8128
8443
  );
8129
8444
  }
8130
8445
  );
8131
- server.registerTool(
8446
+ registerGroupedTool(
8447
+ server,
8448
+ global,
8449
+ "socialweb",
8132
8450
  "ghost_socialweb_post",
8133
8451
  {
8134
8452
  description: "Get a social web post by ActivityPub id.",
@@ -8136,9 +8454,12 @@ function registerCoreTools(server, global, enabledGroups) {
8136
8454
  id: socialWebUrlSchema
8137
8455
  })
8138
8456
  },
8139
- async (args) => toolResult(await getSocialWebPost(global, args.id))
8457
+ async (global2, args) => toolResult(await getSocialWebPost(global2, args.id))
8140
8458
  );
8141
- server.registerTool(
8459
+ registerGroupedTool(
8460
+ server,
8461
+ global,
8462
+ "socialweb",
8142
8463
  "ghost_socialweb_thread",
8143
8464
  {
8144
8465
  description: "Get a social web thread by ActivityPub id.",
@@ -8146,9 +8467,12 @@ function registerCoreTools(server, global, enabledGroups) {
8146
8467
  id: socialWebUrlSchema
8147
8468
  })
8148
8469
  },
8149
- async (args) => toolResult(await getSocialWebThread(global, args.id))
8470
+ async (global2, args) => toolResult(await getSocialWebThread(global2, args.id))
8150
8471
  );
8151
- server.registerTool(
8472
+ registerGroupedTool(
8473
+ server,
8474
+ global,
8475
+ "socialweb",
8152
8476
  "ghost_socialweb_follow",
8153
8477
  {
8154
8478
  description: "Follow a federated social web account.",
@@ -8156,9 +8480,12 @@ function registerCoreTools(server, global, enabledGroups) {
8156
8480
  handle: socialWebRemoteHandleSchema
8157
8481
  })
8158
8482
  },
8159
- async (args) => toolResult(await followAccount(global, args.handle))
8483
+ async (global2, args) => toolResult(await followAccount(global2, args.handle))
8160
8484
  );
8161
- server.registerTool(
8485
+ registerGroupedTool(
8486
+ server,
8487
+ global,
8488
+ "socialweb",
8162
8489
  "ghost_socialweb_unfollow",
8163
8490
  {
8164
8491
  description: "Unfollow a federated social web account.",
@@ -8166,9 +8493,12 @@ function registerCoreTools(server, global, enabledGroups) {
8166
8493
  handle: socialWebRemoteHandleSchema
8167
8494
  })
8168
8495
  },
8169
- async (args) => toolResult(await unfollowAccount(global, args.handle))
8496
+ async (global2, args) => toolResult(await unfollowAccount(global2, args.handle))
8170
8497
  );
8171
- server.registerTool(
8498
+ registerGroupedTool(
8499
+ server,
8500
+ global,
8501
+ "socialweb",
8172
8502
  "ghost_socialweb_like",
8173
8503
  {
8174
8504
  description: "Like a social web post.",
@@ -8176,9 +8506,12 @@ function registerCoreTools(server, global, enabledGroups) {
8176
8506
  id: socialWebUrlSchema
8177
8507
  })
8178
8508
  },
8179
- async (args) => toolResult(await likePost(global, args.id))
8509
+ async (global2, args) => toolResult(await likePost(global2, args.id))
8180
8510
  );
8181
- server.registerTool(
8511
+ registerGroupedTool(
8512
+ server,
8513
+ global,
8514
+ "socialweb",
8182
8515
  "ghost_socialweb_unlike",
8183
8516
  {
8184
8517
  description: "Unlike a social web post.",
@@ -8186,9 +8519,12 @@ function registerCoreTools(server, global, enabledGroups) {
8186
8519
  id: socialWebUrlSchema
8187
8520
  })
8188
8521
  },
8189
- async (args) => toolResult(await unlikePost(global, args.id))
8522
+ async (global2, args) => toolResult(await unlikePost(global2, args.id))
8190
8523
  );
8191
- server.registerTool(
8524
+ registerGroupedTool(
8525
+ server,
8526
+ global,
8527
+ "socialweb",
8192
8528
  "ghost_socialweb_repost",
8193
8529
  {
8194
8530
  description: "Repost a social web post.",
@@ -8196,9 +8532,12 @@ function registerCoreTools(server, global, enabledGroups) {
8196
8532
  id: socialWebUrlSchema
8197
8533
  })
8198
8534
  },
8199
- async (args) => toolResult(await repostPost(global, args.id))
8535
+ async (global2, args) => toolResult(await repostPost(global2, args.id))
8200
8536
  );
8201
- server.registerTool(
8537
+ registerGroupedTool(
8538
+ server,
8539
+ global,
8540
+ "socialweb",
8202
8541
  "ghost_socialweb_derepost",
8203
8542
  {
8204
8543
  description: "Undo a repost on a social web post.",
@@ -8206,26 +8545,36 @@ function registerCoreTools(server, global, enabledGroups) {
8206
8545
  id: socialWebUrlSchema
8207
8546
  })
8208
8547
  },
8209
- async (args) => toolResult(await derepostPost(global, args.id))
8548
+ async (global2, args) => toolResult(await derepostPost(global2, args.id))
8210
8549
  );
8211
- server.registerTool(
8550
+ registerGroupedTool(
8551
+ server,
8552
+ global,
8553
+ "socialweb",
8212
8554
  "ghost_socialweb_delete",
8213
8555
  {
8214
8556
  description: "Delete a social web post authored by the current account.",
8215
8557
  inputSchema: z6.object({
8216
- id: socialWebUrlSchema
8558
+ id: socialWebUrlSchema,
8559
+ confirm: z6.literal(true)
8217
8560
  })
8218
8561
  },
8219
- async (args) => toolResult(await deleteSocialWebPost(global, args.id))
8562
+ async (global2, args) => {
8563
+ assertDestructiveActionsEnabled(global2, "delete social web post");
8564
+ return toolResult(await deleteSocialWebPost(global2, args.id));
8565
+ }
8220
8566
  );
8221
- server.registerTool(
8567
+ registerGroupedTool(
8568
+ server,
8569
+ global,
8570
+ "socialweb",
8222
8571
  "ghost_socialweb_note",
8223
8572
  {
8224
8573
  description: "Create a new social web note.",
8225
8574
  inputSchema: socialWebContentSchema
8226
8575
  },
8227
- async (args) => toolResult(
8228
- await createNote(global, {
8576
+ async (global2, args) => toolResult(
8577
+ await createNote(global2, {
8229
8578
  content: args.content,
8230
8579
  imageFile: args.image_file,
8231
8580
  imageUrl: args.image_url,
@@ -8233,7 +8582,10 @@ function registerCoreTools(server, global, enabledGroups) {
8233
8582
  })
8234
8583
  )
8235
8584
  );
8236
- server.registerTool(
8585
+ registerGroupedTool(
8586
+ server,
8587
+ global,
8588
+ "socialweb",
8237
8589
  "ghost_socialweb_reply",
8238
8590
  {
8239
8591
  description: "Reply to a social web post.",
@@ -8241,8 +8593,8 @@ function registerCoreTools(server, global, enabledGroups) {
8241
8593
  id: socialWebUrlSchema
8242
8594
  })
8243
8595
  },
8244
- async (args) => toolResult(
8245
- await replyToPost(global, args.id, {
8596
+ async (global2, args) => toolResult(
8597
+ await replyToPost(global2, args.id, {
8246
8598
  content: args.content,
8247
8599
  imageFile: args.image_file,
8248
8600
  imageUrl: args.image_url,
@@ -8250,31 +8602,40 @@ function registerCoreTools(server, global, enabledGroups) {
8250
8602
  })
8251
8603
  )
8252
8604
  );
8253
- server.registerTool(
8605
+ registerGroupedTool(
8606
+ server,
8607
+ global,
8608
+ "socialweb",
8254
8609
  "ghost_socialweb_blocked_accounts",
8255
8610
  {
8256
8611
  description: "List blocked social web accounts.",
8257
8612
  inputSchema: socialWebPaginationSchema
8258
8613
  },
8259
- async (args) => {
8614
+ async (global2, args) => {
8260
8615
  const pagination = mapSocialWebPaginationArgs(args);
8261
8616
  return toolResult(
8262
- await listBlockedAccounts(global, pagination.params, pagination.allPages)
8617
+ await listBlockedAccounts(global2, pagination.params, pagination.allPages)
8263
8618
  );
8264
8619
  }
8265
8620
  );
8266
- server.registerTool(
8621
+ registerGroupedTool(
8622
+ server,
8623
+ global,
8624
+ "socialweb",
8267
8625
  "ghost_socialweb_blocked_domains",
8268
8626
  {
8269
8627
  description: "List blocked social web domains.",
8270
8628
  inputSchema: socialWebPaginationSchema
8271
8629
  },
8272
- async (args) => {
8630
+ async (global2, args) => {
8273
8631
  const pagination = mapSocialWebPaginationArgs(args);
8274
- return toolResult(await listBlockedDomains(global, pagination.params, pagination.allPages));
8632
+ return toolResult(await listBlockedDomains(global2, pagination.params, pagination.allPages));
8275
8633
  }
8276
8634
  );
8277
- server.registerTool(
8635
+ registerGroupedTool(
8636
+ server,
8637
+ global,
8638
+ "socialweb",
8278
8639
  "ghost_socialweb_block",
8279
8640
  {
8280
8641
  description: "Block a social web account by ActivityPub id.",
@@ -8282,9 +8643,12 @@ function registerCoreTools(server, global, enabledGroups) {
8282
8643
  id: socialWebUrlSchema
8283
8644
  })
8284
8645
  },
8285
- async (args) => toolResult(await blockAccount(global, args.id))
8646
+ async (global2, args) => toolResult(await blockAccount(global2, args.id))
8286
8647
  );
8287
- server.registerTool(
8648
+ registerGroupedTool(
8649
+ server,
8650
+ global,
8651
+ "socialweb",
8288
8652
  "ghost_socialweb_unblock",
8289
8653
  {
8290
8654
  description: "Unblock a social web account by ActivityPub id.",
@@ -8292,9 +8656,12 @@ function registerCoreTools(server, global, enabledGroups) {
8292
8656
  id: socialWebUrlSchema
8293
8657
  })
8294
8658
  },
8295
- async (args) => toolResult(await unblockAccount(global, args.id))
8659
+ async (global2, args) => toolResult(await unblockAccount(global2, args.id))
8296
8660
  );
8297
- server.registerTool(
8661
+ registerGroupedTool(
8662
+ server,
8663
+ global,
8664
+ "socialweb",
8298
8665
  "ghost_socialweb_block_domain",
8299
8666
  {
8300
8667
  description: "Block a social web domain.",
@@ -8302,9 +8669,12 @@ function registerCoreTools(server, global, enabledGroups) {
8302
8669
  url: socialWebUrlSchema
8303
8670
  })
8304
8671
  },
8305
- async (args) => toolResult(await blockDomain(global, args.url))
8672
+ async (global2, args) => toolResult(await blockDomain(global2, args.url))
8306
8673
  );
8307
- server.registerTool(
8674
+ registerGroupedTool(
8675
+ server,
8676
+ global,
8677
+ "socialweb",
8308
8678
  "ghost_socialweb_unblock_domain",
8309
8679
  {
8310
8680
  description: "Unblock a social web domain.",
@@ -8312,9 +8682,12 @@ function registerCoreTools(server, global, enabledGroups) {
8312
8682
  url: socialWebUrlSchema
8313
8683
  })
8314
8684
  },
8315
- async (args) => toolResult(await unblockDomain(global, args.url))
8685
+ async (global2, args) => toolResult(await unblockDomain(global2, args.url))
8316
8686
  );
8317
- server.registerTool(
8687
+ registerGroupedTool(
8688
+ server,
8689
+ global,
8690
+ "socialweb",
8318
8691
  "ghost_socialweb_upload",
8319
8692
  {
8320
8693
  description: "Upload an image for social web notes and replies.",
@@ -8322,11 +8695,14 @@ function registerCoreTools(server, global, enabledGroups) {
8322
8695
  file_path: z6.string().min(1)
8323
8696
  })
8324
8697
  },
8325
- async (args) => toolResult(await uploadSocialWebImage(global, args.file_path))
8698
+ async (global2, args) => toolResult(await uploadSocialWebImage(global2, args.file_path))
8326
8699
  );
8327
8700
  }
8328
8701
  if (enabledGroups.has("stats")) {
8329
- server.registerTool(
8702
+ registerGroupedTool(
8703
+ server,
8704
+ global,
8705
+ "stats",
8330
8706
  "ghost_stats_overview",
8331
8707
  {
8332
8708
  description: "Get the Ghost analytics overview report.",
@@ -8334,9 +8710,12 @@ function registerCoreTools(server, global, enabledGroups) {
8334
8710
  ...statsRangeArgs
8335
8711
  })
8336
8712
  },
8337
- async (args) => toolResult(await getStatsOverview(global, mapStatsRangeArgs(args)))
8713
+ async (global2, args) => toolResult(await getStatsOverview(global2, mapStatsRangeArgs(args)))
8338
8714
  );
8339
- server.registerTool(
8715
+ registerGroupedTool(
8716
+ server,
8717
+ global,
8718
+ "stats",
8340
8719
  "ghost_stats_web",
8341
8720
  {
8342
8721
  description: "Get the Ghost web analytics report.",
@@ -8344,9 +8723,12 @@ function registerCoreTools(server, global, enabledGroups) {
8344
8723
  ...statsWebArgs
8345
8724
  })
8346
8725
  },
8347
- async (args) => toolResult(await getStatsWeb(global, mapStatsWebArgs(args)))
8726
+ async (global2, args) => toolResult(await getStatsWeb(global2, mapStatsWebArgs(args)))
8348
8727
  );
8349
- server.registerTool(
8728
+ registerGroupedTool(
8729
+ server,
8730
+ global,
8731
+ "stats",
8350
8732
  "ghost_stats_web_table",
8351
8733
  {
8352
8734
  description: "Get a focused Ghost web analytics table view.",
@@ -8355,14 +8737,17 @@ function registerCoreTools(server, global, enabledGroups) {
8355
8737
  ...statsWebArgs
8356
8738
  })
8357
8739
  },
8358
- async (args) => toolResult(
8359
- await getStatsWebTable(global, args.view, {
8740
+ async (global2, args) => toolResult(
8741
+ await getStatsWebTable(global2, args.view, {
8360
8742
  ...mapStatsWebArgs(args),
8361
8743
  limit: args.limit ?? 10
8362
8744
  })
8363
8745
  )
8364
8746
  );
8365
- server.registerTool(
8747
+ registerGroupedTool(
8748
+ server,
8749
+ global,
8750
+ "stats",
8366
8751
  "ghost_stats_growth",
8367
8752
  {
8368
8753
  description: "Get Ghost member and revenue growth analytics.",
@@ -8371,11 +8756,14 @@ function registerCoreTools(server, global, enabledGroups) {
8371
8756
  limit: z6.number().int().positive().max(100).optional()
8372
8757
  })
8373
8758
  },
8374
- async (args) => toolResult(
8375
- await getStatsGrowth(global, { ...mapStatsRangeArgs(args), limit: args.limit ?? 5 })
8759
+ async (global2, args) => toolResult(
8760
+ await getStatsGrowth(global2, { ...mapStatsRangeArgs(args), limit: args.limit ?? 5 })
8376
8761
  )
8377
8762
  );
8378
- server.registerTool(
8763
+ registerGroupedTool(
8764
+ server,
8765
+ global,
8766
+ "stats",
8379
8767
  "ghost_stats_posts",
8380
8768
  {
8381
8769
  description: "Get top Ghost posts by views.",
@@ -8384,11 +8772,14 @@ function registerCoreTools(server, global, enabledGroups) {
8384
8772
  limit: z6.number().int().positive().max(100).optional()
8385
8773
  })
8386
8774
  },
8387
- async (args) => toolResult(
8388
- await getStatsPosts(global, { ...mapStatsRangeArgs(args), limit: args.limit ?? 5 })
8775
+ async (global2, args) => toolResult(
8776
+ await getStatsPosts(global2, { ...mapStatsRangeArgs(args), limit: args.limit ?? 5 })
8389
8777
  )
8390
8778
  );
8391
- server.registerTool(
8779
+ registerGroupedTool(
8780
+ server,
8781
+ global,
8782
+ "stats",
8392
8783
  "ghost_stats_email",
8393
8784
  {
8394
8785
  description: "Get Ghost email analytics grouped by newsletter.",
@@ -8398,15 +8789,18 @@ function registerCoreTools(server, global, enabledGroups) {
8398
8789
  limit: z6.number().int().positive().max(100).optional()
8399
8790
  })
8400
8791
  },
8401
- async (args) => toolResult(
8402
- await getStatsNewsletters(global, {
8792
+ async (global2, args) => toolResult(
8793
+ await getStatsNewsletters(global2, {
8403
8794
  ...mapStatsRangeArgs(args),
8404
8795
  newsletterId: args.newsletter_id,
8405
8796
  limit: args.limit ?? 10
8406
8797
  })
8407
8798
  )
8408
8799
  );
8409
- server.registerTool(
8800
+ registerGroupedTool(
8801
+ server,
8802
+ global,
8803
+ "stats",
8410
8804
  "ghost_stats_email_clicks",
8411
8805
  {
8412
8806
  description: "Get Ghost email click analytics for a newsletter, optionally filtered by post ids.",
@@ -8417,8 +8811,8 @@ function registerCoreTools(server, global, enabledGroups) {
8417
8811
  limit: z6.number().int().positive().max(100).optional()
8418
8812
  })
8419
8813
  },
8420
- async (args) => toolResult(
8421
- await getStatsNewsletterClicks(global, {
8814
+ async (global2, args) => toolResult(
8815
+ await getStatsNewsletterClicks(global2, {
8422
8816
  ...mapStatsRangeArgs(args),
8423
8817
  newsletterId: args.newsletter_id,
8424
8818
  postIds: args.post_ids,
@@ -8426,7 +8820,10 @@ function registerCoreTools(server, global, enabledGroups) {
8426
8820
  })
8427
8821
  )
8428
8822
  );
8429
- server.registerTool(
8823
+ registerGroupedTool(
8824
+ server,
8825
+ global,
8826
+ "stats",
8430
8827
  "ghost_stats_email_subscribers",
8431
8828
  {
8432
8829
  description: "Get Ghost newsletter subscriber analytics.",
@@ -8435,14 +8832,17 @@ function registerCoreTools(server, global, enabledGroups) {
8435
8832
  newsletter_id: z6.string().optional()
8436
8833
  })
8437
8834
  },
8438
- async (args) => toolResult(
8439
- await getStatsNewsletterSubscribers(global, {
8835
+ async (global2, args) => toolResult(
8836
+ await getStatsNewsletterSubscribers(global2, {
8440
8837
  ...mapStatsRangeArgs(args),
8441
8838
  newsletterId: args.newsletter_id
8442
8839
  })
8443
8840
  )
8444
8841
  );
8445
- server.registerTool(
8842
+ registerGroupedTool(
8843
+ server,
8844
+ global,
8845
+ "stats",
8446
8846
  "ghost_stats_post",
8447
8847
  {
8448
8848
  description: "Get Ghost analytics for a single post.",
@@ -8451,9 +8851,12 @@ function registerCoreTools(server, global, enabledGroups) {
8451
8851
  ...statsRangeArgs
8452
8852
  })
8453
8853
  },
8454
- async (args) => toolResult(await getStatsPost(global, { ...mapStatsRangeArgs(args), id: args.id }))
8854
+ async (global2, args) => toolResult(await getStatsPost(global2, { ...mapStatsRangeArgs(args), id: args.id }))
8455
8855
  );
8456
- server.registerTool(
8856
+ registerGroupedTool(
8857
+ server,
8858
+ global,
8859
+ "stats",
8457
8860
  "ghost_stats_post_web",
8458
8861
  {
8459
8862
  description: "Get Ghost web analytics for a single post.",
@@ -8462,9 +8865,12 @@ function registerCoreTools(server, global, enabledGroups) {
8462
8865
  ...statsWebArgs
8463
8866
  })
8464
8867
  },
8465
- async (args) => toolResult(await getStatsPostWeb(global, { ...mapStatsWebArgs(args), id: args.id }))
8868
+ async (global2, args) => toolResult(await getStatsPostWeb(global2, { ...mapStatsWebArgs(args), id: args.id }))
8466
8869
  );
8467
- server.registerTool(
8870
+ registerGroupedTool(
8871
+ server,
8872
+ global,
8873
+ "stats",
8468
8874
  "ghost_stats_post_growth",
8469
8875
  {
8470
8876
  description: "Get Ghost growth analytics for a single post.",
@@ -8473,9 +8879,12 @@ function registerCoreTools(server, global, enabledGroups) {
8473
8879
  ...statsRangeArgs
8474
8880
  })
8475
8881
  },
8476
- async (args) => toolResult(await getStatsPostGrowth(global, { ...mapStatsRangeArgs(args), id: args.id }))
8882
+ async (global2, args) => toolResult(await getStatsPostGrowth(global2, { ...mapStatsRangeArgs(args), id: args.id }))
8477
8883
  );
8478
- server.registerTool(
8884
+ registerGroupedTool(
8885
+ server,
8886
+ global,
8887
+ "stats",
8479
8888
  "ghost_stats_post_newsletter",
8480
8889
  {
8481
8890
  description: "Get Ghost email performance analytics for a single post.",
@@ -8484,11 +8893,14 @@ function registerCoreTools(server, global, enabledGroups) {
8484
8893
  ...statsRangeArgs
8485
8894
  })
8486
8895
  },
8487
- async (args) => toolResult(
8488
- await getStatsPostNewsletter(global, { ...mapStatsRangeArgs(args), id: args.id })
8896
+ async (global2, args) => toolResult(
8897
+ await getStatsPostNewsletter(global2, { ...mapStatsRangeArgs(args), id: args.id })
8489
8898
  )
8490
8899
  );
8491
- server.registerTool(
8900
+ registerGroupedTool(
8901
+ server,
8902
+ global,
8903
+ "stats",
8492
8904
  "ghost_stats_post_referrers",
8493
8905
  {
8494
8906
  description: "Get Ghost referrer analytics for a single post.",
@@ -8498,8 +8910,8 @@ function registerCoreTools(server, global, enabledGroups) {
8498
8910
  limit: z6.number().int().positive().max(100).optional()
8499
8911
  })
8500
8912
  },
8501
- async (args) => toolResult(
8502
- await getStatsPostReferrers(global, {
8913
+ async (global2, args) => toolResult(
8914
+ await getStatsPostReferrers(global2, {
8503
8915
  ...mapStatsRangeArgs(args),
8504
8916
  id: args.id,
8505
8917
  limit: args.limit ?? 10
@@ -9168,6 +9580,7 @@ function registerMemberCommands(program) {
9168
9580
  if (!parsed.success) {
9169
9581
  throwValidationError4(parsed.error);
9170
9582
  }
9583
+ assertDestructiveActionsEnabled(global, "delete member");
9171
9584
  if (!parsed.data.yes) {
9172
9585
  if (isNonInteractive()) {
9173
9586
  throw new GhstError("Deleting in non-interactive mode requires --yes.", {
@@ -9270,6 +9683,9 @@ function registerMemberCommands(program) {
9270
9683
  throwValidationError4(parsed.error);
9271
9684
  }
9272
9685
  const resolvedAction = parsed.data.update ? "update-labels" : parsed.data.delete ? "delete" : parsed.data.action;
9686
+ if (resolvedAction === "delete") {
9687
+ assertDestructiveActionsEnabled(global, "bulk delete members");
9688
+ }
9273
9689
  const payload = await bulkMembers(global, {
9274
9690
  action: resolvedAction ?? "unsubscribe",
9275
9691
  all: parsed.data.all,
@@ -10551,6 +10967,7 @@ function registerPageCommands(program) {
10551
10967
  if (!parsed.success) {
10552
10968
  throwValidationError8(parsed.error);
10553
10969
  }
10970
+ assertDestructiveActionsEnabled(global, "delete page");
10554
10971
  if (!parsed.data.yes) {
10555
10972
  if (isNonInteractive()) {
10556
10973
  throw new GhstError("Deleting in non-interactive mode requires --yes.", {
@@ -10602,6 +11019,9 @@ function registerPageCommands(program) {
10602
11019
  if (!parsed.success) {
10603
11020
  throwValidationError8(parsed.error);
10604
11021
  }
11022
+ if (parsed.data.action === "delete") {
11023
+ assertDestructiveActionsEnabled(global, "bulk delete pages");
11024
+ }
10605
11025
  const payload = await bulkPages(global, {
10606
11026
  filter: parsed.data.filter,
10607
11027
  delete: parsed.data.action === "delete",
@@ -10686,10 +11106,7 @@ var PostCreateInputSchema = withSingleContentSource2(
10686
11106
  metaDescription: z12.string().optional(),
10687
11107
  ogTitle: z12.string().optional(),
10688
11108
  ogImage: z12.string().url().optional(),
10689
- codeInjectionHead: z12.string().optional(),
10690
- newsletter: z12.string().optional(),
10691
- emailOnly: z12.boolean().optional(),
10692
- emailSegment: z12.string().optional()
11109
+ codeInjectionHead: z12.string().optional()
10693
11110
  }).refine((data) => Boolean(data.title || data.fromJson), {
10694
11111
  message: "Provide --title or --from-json.",
10695
11112
  path: ["title"]
@@ -10950,7 +11367,7 @@ function registerPostCommands(program) {
10950
11367
  }
10951
11368
  printPostHuman(payload);
10952
11369
  });
10953
- post.command("create").description("Create a post").option("--title <title>", "Post title").option("--status <status>", "Post status").option("--publish-at <datetime>", "Publish date-time for scheduled posts").option("--html <html>", "Post HTML content").option("--html-file <path>", "Path to HTML file").option("--lexical-file <path>", "Path to Lexical JSON file").option("--markdown-file <path>", "Path to Markdown file").option("--markdown-stdin", "Read Markdown content from stdin").option("--html-raw-file <path>", "Path to raw HTML file wrapped in an HTML card").option("--from-json <path>", "Read post payload from JSON file").option("--tags <tags>", "Comma separated tag names").option("--authors <authors>", "Comma separated author emails").option("--featured", "Mark as featured").option("--visibility <visibility>", "public|members|paid|tiers").option("--tier <slug>", "Tier slug for tier visibility access").option("--feature-image <url>", "Feature image URL").option("--excerpt <excerpt>", "Custom excerpt").option("--meta-title <title>", "Meta title").option("--meta-description <description>", "Meta description").option("--og-title <title>", "Open Graph title").option("--og-image <url>", "Open Graph image URL").option("--code-injection-head <value>", "Code injection head HTML").option("--newsletter <slug>", "Newsletter slug for published posts").option("--email-only", "Publish as email-only").option("--email-segment <segment>", "Email segment for publish email").action(async (options, command) => {
11370
+ post.command("create").description("Create a post").option("--title <title>", "Post title").option("--status <status>", "Post status").option("--publish-at <datetime>", "Publish date-time for scheduled posts").option("--html <html>", "Post HTML content").option("--html-file <path>", "Path to HTML file").option("--lexical-file <path>", "Path to Lexical JSON file").option("--markdown-file <path>", "Path to Markdown file").option("--markdown-stdin", "Read Markdown content from stdin").option("--html-raw-file <path>", "Path to raw HTML file wrapped in an HTML card").option("--from-json <path>", "Read post payload from JSON file").option("--tags <tags>", "Comma separated tag names").option("--authors <authors>", "Comma separated author emails").option("--featured", "Mark as featured").option("--visibility <visibility>", "public|members|paid|tiers").option("--tier <slug>", "Tier slug for tier visibility access").option("--feature-image <url>", "Feature image URL").option("--excerpt <excerpt>", "Custom excerpt").option("--meta-title <title>", "Meta title").option("--meta-description <description>", "Meta description").option("--og-title <title>", "Open Graph title").option("--og-image <url>", "Open Graph image URL").option("--code-injection-head <value>", "Code injection head HTML").action(async (options, command) => {
10954
11371
  const global = getGlobalOptions(command);
10955
11372
  const parsed = PostCreateInputSchema.safeParse({
10956
11373
  title: options.title,
@@ -10974,10 +11391,7 @@ function registerPostCommands(program) {
10974
11391
  metaDescription: options.metaDescription,
10975
11392
  ogTitle: options.ogTitle,
10976
11393
  ogImage: options.ogImage,
10977
- codeInjectionHead: options.codeInjectionHead,
10978
- newsletter: options.newsletter,
10979
- emailOnly: parseBooleanFlag(options.emailOnly),
10980
- emailSegment: options.emailSegment
11394
+ codeInjectionHead: options.codeInjectionHead
10981
11395
  });
10982
11396
  if (!parsed.success) {
10983
11397
  throwValidationError9(parsed.error);
@@ -11013,10 +11427,7 @@ function registerPostCommands(program) {
11013
11427
  meta_description: parsed.data.metaDescription,
11014
11428
  og_title: parsed.data.ogTitle,
11015
11429
  og_image: parsed.data.ogImage,
11016
- codeinjection_head: parsed.data.codeInjectionHead,
11017
- newsletter: parsed.data.newsletter,
11018
- email_only: parsed.data.emailOnly,
11019
- email_segment: parsed.data.emailSegment
11430
+ codeinjection_head: parsed.data.codeInjectionHead
11020
11431
  }
11021
11432
  );
11022
11433
  const payload = await createPost(global, createPayload, source);
@@ -11026,7 +11437,7 @@ function registerPostCommands(program) {
11026
11437
  }
11027
11438
  printPostHuman(payload);
11028
11439
  });
11029
- post.command("update [id]").description("Update a post by id or slug").option("--slug <slug>", "Post slug lookup").option("--title <title>", "Post title").option("--status <status>", "Post status").option("--publish-at <datetime>", "Publish date-time for scheduled posts").option("--html <html>", "Post HTML content").option("--html-file <path>", "Path to HTML file").option("--lexical-file <path>", "Path to Lexical JSON file").option("--markdown-file <path>", "Path to Markdown file").option("--markdown-stdin", "Read Markdown content from stdin").option("--html-raw-file <path>", "Path to raw HTML file wrapped in an HTML card").option("--from-json <path>", "Read post patch from JSON file").option("--tags <tags>", "Comma separated tag names").option("--authors <authors>", "Comma separated author emails").option("--featured <value>", "true|false").option("--visibility <visibility>", "public|members|paid|tiers").option("--tier <slug>", "Tier slug for tier visibility access").option("--feature-image <url>", "Feature image URL").option("--excerpt <excerpt>", "Custom excerpt").option("--meta-title <title>", "Meta title").option("--meta-description <description>", "Meta description").option("--og-title <title>", "Open Graph title").option("--og-image <url>", "Open Graph image URL").option("--code-injection-head <value>", "Code injection head HTML").option("--newsletter <slug>", "Newsletter slug").option("--email-only <value>", "true|false").option("--email-segment <segment>", "Email segment").action(async (id, options, command) => {
11440
+ post.command("update [id]").description("Update a post by id or slug").option("--slug <slug>", "Post slug lookup").option("--title <title>", "Post title").option("--status <status>", "Post status").option("--publish-at <datetime>", "Publish date-time for scheduled posts").option("--html <html>", "Post HTML content").option("--html-file <path>", "Path to HTML file").option("--lexical-file <path>", "Path to Lexical JSON file").option("--markdown-file <path>", "Path to Markdown file").option("--markdown-stdin", "Read Markdown content from stdin").option("--html-raw-file <path>", "Path to raw HTML file wrapped in an HTML card").option("--from-json <path>", "Read post patch from JSON file").option("--tags <tags>", "Comma separated tag names").option("--authors <authors>", "Comma separated author emails").option("--featured <value>", "true|false").option("--visibility <visibility>", "public|members|paid|tiers").option("--tier <slug>", "Tier slug for tier visibility access").option("--feature-image <url>", "Feature image URL").option("--excerpt <excerpt>", "Custom excerpt").option("--meta-title <title>", "Meta title").option("--meta-description <description>", "Meta description").option("--og-title <title>", "Open Graph title").option("--og-image <url>", "Open Graph image URL").option("--code-injection-head <value>", "Code injection head HTML").option("--newsletter <slug>", "Newsletter slug for email delivery").option("--email-only <value>", "Send as email only (true|false)").option("--email-segment <segment>", "Email segment for delivery").action(async (id, options, command) => {
11030
11441
  const global = getGlobalOptions(command);
11031
11442
  const parsed = PostUpdateInputSchema.safeParse({
11032
11443
  id,
@@ -11091,17 +11502,19 @@ function registerPostCommands(program) {
11091
11502
  meta_description: parsed.data.metaDescription,
11092
11503
  og_title: parsed.data.ogTitle,
11093
11504
  og_image: parsed.data.ogImage,
11094
- codeinjection_head: parsed.data.codeInjectionHead,
11095
- newsletter: parsed.data.newsletter,
11096
- email_only: parsed.data.emailOnly,
11097
- email_segment: parsed.data.emailSegment
11505
+ codeinjection_head: parsed.data.codeInjectionHead
11098
11506
  }
11099
11507
  );
11100
11508
  const payload = await updatePost(global, {
11101
11509
  id: parsed.data.id,
11102
11510
  slug: parsed.data.slug,
11103
11511
  patch,
11104
- source
11512
+ source,
11513
+ params: buildEmailParams({
11514
+ newsletter: parsed.data.newsletter,
11515
+ email_only: parsed.data.emailOnly,
11516
+ email_segment: parsed.data.emailSegment
11517
+ })
11105
11518
  });
11106
11519
  if (global.json) {
11107
11520
  printJson(payload, global.jq);
@@ -11119,6 +11532,7 @@ function registerPostCommands(program) {
11119
11532
  if (!parsed.success) {
11120
11533
  throwValidationError9(parsed.error);
11121
11534
  }
11535
+ assertDestructiveActionsEnabled(global, "delete post");
11122
11536
  if (!parsed.data.yes) {
11123
11537
  if (isNonInteractive()) {
11124
11538
  throw new GhstError("Deleting in non-interactive mode requires --yes.", {
@@ -11164,7 +11578,7 @@ function registerPostCommands(program) {
11164
11578
  }
11165
11579
  console.log(`Deleted post '${parsed.data.id ?? ""}'.`);
11166
11580
  });
11167
- post.command("publish <id>").description("Publish a post").option("--newsletter <slug>", "Newsletter slug").option("--email-segment <segment>", "Email segment").option("--email-only", "Email only publish").action(async (id, options, command) => {
11581
+ post.command("publish <id>").description("Publish a post").option("--newsletter <slug>", "Newsletter slug for email delivery").option("--email-segment <segment>", "Email segment for delivery").option("--email-only", "Send as email only").action(async (id, options, command) => {
11168
11582
  const global = getGlobalOptions(command);
11169
11583
  const parsed = PostPublishInputSchema.safeParse({
11170
11584
  id,
@@ -11186,7 +11600,7 @@ function registerPostCommands(program) {
11186
11600
  }
11187
11601
  printPostHuman(payload);
11188
11602
  });
11189
- post.command("schedule <id>").description("Schedule a post").requiredOption("--at <datetime>", "ISO datetime for scheduled publish").option("--newsletter <slug>", "Newsletter slug for email delivery").option("--email-only", "Email only publish").option("--email-segment <segment>", "Email segment").action(async (id, options, command) => {
11603
+ post.command("schedule <id>").description("Schedule a post").requiredOption("--at <datetime>", "ISO datetime for scheduled publish").option("--newsletter <slug>", "Newsletter slug for email delivery").option("--email-only", "Send as email only").option("--email-segment <segment>", "Email segment for delivery").action(async (id, options, command) => {
11190
11604
  const global = getGlobalOptions(command);
11191
11605
  const parsed = PostScheduleInputSchema.safeParse({
11192
11606
  id,
@@ -11252,6 +11666,9 @@ function registerPostCommands(program) {
11252
11666
  throwValidationError9(parsed.error);
11253
11667
  }
11254
11668
  const action = parsed.data.action ?? (parsed.data.delete ? "delete" : "update");
11669
+ if (action === "delete") {
11670
+ assertDestructiveActionsEnabled(global, "bulk delete posts");
11671
+ }
11255
11672
  const payload = await bulkPosts(global, {
11256
11673
  filter: parsed.data.filter,
11257
11674
  delete: action === "delete",
@@ -11763,6 +12180,7 @@ function registerSocialWebCommands(program) {
11763
12180
  if (!parsed.success) {
11764
12181
  throwValidationError11(parsed.error);
11765
12182
  }
12183
+ assertDestructiveActionsEnabled(global, "delete social web post");
11766
12184
  if (!parsed.data.yes) {
11767
12185
  if (isNonInteractive()) {
11768
12186
  throw new GhstError("Deleting in non-interactive mode requires --yes.", {
@@ -12788,6 +13206,7 @@ function registerTagCommands(program) {
12788
13206
  if (!parsed.success) {
12789
13207
  throwValidationError13(parsed.error);
12790
13208
  }
13209
+ assertDestructiveActionsEnabled(global, "delete tag");
12791
13210
  if (!parsed.data.yes) {
12792
13211
  if (isNonInteractive()) {
12793
13212
  throw new GhstError("Deleting in non-interactive mode requires --yes.", {
@@ -12826,6 +13245,9 @@ function registerTagCommands(program) {
12826
13245
  if (!parsed.success) {
12827
13246
  throwValidationError13(parsed.error);
12828
13247
  }
13248
+ if (parsed.data.action === "delete") {
13249
+ assertDestructiveActionsEnabled(global, "bulk delete tags");
13250
+ }
12829
13251
  const payload = await bulkTags(global, {
12830
13252
  filter: parsed.data.filter,
12831
13253
  delete: parsed.data.action === "delete",
@@ -13990,6 +14412,7 @@ function registerWebhookCommands(program) {
13990
14412
  if (!parsed.success) {
13991
14413
  throwValidationError17(parsed.error);
13992
14414
  }
14415
+ assertDestructiveActionsEnabled(global, "delete webhook");
13993
14416
  if (!parsed.data.yes) {
13994
14417
  if (isNonInteractive()) {
13995
14418
  throw new GhstError("Deleting in non-interactive mode requires --yes.", {
@@ -14094,7 +14517,7 @@ function registerWebhookCommands(program) {
14094
14517
  // src/index.ts
14095
14518
  function buildProgram() {
14096
14519
  const program = new Command();
14097
- program.name("ghst").description("A modern CLI for Ghost CMS").showHelpAfterError().showSuggestionAfterError(true).option("--json", "Output JSON").option("--jq <filter>", "Apply jq-style field extraction to JSON output").option("--site <site>", "Configured site alias").option("--url <url>", "Ghost site URL override").option("--staff-token <token>", "Ghost staff access token override").option("--debug [level]", "Enable debug output").option("--no-color", "Disable color output");
14520
+ program.name("ghst").description("A modern CLI for Ghost CMS").showHelpAfterError().showSuggestionAfterError(true).option("--json", "Output JSON").option("--jq <filter>", "Apply jq-style field extraction to JSON output").option("--site <site>", "Configured site alias").option("--url <url>", "Ghost site URL override").option("--staff-token <token>", "Ghost staff access token override").option("--enable-destructive-actions", "Allow destructive operations such as deletes").option("--debug [level]", "Enable debug output").option("--no-color", "Disable color output");
14098
14521
  registerAuthCommands(program);
14099
14522
  registerCommentCommands(program);
14100
14523
  registerPostCommands(program);