Skip to main content
Glama

wp_cache_stats

Retrieve cache statistics for WordPress sites to monitor performance and optimize speed by analyzing cache hit rates and memory usage.

Instructions

Get cache statistics for a WordPress site.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoSite ID to get cache stats for. If not provided, uses default site or fails if multiple sites configured.

Implementation Reference

  • The handler function that implements the core logic of the wp_cache_stats tool. It resolves the WordPress client for the given site, checks if caching is enabled, retrieves cache statistics from the CachedWordPressClient, and formats the response with hit/miss rates, total entries, evictions, and invalidation stats.
    async handleGetCacheStats(params: { site?: string }) {
      return toolWrapper(async () => {
        const client = this.resolveClient(params.site);
    
        if (!(client instanceof CachedWordPressClient)) {
          return {
            caching_enabled: false,
            message: "Caching is disabled for this site. Set DISABLE_CACHE=false to enable caching.",
          };
        }
    
        const stats = client.getCacheStats();
    
        return {
          caching_enabled: true,
          cache_stats: {
            hits: stats.cache.hits,
            misses: stats.cache.misses,
            hit_rate: Math.round(stats.cache.hitRate * 100) + "%",
            total_entries: stats.cache.totalSize,
            evictions: stats.cache.evictions,
          },
          invalidation_stats: {
            queue_size: stats.invalidation.queueSize,
            rules_count: stats.invalidation.rulesCount,
            processing: stats.invalidation.processing,
          },
        };
      });
    }
  • The tool definition object within CacheTools.getTools() that registers the wp_cache_stats tool, including name, description, input parameters (site), and binding to the handler method.
    {
      name: "wp_cache_stats",
      description: "Get cache statistics for a WordPress site.",
      parameters: [
        {
          name: "site",
          type: "string",
          description:
            "Site ID to get cache stats for. If not provided, uses default site or fails if multiple sites configured.",
        },
      ],
      handler: this.handleGetCacheStats.bind(this),
    },
  • The registration logic in ToolRegistry that instantiates CacheTools with the WordPress clients map and registers all tools returned by getTools(), including wp_cache_stats.
    public registerAllTools(): void {
      // Register all tools from the tools directory
      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);
        });
      });
    }
  • The input schema definition for the wp_cache_stats tool, specifying the optional 'site' parameter.
    parameters: [
      {
        name: "site",
        type: "string",
        description:
          "Site ID to get cache stats for. If not provided, uses default site or fails if multiple sites configured.",
      },
    ],
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. It states the tool 'gets' data, implying a read-only operation, but doesn't specify permissions, rate limits, or what happens if the site parameter is omitted (e.g., fails or uses a default). This leaves gaps in understanding the tool's behavior.

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, clear sentence that directly states the tool's purpose without unnecessary words. It's front-loaded and efficiently communicates the core function, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (one optional parameter) and high schema coverage, the description is minimally adequate. However, with no annotations and no output schema, it lacks details on behavioral traits and return values, which could hinder the agent's ability to use it effectively in all contexts.

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, with the 'site' parameter fully documented in the schema itself. The description doesn't add any extra meaning beyond what's in the schema, so it meets the baseline score of 3 for high schema coverage without compensating value.

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 action ('Get') and resource ('cache statistics for a WordPress site'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'wp_cache_info' or 'wp_performance_stats', which might provide similar or overlapping functionality, so it doesn't reach the highest 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 siblings like 'wp_cache_info' and 'wp_performance_stats' available, there's no indication of how this tool differs or when it should be preferred, leaving the agent to guess based on names alone.

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