wp_seo_site_audit
Analyze WordPress site SEO with technical, content, and performance audits to identify optimization opportunities and improve search visibility.
Instructions
Perform comprehensive SEO audit of the WordPress site including technical, content, and performance analysis
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| site | No | Site identifier for multi-site setups | |
| auditType | No | Type of audit to perform (default: full) | |
| maxPages | No | Maximum number of pages to audit (default: 100) | |
| includeExternalLinks | No | Include external link validation in audit | |
| force | No | Force refresh, bypassing cached audit results |
Implementation Reference
- src/tools/seo/SEOHandlers.ts:193-217 (handler)Primary MCP handler function that processes tool invocation parameters and delegates to the core SEOTools.performSiteAudit method.export async function handlePerformSiteAudit(client: WordPressClient, args: Record<string, unknown>): Promise<unknown> { const logger = LoggerFactory.tool("wp_seo_site_audit"); try { const seoTools = getSEOToolsInstance(); const params: SEOToolParams = { auditType: args.auditType as "content" | "performance" | "full" | "technical", force: args.force as boolean, site: args.site as string, }; // Add optional parameters if (args.maxPages) { params.maxPages = args.maxPages as number; } if (args.includeExternalLinks) { params.includeExternalLinks = args.includeExternalLinks as boolean; } return await seoTools.performSiteAudit(params); } catch (error) { logger.error("Failed to perform site audit", { error, args }); throw error; } }
- Tool schema definition including name, description, and input schema validation for wp_seo_site_audit.export const performSiteAuditTool: Tool = { name: "wp_seo_site_audit", description: "Perform comprehensive SEO audit of the WordPress site including technical, content, and performance analysis", inputSchema: { type: "object", properties: { auditType: { type: "string", enum: ["technical", "content", "performance", "full"], description: "Type of audit to perform (default: full)", }, maxPages: { type: "number", description: "Maximum number of pages to audit (default: 100)", }, includeExternalLinks: { type: "boolean", description: "Include external link validation in audit", }, force: { type: "boolean", description: "Force refresh, bypassing cached audit results", }, site: { type: "string", description: "Site identifier for multi-site setups", }, }, required: [], }, };
- src/tools/seo/SEOTools.ts:378-399 (registration)Tool registration mapping that associates 'wp_seo_site_audit' with its handler function handlePerformSiteAudit within the getHandlerForTool method used by getTools().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}`); }) ); }
- src/tools/seo/SEOTools.ts:328-357 (helper)Core helper method in SEOTools class that manages caching, client retrieval, and delegates the actual audit execution to SiteAuditor.async performSiteAudit(params: SEOToolParams): Promise<SiteAuditResult> { const siteLogger = LoggerFactory.tool("wp_seo_site_audit", params.site); return await siteLogger.time("Perform site audit", async () => { try { const client = this.getSiteClient(params.site); // Cache key for audit results (1 hour TTL) const cacheKey = `seo:audit:${params.site}:${params.auditType || "full"}`; const cached = await this.getCachedResult(cacheKey); if (cached && (!params.force as boolean)) { return cached as SiteAuditResult; } // Perform audit (implementation will be added) const audit = await this.executeSiteAudit(client, params); // Cache for 1 hour await this.cacheResult(cacheKey, audit, 3600); return audit; } catch (_error) { handleToolError(_error, "perform site audit", { site: params.site, auditType: params.auditType, }); throw _error; } }); }
- Main audit execution logic in SiteAuditor class that orchestrates technical, content, architecture, performance, and accessibility audits, collects issues, calculates scores, and generates recommendations.async performSiteAudit(params: SEOToolParams): Promise<SiteAuditResult> { this.logger.info("Starting comprehensive site audit", { site: params.site, auditScope: { technical: this.config.includeTechnical, content: this.config.includeContent, architecture: this.config.includeArchitecture, performance: this.config.includePerformance, accessibility: this.config.includeAccessibility, }, }); const startTime = Date.now(); const issues: AuditIssue[] = []; const sections: AuditSection[] = []; const recommendations: string[] = []; try { // Get site data const siteData = await this.collectSiteData(params); // Technical SEO audit if (this.config.includeTechnical) { const technicalResults = await this.auditTechnicalSEO(siteData, params); sections.push(technicalResults.section); issues.push(...technicalResults.issues); if (this.config.includeRecommendations) { recommendations.push(...technicalResults.recommendations); } } // Content quality audit if (this.config.includeContent) { const contentResults = await this.auditContentQuality(siteData, params); sections.push(contentResults.section); issues.push(...contentResults.issues); if (this.config.includeRecommendations) { recommendations.push(...contentResults.recommendations); } } // Site architecture audit if (this.config.includeArchitecture) { const architectureResults = await this.auditSiteArchitecture(siteData, params); sections.push(architectureResults.section); issues.push(...architectureResults.issues); if (this.config.includeRecommendations) { recommendations.push(...architectureResults.recommendations); } } // Performance audit if (this.config.includePerformance) { const performanceResults = await this.auditPerformance(siteData, params); sections.push(performanceResults.section); issues.push(...performanceResults.issues); if (this.config.includeRecommendations) { recommendations.push(...performanceResults.recommendations); } } // Accessibility audit if (this.config.includeAccessibility) { const accessibilityResults = await this.auditAccessibility(siteData, params); sections.push(accessibilityResults.section); issues.push(...accessibilityResults.issues); if (this.config.includeRecommendations) { recommendations.push(...accessibilityResults.recommendations); } } // Filter issues by severity const filteredIssues = this.filterIssuesBySeverity(issues); // Calculate overall score const overallScore = this.calculateOverallScore(sections, filteredIssues); const auditResult: SiteAuditResult = { timestamp: new Date().toISOString(), siteUrl: siteData.siteUrl, overallScore, sections, issues: filteredIssues, recommendations: this.config.includeRecommendations ? recommendations : [], summary: this.generateAuditSummary(sections, filteredIssues), processingTime: Date.now() - startTime, }; this.logger.info("Site audit completed", { overallScore, totalIssues: filteredIssues.length, criticalIssues: filteredIssues.filter((i) => i.severity === IssueSeverity.CRITICAL).length, processingTime: auditResult.processingTime, }); return auditResult; } catch (_error) { this.logger.error("Site audit failed", { _error: _error instanceof Error ? _error.message : String(_error), }); throw _error; } }