Skip to main content
Glama
arttus

umami-mcp-server

by arttus

Get visitor retention across periods

umami_get_retention
Read-onlyIdempotent

Calculate a cohort retention curve for identified visitors, showing the percentage who return each period. Relies on persistent IDs set via umami.identify to track returning visitors.

Instructions

Get a cohort retention curve: of the distinct visitors seen in the first period, what percentage returned in each period since.

Umami has no retention endpoint. This is built from umami.identify()'d visitors: it groups the 'distinctId' metric dimension by period and measures overlap between the earliest period's cohort and each later period.

Requires the site to call umami.identify(persistentId) with a stable, persistent ID (e.g. a long-lived cookie or logged-in user ID). Without that, every session has a null distinctId and no cohort can be tracked, this will report zero visitors regardless of real traffic.

Args:

  • website (string, optional): Website ID, name, or domain.

  • cohort_unit ('day' | 'week' | 'month'): Length of each period, default 'week'.

  • periods (number): Number of periods to show, including period 0, default 6, max 12.

  • response_format ('markdown' | 'json'): Output format (default: 'markdown').

Returns: JSON shape: { "cohort_unit": string, "cohort_size": number, "cohort_start": string, "periods": [ { "period": number, "period_start": string, "returning_visitors": number, "retention_pct": number } ] }

Error handling:

  • cohort_size of 0 means no visitor has been identify()'d yet in the earliest period. This is an instrumentation gap, not a data gap; pageview/session tools still work without identify().

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
periodsNoNumber of periods to show, including period 0.
websiteNoWebsite ID (UUID), name, or domain. Optional if UMAMI_DEFAULT_WEBSITE is set. Use umami_list_websites to discover values.
cohort_unitNoLength of each period.week
response_formatNoOutput format: 'markdown' for a readable summary, 'json' for raw structured data.markdown

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.7/5.0
Behavior5/5

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

Adds substantial behavioral context beyond the readOnlyHint/idempotentHint annotations: the tool groups distinctId overlap, requires persistent user IDs, reports zero when instrumentation is missing, and clearly separates instrumentation gaps from data gaps. This is exactly the kind of nuance an agent needs to interpret results correctly.

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 detailed but well-structured with clear sections: purpose, implementation, prereq, Args, Returns, and Error handling. Every sentence adds value, especially the return shape, which compensates for the missing output schema.

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?

Despite having no output schema, the description fully specifies the JSON return shape, parameter behaviors, prerequisites, and error interpretation. For a read-only analytics tool with an unusual dependency on identify() instrumentation, nothing essential is missing.

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 coverage is 100%, so the schema already documents all four parameters and their defaults. The description mostly restates those same details, though it adds useful output-related context such as cohort_size of 0 meaning no identify()'d visitors in the earliest period.

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?

States a specific verb and resource: 'Get a cohort retention curve' with a precise definition of what it computes. It also distinguishes itself from other analytics siblings by explaining that it is built from identify()'d visitors and that no native retention endpoint exists.

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?

Explicitly states when the tool is valid: only if the site calls umami.identify(persistentId) with a stable ID. It also tells agents when not to rely on it — without identify(), it reports zero visitors — and points to pageview/session tools as the fallback for traffic data.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.