@wisewandtools/mcp-server 2.2.3 → 2.2.4

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
@@ -2397,8 +2397,19 @@ var PublishingToolHandler = class {
2397
2397
  if (storedAuthor && !author_id) {
2398
2398
  if (clear_author) {
2399
2399
  try {
2400
- await this.apiClient.updateArticle(entity_id, { publishwordpress_author: void 0 });
2401
- logger.info("Cleared stored publishwordpress_author before publishing", { entity_id, cleared_author: storedAuthor });
2400
+ await this.apiClient.updateArticle(entity_id, { publishwordpress_author: null });
2401
+ try {
2402
+ const updated = await this.apiClient.getArticle(entity_id);
2403
+ const stillPresent = updated.data?.input?.publishwordpress_author;
2404
+ if (stillPresent) {
2405
+ logger.warn("publishwordpress_author still present after clear attempt", { entity_id, value: stillPresent });
2406
+ warnings.push(`publishwordpress_author may not have been fully cleared (still shows "${stillPresent}"). Publishing may still fail.`);
2407
+ } else {
2408
+ logger.info("Cleared stored publishwordpress_author before publishing", { entity_id, cleared_author: storedAuthor });
2409
+ }
2410
+ } catch (verifyError) {
2411
+ logger.warn("Could not verify publishwordpress_author was cleared", { error: verifyError.message });
2412
+ }
2402
2413
  } catch (clearError) {
2403
2414
  logger.warn("Failed to clear publishwordpress_author", { error: clearError.message });
2404
2415
  warnings.push(`Could not clear stored publishwordpress_author (${storedAuthor}). Publishing may fail if the WP connection user lacks edit_others_posts.`);
@@ -3126,20 +3137,19 @@ var BulkOperationsToolHandler = class {
3126
3137
  const result2 = await this.apiClient.calculateBulkCost(articles);
3127
3138
  logger.debug("bulk_estimate_cost raw API response keys", { keys: Object.keys(result2 || {}) });
3128
3139
  const breakdown = result2?.breakdown ?? result2?.items ?? result2?.estimates ?? [];
3129
- let total;
3130
- if (typeof result2?.total === "number" && !isNaN(result2.total)) {
3131
- total = result2.total;
3132
- } else if (typeof result2?.credits === "number" && !isNaN(result2.credits)) {
3133
- total = result2.credits;
3134
- } else if (typeof result2?.cost === "number" && !isNaN(result2.cost)) {
3135
- total = result2.cost;
3140
+ let totalCredits;
3141
+ if (typeof result2?.credits === "number" && !isNaN(result2.credits)) {
3142
+ totalCredits = result2.credits;
3143
+ } else if (typeof result2?.total === "number" && !isNaN(result2.total)) {
3144
+ totalCredits = result2.total;
3136
3145
  } else if (Array.isArray(breakdown) && breakdown.length > 0) {
3137
- total = breakdown.reduce((sum, item) => sum + (item?.credits ?? item?.cost ?? 0), 0);
3138
- logger.info("bulk_estimate_cost: total derived from breakdown sum", { total });
3146
+ totalCredits = breakdown.reduce((sum, item) => sum + (item?.credits ?? item?.cost ?? 0), 0);
3147
+ logger.info("bulk_estimate_cost: totalCredits derived from breakdown sum", { totalCredits });
3139
3148
  } else {
3140
- total = 0;
3141
- logger.warn("bulk_estimate_cost: could not extract total from API response, defaulting to 0", { resultKeys: Object.keys(result2 || {}) });
3149
+ totalCredits = 0;
3150
+ logger.warn("bulk_estimate_cost: could not extract credits from API response, defaulting to 0", { resultKeys: Object.keys(result2 || {}) });
3142
3151
  }
3152
+ const totalCost = typeof result2?.cost === "number" && !isNaN(result2.cost) ? result2.cost : typeof result2?.price === "number" && !isNaN(result2.price) ? result2.price : null;
3143
3153
  this.metrics.recordAPICall("bulk_estimate_cost", "success");
3144
3154
  return {
3145
3155
  content: [
@@ -3148,13 +3158,13 @@ var BulkOperationsToolHandler = class {
3148
3158
  text: JSON.stringify({
3149
3159
  success: true,
3150
3160
  total_cost: {
3151
- credits: total,
3152
- usd: (total * 0.01).toFixed(2)
3161
+ credits: totalCredits,
3162
+ usd: totalCost !== null ? totalCost.toFixed(2) : null
3153
3163
  },
3154
3164
  article_count: articles.length,
3155
3165
  average_cost_per_article: {
3156
- credits: articles.length > 0 ? Math.round(total / articles.length) : 0,
3157
- usd: articles.length > 0 ? (total / articles.length * 0.01).toFixed(2) : "0.00"
3166
+ credits: articles.length > 0 ? Math.round(totalCredits / articles.length) : 0,
3167
+ usd: totalCost !== null && articles.length > 0 ? (totalCost / articles.length).toFixed(2) : null
3158
3168
  },
3159
3169
  breakdown
3160
3170
  }, null, 2)