Skip to main content
Glama

wp_seo_bulk_update_metadata

Update SEO metadata for multiple WordPress posts simultaneously with progress tracking and error handling.

Instructions

Update SEO metadata for multiple posts with progress tracking and error handling

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoSite identifier for multi-site setups
postIdsYesArray of WordPress post IDs to update
updatesYesMetadata fields to update for all posts
dryRunNoPerform a dry run without making actual changes

Implementation Reference

  • The main MCP tool handler function for 'wp_seo_bulk_update_metadata'. It parses input arguments, creates parameters, and delegates execution to the SEOTools.bulkUpdateMetadata method.
    /**
     * Handle bulk metadata update request
     */
    export async function handleBulkUpdateMetadata(
      client: WordPressClient,
      args: Record<string, unknown>,
    ): Promise<unknown> {
      const logger = LoggerFactory.tool("wp_seo_bulk_update_metadata");
    
      try {
        const seoTools = getSEOToolsInstance();
        const params: SEOToolParams = {
          postIds: args.postIds as number[],
          updates: args.updates as Partial<SEOMetadata>,
          dryRun: args.dryRun as boolean,
          site: args.site as string,
        };
    
        return await seoTools.bulkUpdateMetadata(params);
      } catch (error) {
        logger.error("Failed to bulk update metadata", { error, args });
        throw error;
      }
    }
  • Defines the tool schema including name, description, and input validation schema for the wp_seo_bulk_update_metadata tool.
    /**
     * Bulk update metadata for multiple posts
     */
    export const bulkUpdateMetadataTool: Tool = {
      name: "wp_seo_bulk_update_metadata",
      description: "Update SEO metadata for multiple posts with progress tracking and error handling",
      inputSchema: {
        type: "object",
        properties: {
          postIds: {
            type: "array",
            items: { type: "number" },
            description: "Array of WordPress post IDs to update",
          },
          updates: {
            type: "object",
            properties: {
              title: { type: "string" },
              description: { type: "string" },
              focusKeyword: { type: "string" },
              canonical: { type: "string" },
            },
            description: "Metadata fields to update for all posts",
          },
          dryRun: {
            type: "boolean",
            description: "Perform a dry run without making actual changes",
          },
          site: {
            type: "string",
            description: "Site identifier for multi-site setups",
          },
        },
        required: ["postIds", "updates"],
      },
    };
  • Maps the tool name 'wp_seo_bulk_update_metadata' to its handler function handleBulkUpdateMetadata. Used by getTools() to register all SEO tools with handlers.
    private getHandlerForTool(toolName: string): unknown {
      const handlers: Record<string, unknown> = {
        wp_seo_analyze_content: handleAnalyzeContent,
        wp_seo_generate_metadata: handleGenerateMetadata,
        wp_seo_bulk_update_metadata: handleBulkUpdateMetadata,
        wp_seo_generate_schema: handleGenerateSchema,
        wp_seo_validate_schema: handleValidateSchema,
        wp_seo_suggest_internal_links: handleSuggestInternalLinks,
        wp_seo_site_audit: handlePerformSiteAudit,
        wp_seo_track_serp: handleTrackSERPPositions,
        wp_seo_keyword_research: handleKeywordResearch,
        wp_seo_test_integration: handleTestSEOIntegration,
        wp_seo_get_live_data: handleGetLiveSEOData,
      };
    
      return (
        handlers[toolName] ||
        (() => {
          throw new Error(`Unknown SEO tool: ${toolName}`);
        })
      );
    }
  • Core bulk processing logic delegated from SEOTools. Handles batching, individual post metadata updates, retries, progress reporting, and error collection.
    async bulkUpdateMetadata(params: SEOToolParams, progressCallback?: ProgressCallback): Promise<BulkOperationResult> {
      const startTime = Date.now();
      this.logger.info("Starting bulk metadata update", {
        postIds: params.postIds?.length,
        dryRun: params.dryRun,
        batchSize: this.config.batchSize,
      });
    
      if (!params.postIds?.length) {
        throw new Error("No post IDs provided for bulk operation");
      }
    
      const progress: BulkProgress = {
        total: params.postIds.length,
        processed: 0,
        completed: 0,
        failed: 0,
        skipped: 0,
        currentBatch: 0,
        totalBatches: Math.ceil(params.postIds.length / this.config.batchSize),
        avgProcessingTime: 0,
      };
    
      const errors: BulkOperationError[] = [];
      const batches = this.createBatches(params.postIds, this.config.batchSize);
    
      // Process each batch
      for (let batchIndex = 0; batchIndex < batches.length; batchIndex++) {
        const batch = batches[batchIndex];
        progress.currentBatch = batchIndex + 1;
    
        this.logger.debug(`Processing batch ${progress.currentBatch}/${progress.totalBatches}`, {
          batchSize: batch.length,
          postIds: batch,
        });
    
        // Process batch items
        await Promise.all(
          batch.map(async (postId) => {
            const itemStartTime = Date.now();
    
            try {
              await this.processMetadataUpdate(postId, params);
              progress.completed++;
    
              // Update average processing time
              const processingTime = Date.now() - itemStartTime;
              progress.avgProcessingTime =
                (progress.avgProcessingTime * progress.processed + processingTime) / (progress.processed + 1);
            } catch (_error) {
              const bulkError: BulkOperationError = {
                postId,
                error: _error instanceof Error ? _error.message : String(_error),
                attempts: 1,
                retryable: this.isRetryableError(_error),
              };
    
              // Attempt retries
              if (bulkError.retryable) {
                const retryResult = await this.retryOperation(
                  () => this.processMetadataUpdate(postId, params),
                  bulkError,
                );
    
                if (retryResult.success) {
                  progress.completed++;
                } else {
                  progress.failed++;
                  errors.push(retryResult.error);
                }
              } else {
                progress.failed++;
                errors.push(bulkError);
              }
            }
    
            progress.processed++;
          }),
        );
    
        // Calculate ETA
        if (progress.avgProcessingTime > 0 && progress.processed < progress.total) {
          const remainingItems = progress.total - progress.processed;
          const etaMs = remainingItems * progress.avgProcessingTime;
          progress.eta = new Date(Date.now() + etaMs);
        } else if (progress.processed > 0 && progress.processed < progress.total) {
          // Fallback ETA calculation even with minimal processing time
          const remainingItems = progress.total - progress.processed;
          const averageTime = progress.avgProcessingTime || 100; // Fallback to 100ms
          const etaMs = remainingItems * averageTime;
          progress.eta = new Date(Date.now() + etaMs);
        }
    
        // Call progress callback
        if (progressCallback && this.config.enableProgress) {
          progressCallback(progress);
        }
    
        // Small delay between batches to avoid overwhelming the server
        if (batchIndex < batches.length - 1) {
          await this.delay(100);
        }
      }
    
      const result: BulkOperationResult = {
        total: params.postIds.length,
        success: progress.completed,
        failed: progress.failed,
        skipped: progress.skipped,
        errors: errors.map((e) => ({ postId: e.postId, error: e.error })),
        processingTime: Date.now() - startTime,
        dryRun: params.dryRun || false,
      };
    
      this.logger.info("Bulk metadata update completed", {
        ...result,
        successRate: ((result.success / result.total) * 100).toFixed(1) + "%",
      });
    
      return result;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'progress tracking and error handling,' which adds some context about reliability features. However, it doesn't address critical behavioral aspects: whether this is a destructive operation (likely yes, as it updates metadata), permission requirements, rate limits, or what happens on partial failures. For a bulk mutation tool with zero annotation coverage, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose ('Update SEO metadata for multiple posts') and adds value with secondary features ('with progress tracking and error handling'). There's no wasted verbiage or redundancy, making it highly concise and well-structured for quick comprehension.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (bulk mutation with 4 parameters, nested objects, no output schema, and no annotations), the description is minimally adequate. It covers the basic purpose and hints at reliability features, but lacks details on behavioral traits, error formats, or output expectations. With no output schema, the description should ideally mention what's returned (e.g., success counts, error reports), but it doesn't, leaving gaps for a mutation tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all four parameters thoroughly. The description doesn't add any parameter-specific details beyond what's in the schema (e.g., it doesn't clarify the structure of 'updates' or examples of metadata fields). Baseline 3 is appropriate when the schema does the heavy lifting, though the description could have enhanced semantics for complex parameters like 'updates.'

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Update SEO metadata for multiple posts' specifies both the action (update) and resource (SEO metadata for posts). It distinguishes from siblings like wp_update_post (general post updates) and wp_seo_generate_metadata (generation vs. update). However, it doesn't explicitly differentiate from wp_seo_analyze_content or wp_seo_suggest_internal_links, which are related but distinct SEO operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when bulk updates are preferable over individual updates (e.g., wp_update_post), nor does it reference related SEO tools like wp_seo_generate_metadata for creation versus update scenarios. The phrase 'with progress tracking and error handling' hints at use cases requiring reliability, but this is implicit rather than explicit guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/docdyhr/mcp-wordpress'

If you have feedback or need assistance with the MCP directory API, please join our Discord server