Skip to main content
Glama

wp_performance_alerts

Monitor WordPress site performance issues and detect anomalies by retrieving alerts filtered by severity, category, and site ID for proactive management.

Instructions

Get performance alerts and anomaly detection results

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoSpecific site ID for multi-site setups (optional for single site)
severityNoFilter alerts by severity level (info, warning, error, critical)
categoryNoFilter alerts by category (performance, cache, system, wordpress)
limitNoMaximum number of alerts to return (default: 20)
includeAnomaliesNoInclude detected anomalies (default: true)

Implementation Reference

  • Core execution logic for wp_performance_alerts tool. Fetches and filters alerts/anomalies from monitoring systems, applies formatting and summarization using helpers, and structures the response.
    private async getPerformanceAlerts(_client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
      return toolWrapper(async () => {
        const {
          site,
          severity,
          category,
          limit = 20,
          includeAnomalies = true,
        } = params as {
          site?: string;
          severity?: string;
          category?: string;
          limit?: number;
          includeAnomalies?: boolean;
        };
    
        // Get alerts from monitor
        let alerts = this.monitor.getAlerts(severity) as PerformanceAlert[];
    
        // Filter by category if specified
        if (category) {
          alerts = alerts.filter((alert) => alert.category === category);
        }
    
        // Limit results
        alerts = alerts.slice(-(limit as number));
    
        // Get anomalies if requested
        let anomalies: PerformanceAnomaly[] = [];
        if (includeAnomalies) {
          anomalies = this.analytics.getAnomalies(severity) as PerformanceAnomaly[];
        }
    
        // Calculate alert summary
        const alertSummary = {
          total: alerts.length,
          critical: alerts.filter((a) => a.severity === "critical").length,
          error: alerts.filter((a) => a.severity === "error").length,
          warning: alerts.filter((a) => a.severity === "warning").length,
          info: alerts.filter((a) => a.severity === "info").length,
        };
    
        const anomalySummary = {
          total: anomalies.length,
          critical: anomalies.filter((a) => a.severity === "critical").length,
          major: anomalies.filter((a) => a.severity === "major").length,
          moderate: anomalies.filter((a) => a.severity === "moderate").length,
          minor: anomalies.filter((a) => a.severity === "minor").length,
        };
    
        return {
          success: true,
          data: {
            alerts: alerts.map((alert) => ({
              ...alert,
              timestamp: new Date(alert.timestamp).toISOString(),
              formattedMessage: formatAlertMessage(alert),
            })),
            anomalies: anomalies.map((anomaly) => ({
              ...anomaly,
              timestamp: new Date(anomaly.timestamp).toISOString(),
              formattedDescription: formatAnomalyDescription(anomaly),
            })),
            summary: {
              alerts: alertSummary,
              anomalies: anomalySummary,
              overallStatus: calculateAlertStatus(alertSummary, anomalySummary),
            },
            metadata: {
              timestamp: new Date().toISOString(),
              filters: { severity, category, site: site || "all" },
              limit,
            },
          },
        };
      });
    }
  • Tool definition including name, description, input parameters schema, and handler binding.
    {
      name: "wp_performance_alerts",
      description: "Get performance alerts and anomaly detection results",
      parameters: [
        {
          name: "site",
          type: "string",
          description: "Specific site ID for multi-site setups (optional for single site)",
          required: false,
        },
        {
          name: "severity",
          type: "string",
          description: "Filter alerts by severity level (info, warning, error, critical)",
          required: false,
        },
        {
          name: "category",
          type: "string",
          description: "Filter alerts by category (performance, cache, system, wordpress)",
          required: false,
        },
        {
          name: "limit",
          type: "number",
          description: "Maximum number of alerts to return (default: 20)",
          required: false,
        },
        {
          name: "includeAnomalies",
          type: "boolean",
          description: "Include detected anomalies (default: true)",
          required: false,
        },
      ],
      handler: this.getPerformanceAlerts.bind(this),
    },
  • ToolRegistry instantiates PerformanceTools class (providing wp_performance_alerts) with WordPress clients map and registers all returned tools 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);
      });
    });
  • Helper functions used exclusively in the wp_performance_alerts handler for formatting alerts/anomalies and computing overall status.
    /**
     * Format alert message
     */
    export function formatAlertMessage(alert: PerformanceAlert): string {
      return `${alert.severity.toUpperCase()}: ${alert.message} (${alert.metric}: ${alert.actualValue} vs threshold: ${alert.threshold})`;
    }
    
    /**
     * Format anomaly description
     */
    export function formatAnomalyDescription(anomaly: PerformanceAnomaly): string {
      const direction = anomaly.actualValue > anomaly.expectedValue ? "higher" : "lower";
      return `${anomaly.metric} is ${Math.abs(anomaly.deviation).toFixed(1)}% ${direction} than expected (${anomaly.expectedValue.toFixed(2)} vs ${anomaly.actualValue.toFixed(2)})`;
    }
    
    /**
     * Calculate alert status from summaries
     */
    export function calculateAlertStatus(
      alertSummary: { critical: number; error: number; warning: number },
      anomalySummary: {
        critical: number;
        major: number;
        moderate: number;
        minor: number;
      },
    ): string {
      const critical = alertSummary.critical + anomalySummary.critical;
      const high = alertSummary.error + anomalySummary.major;
    
      if (critical > 0) return "Critical Issues Detected";
      if (high > 2) return "High Priority Issues";
      if (alertSummary.warning + anomalySummary.moderate > 5) return "Performance Warnings";
      return "System Healthy";
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Get' implies a read-only operation, the description doesn't specify whether this requires authentication, has rate limits, returns paginated results, or what format the output takes. For a tool with 5 parameters and no output schema, this lack of behavioral context is a significant gap.

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 extremely concise—a single sentence with no wasted words. It's front-loaded with the core purpose ('Get performance alerts and anomaly detection results'), making it easy to parse. Every word earns its place, and there's no redundancy or unnecessary elaboration.

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 the tool's complexity (5 parameters, no output schema, no annotations), the description is incomplete. It doesn't address what the tool returns, how results are structured, or any behavioral traits like error handling. For a data retrieval tool with filtering options, more context is needed to help the agent understand the output and usage nuances.

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?

The input schema has 100% description coverage, so all parameters are documented in the schema itself. The description doesn't add any meaning beyond what's in the schema—it doesn't explain parameter interactions, default behaviors, or provide examples. With high schema coverage, the baseline score of 3 is appropriate as 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 performance alerts and anomaly detection results'. It specifies the verb ('Get') and resource ('performance alerts and anomaly detection results'), making the function unambiguous. However, it doesn't distinguish this tool from its sibling performance tools like 'wp_performance_stats' or 'wp_performance_history', which prevents a perfect score.

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. With multiple sibling tools related to performance (e.g., 'wp_performance_stats', 'wp_performance_history'), there's no indication of whether this tool is for real-time alerts, historical data, or specific use cases. The absence of any context or exclusions leaves the agent without usage direction.

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