wp_performance_export
Export comprehensive WordPress performance reports with analytics, historical data, and customizable time ranges in JSON, CSV, or summary formats.
Instructions
Export comprehensive performance report
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| site | No | Specific site ID for multi-site setups (optional for single site) | |
| format | No | Export format (json, csv, summary) | |
| includeHistorical | No | Include historical data (default: true) | |
| includeAnalytics | No | Include analytics and insights (default: true) | |
| timeRange | No | Time range for data export (1h, 6h, 24h, 7d, 30d) |
Implementation Reference
- The core handler function for the 'wp_performance_export' tool. It collects current performance metrics, optional historical data and analytics, formats the report (JSON, CSV, or summary), and returns the export data.private async exportPerformanceReport(_client: WordPressClient, params: Record<string, unknown>): Promise<unknown> { return toolWrapper(async () => { const { site, format = "json", includeHistorical = true, includeAnalytics = true, timeRange = "24h", } = params as { site?: string; format?: string; includeHistorical?: boolean; includeAnalytics?: boolean; timeRange?: string; }; // Generate comprehensive analytics report const report = this.analytics.exportAnalyticsReport(); // Add additional data based on parameters const exportData: { currentMetrics: PerformanceMetrics; [key: string]: unknown; } = { metadata: { generatedAt: new Date().toISOString(), site: site || "all", timeRange, format, version: "1.0.0", }, summary: report.summary, currentMetrics: this.collector.collectCurrentMetrics(), }; if (includeHistorical) { const timeframMs = parseTimeframe(timeRange); const startTime = Date.now() - timeframMs; exportData.historicalData = this.monitor.getHistoricalData(startTime); } if (includeAnalytics) { exportData.analytics = { trends: report.trends, benchmarks: report.benchmarks, insights: report.insights, anomalies: report.anomalies, predictions: report.predictions, optimizationPlan: report.optimizationPlan, }; } // Add aggregated statistics exportData.aggregatedStats = { cache: this.collector.getAggregatedCacheStats(), client: this.collector.getAggregatedClientStats(), }; // Add site comparison if multi-site if (!site) { exportData.siteComparison = this.collector.compareSitePerformance(); } // Format output based on requested format let formattedOutput: unknown; if (format === "csv") { formattedOutput = convertToCSV(exportData); } else if (format === "summary") { formattedOutput = createSummaryReport(exportData); } else { formattedOutput = exportData; } return { success: true, data: formattedOutput, metadata: { timestamp: new Date().toISOString(), format, dataSize: JSON.stringify(exportData).length, site: site || "all", }, }; }); }
- src/tools/performance/PerformanceTools.ts:256-292 (registration)Tool registration in PerformanceTools.getTools(), defining name, description, input parameters schema, and binding to the exportPerformanceReport handler.{ name: "wp_performance_export", description: "Export comprehensive performance report", parameters: [ { name: "site", type: "string", description: "Specific site ID for multi-site setups (optional for single site)", required: false, }, { name: "format", type: "string", description: "Export format (json, csv, summary)", required: false, }, { name: "includeHistorical", type: "boolean", description: "Include historical data (default: true)", required: false, }, { name: "includeAnalytics", type: "boolean", description: "Include analytics and insights (default: true)", required: false, }, { name: "timeRange", type: "string", description: "Time range for data export (1h, 6h, 24h, 7d, 30d)", required: false, }, ], handler: this.exportPerformanceReport.bind(this), },
- src/server/ToolRegistry.ts:47-62 (registration)Higher-level registration in ToolRegistry.registerAllTools() where PerformanceTools class is instantiated and its tools (including wp_performance_export) are registered with the MCP server.Object.values(Tools).forEach((ToolClass) => { let toolInstance: { getTools(): unknown[] }; // Cache and Performance tools need the clients map if (ToolClass.name === "CacheTools" || ToolClass.name === "PerformanceTools") { toolInstance = new ToolClass(this.wordpressClients); } else { toolInstance = new (ToolClass as new () => { getTools(): unknown[] })(); } const tools = toolInstance.getTools(); tools.forEach((tool: unknown) => { this.registerTool(tool as ToolDefinition); }); });
- src/server/ToolRegistry.ts:94-97 (schema)The MCP server.tool() registration with Zod schema built from tool parameters, including site handling for multi-site.this.server.tool( tool.name, tool.description || `WordPress tool: ${tool.name}`, parameterSchema,