Skip to main content
Glama

get-stats-highlights

Retrieve key performance metrics for a WordPress site from the past seven days using site URL, username, password, and site ID for analysis and insights.

Instructions

Get highlight metrics for a WordPress site from the last seven days

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
passwordYesWordPress application password
siteIdYesWordPress site ID
siteUrlYesWordPress site URL
usernameYesWordPress username

Implementation Reference

  • src/index.ts:1118-1165 (registration)
    Registration of the 'get-stats-highlights' tool using server.tool, including description, input schema, and handler function.
    server.tool(
      "get-stats-highlights",
      "Get highlight metrics for a WordPress site from the last seven days",
      {
        siteUrl: z.string().url().describe("WordPress site URL"),
        username: z.string().describe("WordPress username"),
        password: z.string().describe("WordPress application password"),
        siteId: z.number().describe("WordPress site ID"),
      },
      async ({ siteUrl, username, password, siteId }) => {
        try {
          const highlights = await makeWPRequest<WPStatsHighlights>({
            siteUrl,
            endpoint: `sites/${siteId}/stats/highlights`,
            auth: { username, password }
          });
          
          const highlightsText = `
    Stats Highlights for site #${siteId}:
    Period: ${highlights.period || "Last 7 days"}
    Views: ${highlights.views || 0}
    Visitors: ${highlights.visitors || 0}
    Likes: ${highlights.likes || 0}
    Comments: ${highlights.comments || 0}
    Followers: ${highlights.followers || 0}
    Posts: ${highlights.posts || 0}
          `.trim();
          
          return {
            content: [
              {
                type: "text",
                text: highlightsText,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error retrieving stats highlights: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
    );
  • Handler function that makes API request to Jetpack stats endpoint `/sites/{siteId}/stats/highlights`, formats the WPStatsHighlights data, and returns formatted text response.
      async ({ siteUrl, username, password, siteId }) => {
        try {
          const highlights = await makeWPRequest<WPStatsHighlights>({
            siteUrl,
            endpoint: `sites/${siteId}/stats/highlights`,
            auth: { username, password }
          });
          
          const highlightsText = `
    Stats Highlights for site #${siteId}:
    Period: ${highlights.period || "Last 7 days"}
    Views: ${highlights.views || 0}
    Visitors: ${highlights.visitors || 0}
    Likes: ${highlights.likes || 0}
    Comments: ${highlights.comments || 0}
    Followers: ${highlights.followers || 0}
    Posts: ${highlights.posts || 0}
          `.trim();
          
          return {
            content: [
              {
                type: "text",
                text: highlightsText,
              },
            ],
          };
        } catch (error) {
          return {
            content: [
              {
                type: "text",
                text: `Error retrieving stats highlights: ${error instanceof Error ? error.message : String(error)}`,
              },
            ],
          };
        }
      }
  • Zod input schema defining parameters for the tool.
    {
      siteUrl: z.string().url().describe("WordPress site URL"),
      username: z.string().describe("WordPress username"),
      password: z.string().describe("WordPress application password"),
      siteId: z.number().describe("WordPress site ID"),
    },
  • TypeScript interface defining the structure of stats highlights response data.
    interface WPStatsHighlights {
      views: number;
      visitors: number;
      likes: number;
      comments: number;
      followers: number;
      posts: number;
      period: string;
    }
  • Helper function used by the tool to make authenticated requests to WordPress REST API endpoints.
    async function makeWPRequest<T>({
      siteUrl, 
      endpoint,
      method = 'GET',
      auth,
      data = null,
      params = null
    }: {
      siteUrl: string;
      endpoint: string;
      method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
      auth: { username: string; password: string };
      data?: any;
      params?: any;
    }): Promise<T> {
      const authString = Buffer.from(`${auth.username}:${auth.password}`).toString('base64');
      
      try {
        const response = await axios({
          method,
          url: `${siteUrl}/wp-json/wp/v2/${endpoint}`,
          headers: {
            'Authorization': `Basic ${authString}`,
            'Content-Type': 'application/json',
          },
          data: data,
          params: params
        });
        
        return response.data as T;
      } catch (error) {
        if (axios.isAxiosError(error) && error.response) {
          throw new Error(`WordPress API error: ${error.response.data?.message || error.message}`);
        }
        throw error;
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves data ('Get'), implying a read-only operation, but doesn't mention authentication requirements, rate limits, error handling, or what 'highlight metrics' includes. This is inadequate for a tool with four required parameters and no output schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose. It avoids unnecessary words, though it could be slightly more informative (e.g., specifying metrics types). Every part of the sentence contributes to understanding the tool's function.

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 complexity (four required parameters, no annotations, no output schema), the description is insufficient. It doesn't explain what 'highlight metrics' returns, authentication implications, or error cases. For a tool that likely involves API calls and data retrieval, more context is needed to ensure proper 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 fully documents all four parameters. The description adds no additional parameter information beyond what's in the schema, such as explaining how 'siteId' relates to 'siteUrl' or format specifics. Baseline 3 is appropriate since the schema handles parameter documentation.

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 highlight metrics') and resource ('for a WordPress site'), with a specific time constraint ('from the last seven days'). It distinguishes from siblings like 'get-site-stats' or 'get-stats-summary' by specifying 'highlight metrics' and the fixed time window, though it could be more explicit about what 'highlight metrics' entails.

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 like 'get-site-stats' or 'get-stats-summary'. It mentions the time window but doesn't explain why this tool is preferred over others for similar metrics, leaving usage context implied rather than explicit.

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

Related 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/prathammanocha/wordpress-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server