Skip to main content
Glama

wp_performance_history

Retrieve historical performance data and trends for WordPress sites to monitor response times, cache efficiency, error rates, and resource usage over selected time periods.

Instructions

Get historical performance data and trends

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoSpecific site ID for multi-site setups (optional for single site)
timeframeNoTime period for historical data (1h, 6h, 12h, 24h, 7d)
metricsNoSpecific metrics to include (responseTime, cacheHitRate, errorRate, memoryUsage, requestVolume)
includeTrendsNoInclude trend analysis (default: true)

Implementation Reference

  • Tool registration definition in PerformanceTools.getTools(), specifying name, description, input parameters schema, and binding to the handler method.
    { name: "wp_performance_history", description: "Get historical performance data and trends", parameters: [ { name: "site", type: "string", description: "Specific site ID for multi-site setups (optional for single site)", required: false, }, { name: "timeframe", type: "string", description: "Time period for historical data (1h, 6h, 12h, 24h, 7d)", required: false, }, { name: "metrics", type: "array", description: "Specific metrics to include (responseTime, cacheHitRate, errorRate, memoryUsage, requestVolume)", required: false, }, { name: "includeTrends", type: "boolean", description: "Include trend analysis (default: true)", required: false, }, ], handler: this.getPerformanceHistory.bind(this), },
  • The primary handler function that executes the tool's logic: parses parameters, retrieves historical data, optionally analyzes trends, processes chart data, computes averages, and formats the response.
    /** * Get historical performance data and trends */ private async getPerformanceHistory(_client: WordPressClient, params: Record<string, unknown>): Promise<unknown> { return toolWrapper(async () => { const { site, timeframe = "24h", metrics: requestedMetrics, includeTrends = true, } = params as { site?: string; timeframe?: string; metrics?: string[]; includeTrends?: boolean; }; // Convert timeframe to milliseconds const timeframMs = parseTimeframe(timeframe); const startTime = Date.now() - timeframMs; // Get historical data const historicalData = this.monitor.getHistoricalData(startTime); // Analyze trends if requested let trends = null; if (includeTrends) { // Add current data for trend analysis this.analytics.addDataPoint(this.collector.collectCurrentMetrics()); trends = this.analytics.analyzeTrends(); // Filter trends by requested metrics if (requestedMetrics && Array.isArray(requestedMetrics)) { trends = trends.filter((trend) => requestedMetrics.includes(trend.metric)); } } // Process historical data for charting const chartData = processHistoricalDataForChart(historicalData, requestedMetrics as string[] | undefined); return { success: true, data: { timeframe, dataPoints: historicalData.length, historicalData: chartData, trends: trends || [], summary: { averageResponseTime: calculateAverage(historicalData.map((d) => d.requests.averageResponseTime)), averageCacheHitRate: calculateAverage(historicalData.map((d) => d.cache.hitRate)), averageErrorRate: calculateAverage( historicalData.map((d) => (d.requests.total > 0 ? d.requests.failed / d.requests.total : 0)), ), totalRequests: historicalData.reduce((sum, d) => sum + d.requests.total, 0), }, metadata: { timestamp: new Date().toISOString(), site: site || "all", requestedMetrics: requestedMetrics || ["all"], }, }, }; }); }
  • Helper function to convert timeframe strings (e.g., '24h') to milliseconds, used in the handler to determine the historical data range.
    export function parseTimeframe(timeframe: string): number { const map: Record<string, number> = { "1h": 60 * 60 * 1000, "6h": 6 * 60 * 60 * 1000, "12h": 12 * 60 * 60 * 1000, "24h": 24 * 60 * 60 * 1000, "7d": 7 * 24 * 60 * 60 * 1000, "30d": 30 * 24 * 60 * 60 * 1000, }; return map[timeframe] || map["24h"]; }
  • Helper function to transform raw historical metrics data into a chart-ready format with timestamped values for specified metrics.
    export function processHistoricalDataForChart( data: PerformanceMetrics[], requestedMetrics?: string[], ): Record<string, unknown> { if (!data.length) return {}; const allMetrics = ["responseTime", "cacheHitRate", "errorRate", "memoryUsage", "requestVolume"]; const metricsToProcess = requestedMetrics || allMetrics; const result: Record<string, unknown> = {}; for (const metric of metricsToProcess) { result[metric] = data.map((point, index) => ({ timestamp: point.system.uptime, value: extractMetricValue(point, metric), index, })); } return result; }
  • Global tool registry handles special instantiation of PerformanceTools class with WordPress clients map, as it requires client metrics for monitoring.
    if (ToolClass.name === "CacheTools" || ToolClass.name === "PerformanceTools") { toolInstance = new ToolClass(this.wordpressClients);

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