Skip to main content
Glama

wp_seo_generate_schema

Generate JSON-LD structured data for WordPress posts to enhance search engine visibility and rich results display.

Instructions

Generate JSON-LD structured data schema for enhanced search results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoSite identifier for multi-site setups
postIdYesWordPress post ID
schemaTypeYesType of schema.org structured data to generate
customDataNoAdditional custom data for the schema

Implementation Reference

  • Defines the Tool object for 'wp_seo_generate_schema' including name, description, and input schema validation.
    export const generateSchemaTool: Tool = {
      name: "wp_seo_generate_schema",
      description: "Generate JSON-LD structured data schema for enhanced search results",
      inputSchema: {
        type: "object",
        properties: {
          postId: {
            type: "number",
            description: "WordPress post ID",
          },
          schemaType: {
            type: "string",
            enum: [
              "Article",
              "Product",
              "FAQ",
              "HowTo",
              "Organization",
              "Website",
              "BreadcrumbList",
              "Event",
              "Recipe",
              "Course",
              "LocalBusiness",
              "Person",
              "Review",
              "VideoObject",
            ],
            description: "Type of schema.org structured data to generate",
          },
          customData: {
            type: "object",
            description: "Additional custom data for the schema",
          },
          site: {
            type: "string",
            description: "Site identifier for multi-site setups",
          },
        },
        required: ["postId", "schemaType"],
      },
    };
  • MCP handler function that extracts parameters from args and delegates to SEOTools.generateSchema.
    export async function handleGenerateSchema(client: WordPressClient, args: Record<string, unknown>): Promise<unknown> {
      const logger = LoggerFactory.tool("wp_seo_generate_schema");
    
      try {
        const seoTools = getSEOToolsInstance();
        const params: SEOToolParams = {
          postId: args.postId as number,
          schemaType: args.schemaType as SchemaType,
          site: args.site as string,
        };
    
        // Add custom data if provided
        if (args.customData) {
          params.customData = args.customData;
        }
    
        return await seoTools.generateSchema(params);
      } catch (error) {
        logger.error("Failed to generate schema", { error, args });
        throw error;
      }
  • Maps tool name 'wp_seo_generate_schema' to its handler function handleGenerateSchema in getHandlerForTool method, used by getTools() for MCP 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 business logic for generating schema: handles caching, fetches post, calls SchemaGenerator via createSchema.
    async generateSchema(params: SEOToolParams): Promise<SchemaMarkup> {
      const siteLogger = LoggerFactory.tool("wp_seo_generate_schema", params.site);
    
      return await siteLogger.time("Generate schema markup", async () => {
        try {
          validateRequired(params, ["postId", "schemaType"]);
          const client = this.getSiteClient(params.site);
    
          // Check cache
          const cacheKey = `seo:schema:${params.site}:${params.postId as number}:${params.schemaType}`;
          const cached = await this.getCachedResult(cacheKey);
          if (cached) {
            return cached as SchemaMarkup;
          }
    
          // Generate schema (implementation in generators)
          const schema = await this.createSchema(client, params);
    
          // Cache for 24 hours
          await this.cacheResult(cacheKey, schema, 86400);
    
          return schema;
        } catch (_error) {
          handleToolError(_error, "generate schema", {
            site: params.site,
            postId: params.postId as number,
            schemaType: params.schemaType,
          });
          throw _error;
        }
      });
    }
  • Exact implementation: Generates JSON-LD schema markup based on schemaType using switch statement dispatching to type-specific generators and content extraction helpers.
    async generateSchema(post: WordPressPost, params: SEOToolParams, options: SchemaOptions = {}): Promise<SchemaMarkup> {
      this.logger.debug("Generating schema markup", {
        postId: post.id,
        schemaType: params.schemaType,
        title: post.title?.rendered?.substring(0, 50),
      });
    
      if (!params.schemaType) {
        throw new Error("Schema type is required for schema generation");
      }
    
      const baseSchema: SchemaMarkup = {
        "@context": "https://schema.org",
        "@type": params.schemaType,
      };
    
      // Generate schema based on type
      switch (params.schemaType) {
        case "Article":
          return this.generateArticleSchema(post, baseSchema, options);
    
        case "Product":
          return this.generateProductSchema(post, baseSchema, options);
    
        case "FAQ":
          return this.generateFAQSchema(post, baseSchema, options);
    
        case "HowTo":
          return this.generateHowToSchema(post, baseSchema, options);
    
        case "Organization":
          return this.generateOrganizationSchema(post, baseSchema, options);
    
        case "LocalBusiness":
          return this.generateLocalBusinessSchema(post, baseSchema, options);
    
        case "Website":
          return this.generateWebsiteSchema(post, baseSchema, options);
    
        case "BreadcrumbList":
          return this.generateBreadcrumbSchema(post, baseSchema, options);
    
        case "Event":
          return this.generateEventSchema(post, baseSchema, options);
    
        case "Recipe":
          return this.generateRecipeSchema(post, baseSchema, options);
    
        case "Course":
          return this.generateCourseSchema(post, baseSchema, options);
    
        case "VideoObject":
          return this.generateVideoSchema(post, baseSchema, options);
    
        case "Person":
          return this.generatePersonSchema(post, baseSchema, options);
    
        case "Review":
          return this.generateReviewSchema(post, baseSchema, options);
    
        default:
          throw new Error(`Unsupported schema type: ${params.schemaType}`);
      }
    }
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 states the tool generates schema but doesn't describe what the generation entails (e.g., whether it creates/modifies data, requires specific permissions, has side effects like caching, or returns structured output). For a tool with potential write operations (implied by 'generate'), this lack of detail 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 action ('Generate JSON-LD structured data schema') and purpose ('for enhanced search results'). There's no wasted wording, and it directly communicates the tool's function without redundancy.

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 tool's complexity (4 parameters, nested objects, no output schema) and lack of annotations, the description is incomplete. It doesn't explain the output format (e.g., JSON-LD string), error conditions, or behavioral traits like idempotency. For a generation tool with potential side effects, more context is needed to guide effective use.

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 fully documents all parameters (site, postId, schemaType, customData) with descriptions and enum values. The description adds no additional parameter semantics beyond what's in the schema, such as explaining how 'customData' integrates or format examples. Baseline 3 is appropriate when the schema does the heavy lifting.

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 verb 'Generate' and the resource 'JSON-LD structured data schema', specifying it's for 'enhanced search results'. It distinguishes from sibling SEO tools like 'wp_seo_analyze_content' or 'wp_seo_validate_schema' by focusing on schema generation rather than analysis or validation. However, it doesn't explicitly mention WordPress context or differentiate from 'wp_seo_generate_metadata', which might be a related sibling.

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 prerequisites (e.g., needing a valid postId), compare to other schema-related tools like 'wp_seo_validate_schema', or specify use cases (e.g., for SEO optimization). The agent must infer usage from the tool name and parameters alone.

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