Skip to main content
Glama

wp_seo_generate_metadata

Generate SEO-optimized metadata for WordPress posts including title tags, meta descriptions, OpenGraph, and Twitter Card data to improve search visibility.

Instructions

Generate SEO-optimized metadata including title tags, meta descriptions, OpenGraph, and Twitter Card data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoSite identifier for multi-site setups
postIdYesWordPress post ID
titleNoCustom title to optimize (optional, uses post title if not provided)
descriptionNoCustom description to optimize (optional, uses excerpt if not provided)
focusKeywordNoPrimary keyword to include in metadata

Implementation Reference

  • MCP handler function that executes the wp_seo_generate_metadata tool logic by extracting parameters from args and delegating to SEOTools.generateMetadata
    export async function handleGenerateMetadata(client: WordPressClient, args: Record<string, unknown>): Promise<unknown> {
      const logger = LoggerFactory.tool("wp_seo_generate_metadata");
    
      try {
        const seoTools = getSEOToolsInstance();
        const params: SEOToolParams = {
          postId: args.postId as number,
          site: args.site as string,
        };
    
        // Add custom title/description if provided
        if (args.title) {
          params.title = args.title as string;
        }
        if (args.description) {
          params.description = args.description as string;
        }
        if (args.focusKeyword) {
          params.focusKeywords = [args.focusKeyword as string];
        }
    
        return await seoTools.generateMetadata(params);
      } catch (error) {
        logger.error("Failed to generate metadata", { error, args });
        throw error;
      }
    }
  • Input schema and definition for the wp_seo_generate_metadata tool
    export const generateMetadataTool: Tool = {
      name: "wp_seo_generate_metadata",
      description:
        "Generate SEO-optimized metadata including title tags, meta descriptions, OpenGraph, and Twitter Card data",
      inputSchema: {
        type: "object",
        properties: {
          postId: {
            type: "number",
            description: "WordPress post ID",
          },
          title: {
            type: "string",
            description: "Custom title to optimize (optional, uses post title if not provided)",
          },
          description: {
            type: "string",
            description: "Custom description to optimize (optional, uses excerpt if not provided)",
          },
          focusKeyword: {
            type: "string",
            description: "Primary keyword to include in metadata",
          },
          site: {
            type: "string",
            description: "Site identifier for multi-site setups",
          },
        },
        required: ["postId"],
      },
    };
  • Registration mapping in getHandlerForTool that associates 'wp_seo_generate_metadata' with handleGenerateMetadata handler. Used by getTools() for MCP tool registration.
    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 generateMetadata method in SEOTools class that orchestrates metadata generation by calling createMetadata (which uses MetaGenerator).
    async generateMetadata(params: SEOToolParams): Promise<SEOMetadata> {
      const siteLogger = LoggerFactory.tool("wp_seo_generate_meta", params.site);
    
      return await siteLogger.time("Generate SEO metadata", async () => {
        try {
          validateRequired(params, ["postId"]);
          const client = this.getSiteClient(params.site);
    
          // Implementation will be added in generators
          const metadata = await this.createMetadata(client, params);
    
          return metadata;
        } catch (_error) {
          handleToolError(_error, "generate metadata", {
            site: params.site,
            postId: params.postId as number,
          });
          throw _error;
        }
      });
    }
  • The core implementation logic in MetaGenerator.generateMetadata that generates title, description, OpenGraph, Twitter Card, applies safety filters, and validates the SEO metadata.
    async generateMetadata(
      post: WordPressPost,
      params: SEOToolParams,
      options: MetaGenerationOptions = {},
    ): Promise<SEOMetadata> {
      const siteLogger = LoggerFactory.tool("seo_generate_metadata", params.site);
    
      return await siteLogger.time("Generate SEO metadata", async () => {
        // Extract content for analysis
        const content = this.extractPostContent(post);
        const focusKeyword = params.focusKeywords?.[0] || "";
    
        // Generate title tag
        const title = await this.generateTitle(post, content, focusKeyword, options);
    
        // Generate meta description
        const description = await this.generateDescription(post, content, focusKeyword, options);
    
        // Generate OpenGraph metadata
        const openGraph = await this.generateOpenGraph(post, title, description, options);
    
        // Generate Twitter Card metadata
        const twitterCard = await this.generateTwitterCard(post, title, description, options);
    
        // Create canonical URL
        const canonical = this.generateCanonicalUrl(post);
    
        // Set robots directives
        const robots = this.generateRobotsDirectives(post, options);
    
        const metadata: SEOMetadata = {
          title,
          description,
        };
    
        if (focusKeyword) {
          metadata.focusKeyword = focusKeyword;
        }
    
        if (canonical) {
          metadata.canonical = canonical;
        }
    
        if (robots) {
          metadata.robots = robots;
        }
    
        if (openGraph) {
          metadata.openGraph = openGraph;
        }
    
        if (twitterCard) {
          metadata.twitterCard = twitterCard;
        }
    
        // Apply safety filters
        this.applySafetyFilters(metadata);
    
        // Re-optimize description length after safety filters may have shortened it
        metadata.description = this.optimizeDescriptionLength(metadata.description);
    
        // Validate required fields
        this.validateMetadata(metadata);
    
        siteLogger.info("Generated SEO metadata", {
          titleLength: title.length,
          descriptionLength: description.length,
          hasOpenGraph: Boolean(openGraph),
          hasTwitterCard: Boolean(twitterCard),
          focusKeyword,
        });
    
        return metadata;
      });
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool 'generates' metadata, implying a read-only or computational operation, but doesn't clarify if this creates, updates, or just returns suggestions. It lacks details on permissions needed, rate limits, side effects, or output format, which is insufficient for a tool with potential write implications in a CMS context.

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 ('Generate SEO-optimized metadata') and lists key components without unnecessary words. Every element earns its place, 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.

Completeness2/5

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

Given the complexity of SEO operations and the lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., suggestions vs. applied changes), potential errors, or how it interacts with WordPress posts. For a tool with 5 parameters in a content management system, more behavioral and output context is needed.

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?

The description doesn't add any parameter-specific information beyond what's already in the schema, which has 100% coverage with clear descriptions for all 5 parameters. The baseline score of 3 is appropriate since the schema fully documents parameters like postId, focusKeyword, and optional fields, and the description doesn't compensate with additional context or examples.

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: 'Generate SEO-optimized metadata' with specific components listed (title tags, meta descriptions, OpenGraph, Twitter Card data). It uses a specific verb ('Generate') and identifies the resource ('metadata'), but doesn't explicitly differentiate from sibling SEO tools like wp_seo_analyze_content or wp_seo_bulk_update_metadata, which prevents a perfect score.

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 to choose this over wp_seo_bulk_update_metadata for batch operations or wp_seo_analyze_content for analysis. There's no context about prerequisites, timing, or exclusions, leaving the agent with minimal usage direction.

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