Skip to main content
Glama

wp_seo_validate_schema

Validate JSON-LD schema markup for correctness and compliance with SEO standards to improve search engine visibility.

Instructions

Validate JSON-LD schema markup for correctness and compliance

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoSite identifier for multi-site setups
schemaYesJSON-LD schema object to validate
schemaTypeNoExpected schema type for validation
useGoogleValidatorNoUse Google's Rich Results Test API for validation

Implementation Reference

  • The primary MCP handler function for the wp_seo_validate_schema tool. It processes input arguments, constructs parameters, and delegates execution to the SEOTools instance's validateSchema method.
    export async function handleValidateSchema(client: WordPressClient, args: Record<string, unknown>): Promise<unknown> { const logger = LoggerFactory.tool("wp_seo_validate_schema"); try { const seoTools = getSEOToolsInstance(); const params: SEOToolParams = { schema: args.schema, schemaType: args.schemaType as SchemaType, site: args.site as string, }; // Add Google validator flag if provided if (args.useGoogleValidator) { params.useGoogleValidator = args.useGoogleValidator as boolean; } return await seoTools.validateSchema(params); } catch (error) { logger.error("Failed to validate schema", { error, args }); throw error; } }
  • Tool definition including name, description, and input schema for the wp_seo_validate_schema tool, used for MCP registration.
    export const validateSchemaTool: Tool = { name: "wp_seo_validate_schema", description: "Validate JSON-LD schema markup for correctness and compliance", inputSchema: { type: "object", properties: { schema: { type: "object", description: "JSON-LD schema object to validate", }, schemaType: { type: "string", description: "Expected schema type for validation", }, useGoogleValidator: { type: "boolean", description: "Use Google's Rich Results Test API for validation", }, site: { type: "string", description: "Site identifier for multi-site setups", }, }, required: ["schema"], }, };
  • Handler mapping function that associates the tool name 'wp_seo_validate_schema' with its handler function handleValidateSchema. 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 implementation method in SEOTools class that performs the schema validation logic, including caching, error handling, and delegation to performSchemaValidation.
    async validateSchema(params: SEOToolParams): Promise<unknown> { const siteLogger = LoggerFactory.tool("wp_seo_validate_schema", params.site); return await siteLogger.time("Validate schema markup", async () => { try { validateRequired(params, ["schema"]); // Implementation will be added in validators const validation = await this.performSchemaValidation(params); return validation; } catch (_error) { handleToolError(_error, "validate schema", { site: params.site, }); throw _error; } }); }
  • Private helper method that executes the actual schema validation using SchemaGenerator and formats the response.
    private async performSchemaValidation(params: SEOToolParams): Promise<unknown> { if (!params.schema) { throw new Error("Schema markup is required for validation"); } // Basic validation using the SchemaGenerator's validation method const validation = this.schemaGenerator.validateSchema(params.schema as SchemaMarkup); return { valid: validation.valid, errors: validation.errors, warnings: [], // Could add warnings for best practices schemaType: (params.schema as SchemaMarkup)["@type"], validatedAt: new Date().toISOString(), }; }

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