@wisewandtools/mcp-server 2.0.19 → 2.1.1

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
@@ -2767,17 +2767,37 @@ var BulkOperationsToolHandler = class {
2767
2767
  },
2768
2768
  handler: /* @__PURE__ */ __name(async (args) => {
2769
2769
  try {
2770
- const { articles, auto_generate = false } = args;
2771
- logger.info("BULK CREATE DEBUG - Handler received:", {
2772
- articles_type: typeof articles,
2773
- is_array: Array.isArray(articles),
2774
- articles_length: Array.isArray(articles) ? articles.length : "N/A",
2775
- articles_stringified: typeof articles === "string",
2776
- first_article: Array.isArray(articles) && articles.length > 0 ? articles[0] : null,
2770
+ let processedArgs = { ...args };
2771
+ if (typeof args.articles === "string") {
2772
+ logger.info("Converting articles from string to array");
2773
+ try {
2774
+ processedArgs.articles = JSON.parse(args.articles);
2775
+ } catch (error) {
2776
+ throw new Error("Invalid articles format: expected array or JSON string");
2777
+ }
2778
+ }
2779
+ const { articles, auto_generate = false } = processedArgs;
2780
+ logger.info("Validating and transforming article data types", { count: articles.length });
2781
+ const validatedArticles = articles.map((article, index) => {
2782
+ try {
2783
+ const validated = CreateArticleSchema.parse(article);
2784
+ return validated;
2785
+ } catch (error) {
2786
+ logger.error(`Validation failed for article ${index}:`, {
2787
+ article,
2788
+ error: error.message
2789
+ });
2790
+ throw new Error(`Article ${index} validation failed: ${error.message}`);
2791
+ }
2792
+ });
2793
+ logger.info("BULK CREATE DEBUG - After validation:", {
2794
+ original_count: articles.length,
2795
+ validated_count: validatedArticles.length,
2796
+ first_validated: validatedArticles.length > 0 ? validatedArticles[0] : null,
2777
2797
  auto_generate
2778
2798
  });
2779
- logger.info("Starting bulk article creation", { count: articles.length });
2780
- const createResult = await this.apiClient.createBulkArticles(articles);
2799
+ logger.info("Starting bulk article creation", { count: validatedArticles.length });
2800
+ const createResult = await this.apiClient.createBulkArticles(validatedArticles);
2781
2801
  const results = {
2782
2802
  total: articles.length,
2783
2803
  created: createResult.items.length,
@@ -2870,7 +2890,16 @@ var BulkOperationsToolHandler = class {
2870
2890
  },
2871
2891
  handler: /* @__PURE__ */ __name(async (args) => {
2872
2892
  try {
2873
- const { articles } = args;
2893
+ let processedArgs = { ...args };
2894
+ if (typeof args.articles === "string") {
2895
+ logger.info("Converting articles from string to array (bulk cost estimate)");
2896
+ try {
2897
+ processedArgs.articles = JSON.parse(args.articles);
2898
+ } catch (error) {
2899
+ throw new Error("Invalid articles format: expected array or JSON string");
2900
+ }
2901
+ }
2902
+ const { articles } = processedArgs;
2874
2903
  const result2 = await this.apiClient.calculateBulkCost(articles);
2875
2904
  this.metrics.recordAPICall("bulk_estimate_cost", "success");
2876
2905
  return {