Skip to main content
Glama
PiwikPRO

Piwik PRO MCP Server

Official
by PiwikPRO

analytics_query_execute

Read-only

Execute analytics queries against Piwik PRO using dimensions and metrics with optional filters, transformations, and ordering.

Instructions

    Execute an analytics query against Piwik PRO.

    REQUIRED WORKFLOW - You must follow these steps in order:

    1. Call `analytics_dimensions_list` to get available dimension IDs
    2. Call `analytics_metrics_list` to get available metric IDs
    3. Call `analytics_dimensions_details_list` for details on dimensions you plan to use
    4. Call `analytics_metrics_details_list` for details on metrics you plan to use
    5. Call this tool with validated column_ids and transformation_ids

    Column IDs and transformation IDs must exactly match values returned by the list and
    details endpoints. Guessing or inventing IDs will cause query failures.

    DO NOT RUN THIS TOOL BEFORE CHECKING DIMENSIONS AND METRICS DETAILS!
    Important: Metrics cannot be transformed. Only dimensions accept transformation_id.

    ---

    Args:
        website_id: UUID of the website/app to query
        columns: List of column definitions. Each column is a dict with:
            - column_id (required): Dimension or metric ID from the list endpoints
              (in case of calculated metric use always string "calculated_metric",
              in case of custom channel grouping use always string "custom_channel_grouping")
            - transformation_id (optional): Aggregation function from details endpoint
              (e.g., "sum", "count", "unique_count")
              Note: Only dimensions support transformations. Metrics cannot be transformed.
            - calculated_metric_id: only for calculated metrics
            - custom_channel_grouping_id: only for custom channel groupings
            - dimension_value_grouping_id: only for transformation_id = 'dimension_value_grouping'
            - event_type: optional int value only for transformed dimension with scope = 'product'
              Allowed values:
                Order: 9, Abandoned cart: 10, Product detail view: 22, Add to cart: 23, Remove from cart: 24

        date_from: Start date in YYYY-MM-DD format
        date_to: End date in YYYY-MM-DD format
        relative_date: Alternative to date_from/date_to. Options:
            today, yesterday, last_week, last_month, last_year, last_X_days
            last_X_days must be in range 1 <= X <= 365
            For periods beyond the last year use date_from and date_to

        filters: Optional dimension filter group with structure:
            {"operator": "and"|"or", "conditions": [...]}

            Each condition:
            {"column_id": "...", "condition": {"operator": "<op>", "value": ...}}

            Filter operators:
            - String: eq, neq, contains, not_contains, starts_with, ends_with, matches, not_matches
            - Numeric: gt, gte, lt, lte
            - Null checks: empty, not_empty

            Note: Some operators only work with specific data types.
            Check dimension/metric details for type compatibility before filtering.
        metric_filters: as arg 'filters' but for metrics
        offset: Rows to skip (default: 0)
        limit: Max rows to return (default: 100, max: 100000)
        order_by: List of [column_index, "asc"|"desc"] pairs

    ---

    Reference:
    - Dimension IDs: analytics_dimensions_list
    - Metric IDs: analytics_metrics_list
    - Dimension details (transformations, types): analytics_dimensions_details_list
    - Metric details (types): analytics_metrics_details_list
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
website_idYes
columnsYes
date_fromNo
date_toNo
relative_dateNo
filtersNo
metric_filtersNo
offsetNo
limitNo
order_byNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusYesExecution status
resultYesQuery results
messageYesStatus message
Behavior5/5

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

Beyond the readOnlyHint annotation, the description discloses that transformations apply only to dimensions (not metrics), details on calculated metrics and custom channel grouping, filter operators and compatibility hints, and constraints on relative_date range.

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 well-structured with a summary, numbered workflow, parameter definitions, and references, all front-loaded. Every sentence adds essential information given the tool's complexity; no wasted text.

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

Completeness5/5

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

Given the tool's complexity (10 parameters, nested objects, various conditional fields) and the absence of schema descriptions, the description covers all aspects including special column types, filter operators, date constraints, and references to prerequisite tools, making it fully complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Although the input schema has 0% description coverage, the description provides exhaustive semantics for all 10 parameters: website_id (UUID), columns (dict structure with fields), date formatting, relative_date options, filter structure and operators, limit max, and order_by format.

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 it executes an analytics query against Piwik PRO, and the required workflow distinguishes it from sibling tools like analytics_dimensions_list by specifying it as the final step after gathering dimension and metric details.

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 an explicit required workflow with five steps, prerequisites (must call dimension and metric list and details endpoints first), and a strong warning not to run this tool before checking details, offering clear directives on when and how to use it.

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/PiwikPRO/mcp'

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