Skip to main content
Glama
Defilan

Plausible Analytics MCP Server

by Defilan

get-aggregate-stats

Retrieve aggregated website analytics like visitors, pageviews, and bounce rate for a specified time period to monitor site performance and trends.

Instructions

Get aggregate stats for a site over a time period (visitors, pageviews, bounce rate, etc.). Use this for summary/overview questions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
site_idYesDomain of the site (e.g. 'example.com')
metricsNoMetrics to retrieve
date_rangeNoTime period. Use a preset like '30d' or a custom range ['2024-01-01', '2024-01-31']30d
filtersNoFilters array using Plausible v2 syntax, e.g. [['is', 'event:page', ['/blog*']]]

Implementation Reference

  • The handler function for the get-aggregate-stats tool that queries the client and formats the response.
    async ({ site_id, metrics, date_range, filters }) => {
      const result = await client.query({
        site_id,
        metrics,
        date_range,
        filters: filters ?? undefined,
      });
    
      // Format the aggregate result readably
      const row = result.results[0];
      const formatted: Record<string, unknown> = {};
      metrics.forEach((m, i) => {
        formatted[m] = row?.metrics[i];
      });
    
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(
              { site_id, date_range, metrics: formatted },
              null,
              2
            ),
          },
        ],
      };
    }
  • src/index.ts:103-140 (registration)
    The MCP tool registration for 'get-aggregate-stats' including input schema definitions.
    server.tool(
      "get-aggregate-stats",
      "Get aggregate stats for a site over a time period (visitors, pageviews, bounce rate, etc.). Use this for summary/overview questions.",
      {
        site_id: z.string().describe("Domain of the site (e.g. 'example.com')"),
        metrics: metricsSchema,
        date_range: dateRangeSchema,
        filters: filtersSchema,
      },
      async ({ site_id, metrics, date_range, filters }) => {
        const result = await client.query({
          site_id,
          metrics,
          date_range,
          filters: filters ?? undefined,
        });
    
        // Format the aggregate result readably
        const row = result.results[0];
        const formatted: Record<string, unknown> = {};
        metrics.forEach((m, i) => {
          formatted[m] = row?.metrics[i];
        });
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(
                { site_id, date_range, metrics: formatted },
                null,
                2
              ),
            },
          ],
        };
      }
    );
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 mentions the tool retrieves aggregate stats but doesn't describe key behaviors: whether it's a read-only operation, potential rate limits, authentication requirements, or what the output format looks like (e.g., JSON structure). For a tool with no annotations, this leaves significant gaps in understanding how it behaves.

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 concise and front-loaded: the first sentence clearly states the purpose, and the second provides usage guidance. There's no wasted text, and both sentences earn their place by adding value. It could be slightly more structured by explicitly listing key parameters, but it's efficient overall.

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 moderate complexity (4 parameters, no output schema, no annotations), the description is partially complete. It covers the purpose and basic usage but lacks details on behavioral traits, output format, and explicit differentiation from siblings. With no annotations to fill gaps, the description should do more to ensure the agent can use the tool effectively, making it adequate but with clear room for improvement.

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 parameters thoroughly. The description adds minimal value beyond the schema: it implies parameters like 'site' and 'time period' but doesn't provide additional syntax or format details. The baseline score of 3 is appropriate when the schema does the heavy lifting, though the description could have elaborated on parameter interactions.

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 aggregate stats for a site over a time period' with examples like 'visitors, pageviews, bounce rate, etc.' It specifies the verb (get), resource (aggregate stats), and scope (site, time period). However, it doesn't explicitly distinguish this from sibling tools like 'get-timeseries' or 'get-breakdown' beyond the 'summary/overview' hint.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides some guidance with 'Use this for summary/overview questions,' which implies when to use it. However, it doesn't explicitly state when NOT to use it or name alternatives among the sibling tools (e.g., 'get-timeseries' for trends over time or 'get-breakdown' for detailed segmentation). The guidance is helpful but incomplete.

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/Defilan/plausible-mcp'

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