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);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. 'Get historical performance data and trends' implies a read-only operation but doesn't disclose important behavioral traits: whether authentication is required, rate limits, data freshness, format of returned data (e.g., time-series), or what 'trends' specifically entails. For a tool with 4 parameters and no output schema, this leaves significant gaps.

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: 'Get historical performance data and trends.' It's front-loaded with the core purpose, has zero wasted words, and appropriately sized for a tool with clear parameters documented elsewhere.

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 4 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what 'historical performance data' includes (e.g., aggregated metrics, raw logs), how trends are calculated, or the format of returned data. For a tool that likely returns complex time-series data, this leaves the agent guessing about output structure and usage.

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 already documents all 4 parameters thoroughly with descriptions and constraints (e.g., timeframe options, metrics list). The description adds no additional parameter semantics beyond what's in the schema, maintaining the baseline score of 3 where 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 tool's purpose: 'Get historical performance data and trends' specifies the verb ('Get') and resource ('historical performance data and trends'). It distinguishes from most sibling tools (which are CRUD operations for content, users, etc.) but doesn't explicitly differentiate from other performance-related siblings like wp_performance_stats or wp_performance_alerts.

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 sibling tools like wp_performance_stats (which might provide current stats) or wp_performance_alerts (which might focus on alert conditions), nor does it specify prerequisites or appropriate contexts for retrieving historical data versus other performance metrics.

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