Skip to main content
Glama
Defilan

Plausible Analytics MCP Server

by Defilan

query

Execute advanced Plausible Analytics API queries for custom property breakdowns, behavioral filters, and multi-dimensional time series analysis.

Instructions

Execute a raw Plausible Stats API v2 query. Use this for advanced queries that the other tools don't cover, such as custom property breakdowns, behavioral filters, or combining multiple dimensions with time series.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
site_idYesDomain of the site (e.g. 'example.com')
metricsYesMetrics to retrieve
date_rangeYesDate range preset or custom [start, end]
dimensionsNoDimensions to group by
filtersNoFilters in Plausible v2 syntax
order_byNoOrder by, e.g. [['visitors', 'desc']]
paginationNoPagination options
includeNoInclude options (imports, time_labels, comparisons)

Implementation Reference

  • src/index.ts:277-337 (registration)
    Registration of the 'query' MCP tool.
    server.tool(
      "query",
      "Execute a raw Plausible Stats API v2 query. Use this for advanced queries that the other tools don't cover, such as custom property breakdowns, behavioral filters, or combining multiple dimensions with time series.",
      {
        site_id: z.string().describe("Domain of the site (e.g. 'example.com')"),
        metrics: z.array(z.string()).describe("Metrics to retrieve"),
        date_range: z
          .union([z.string(), z.tuple([z.string(), z.string()])])
          .describe("Date range preset or custom [start, end]"),
        dimensions: z.array(z.string()).optional().describe("Dimensions to group by"),
        filters: z.array(z.any()).optional().describe("Filters in Plausible v2 syntax"),
        order_by: z
          .array(z.any())
          .optional()
          .describe("Order by, e.g. [['visitors', 'desc']]"),
        pagination: z
          .object({
            limit: z.number().optional(),
            offset: z.number().optional(),
          })
          .optional()
          .describe("Pagination options"),
        include: z
          .object({
            imports: z.boolean().optional(),
            time_labels: z.boolean().optional(),
            total_rows: z.boolean().optional(),
            comparisons: z
              .object({
                mode: z.string(),
                date_range: z
                  .union([z.string(), z.tuple([z.string(), z.string()])])
                  .optional(),
              })
              .optional(),
          })
          .optional()
          .describe("Include options (imports, time_labels, comparisons)"),
      },
      async ({ site_id, metrics, date_range, dimensions, filters, order_by, pagination, include }) => {
        const result = await client.query({
          site_id,
          metrics,
          date_range,
          dimensions: dimensions ?? undefined,
          filters: filters ?? undefined,
          order_by: order_by ?? undefined,
          pagination: pagination ?? undefined,
          include: include ?? undefined,
        });
    
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      }
    );
  • Implementation of the 'query' method in the Plausible client which makes the actual API request.
    async query(params: PlausibleQueryParams): Promise<PlausibleQueryResult> {
      const response = await fetch(`${this.baseUrl}/api/v2/query`, {
        method: "POST",
        headers: {
          Authorization: `Bearer ${this.apiKey}`,
          "Content-Type": "application/json",
        },
        body: JSON.stringify(params),
      });
    
      if (!response.ok) {
        const body = await response.text();
        throw new Error(
          `Plausible API error (${response.status}): ${body}`
        );
      }
    
      return response.json() as Promise<PlausibleQueryResult>;
    }
Behavior3/5

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

No annotations are provided, so the description carries full burden. It mentions this is for 'raw Plausible Stats API v2 query' execution, which implies direct API interaction, but doesn't disclose important behavioral aspects like authentication requirements, rate limits, error handling, or what format the results return. The description adds some context about advanced use cases but lacks operational transparency.

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 perfectly concise - two sentences that efficiently communicate purpose and usage guidelines. The first sentence states what the tool does, the second provides clear when-to-use guidance with specific examples. Every word earns its place with zero waste.

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?

For a complex tool with 8 parameters, nested objects, no output schema, and no annotations, the description is adequate but incomplete. It explains the tool's purpose and differentiation well, but doesn't address the complexity of parameter interactions, result format, or operational considerations that would help an agent use this advanced tool effectively.

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?

With 100% schema description coverage, the baseline is 3. The description doesn't add any parameter-specific information beyond what's already documented in the schema. While it mentions general use cases like 'custom property breakdowns' and 'behavioral filters' that relate to parameters, it doesn't provide additional semantic context for individual parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool executes raw Plausible Stats API v2 queries, specifying it's for advanced scenarios like custom property breakdowns, behavioral filters, or combining multiple dimensions with time series. It distinguishes from siblings by explicitly mentioning 'advanced queries that the other tools don't cover'.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool ('for advanced queries that the other tools don't cover') and gives concrete examples of appropriate use cases (custom property breakdowns, behavioral filters, combining multiple dimensions with time series). This clearly differentiates it from the simpler sibling tools.

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