Analytics for AI and MCP Clients

Two different things live on this page, and they are easy to confuse because both involve AI. The first is how Leed counts non-human readers: an agent that answers a question out of your documentation never loads a page, so it is invisible to every page-view metric, and Leed records it in a separate stream rather than letting it vanish. The second is how you or a client query your analytics by name instead of reading a dashboard — the same catalog Know renders, reachable from the in-CMS assistant and from any MCP client you have connected.

Three audiences, counted separately

Leed splits traffic into people and agents, and agents into signed in and anonymous, because the three arrive through genuinely different doors:

AudienceWhat counts as one unitWhere it comes fromSets a cookie?Where it surfaces
PeopleOne page viewPage-view events from the tracker on your published siteYes — __sid and __lidEvery session- and page-view metric in Leed
Anonymous agentsOne granted tool callYour site’s public agent surface at /api/agent/*NoKnow › Agents and Knowledge health › Agent calls (Growth)
Signed-in agentsOne granted tool callYour Docs MCP, the OAuth-gated surface your readers connectNoKnow › Agents and Knowledge health › Agent calls (Growth)

The split matters most when your page views drop. If readers have started asking an assistant instead of visiting, the people bucket falls while the agent buckets rise — and the total demand for your content has not moved at all. Counting them in one bucket would hide that; counting them separately is what makes it legible. Leed records only whether an agent was signed in or anonymous; it does not know which AI client made a request.

flowchart TD
  H["A person's browser loads a page"] --> PV["Page view events"]
  A["An agent calls your site agent surface"] --> RL["Tool-call request log"]
  M["A signed-in agent calls your Docs MCP"] --> RL
  S["A reader types in documentation search"] --> RL
  PV --> HB["People"]
  RL -->|"source = agent"| AB["Anonymous agents"]
  RL -->|"source = mcp"| MB["Signed-in agents"]
  RL -->|"source = site"| SB["Reader searches"]
  H --> SESS["Session row, __sid and __lid cookies"]
  A -.->|"no session, no cookie"| NONE["Outside the session chain"]
  M -.->|"no session, no cookie"| NONE
  S -.->|"no session, no cookie"| NONE

What is counted

Only granted tool calls count as traffic. A request that was refused at the gate — an unrecognized visitor trying to reach a Docs MCP that is not open to them — is written to the same log flagged as denied, and excluded from the audience buckets. It is a demand signal, not an audience.

Each bucket carries a prior-period delta computed exactly the way every other comparison in Leed is: the immediately preceding window of equal length. When the prior window recorded nothing at all, there is no percentage to show, and the delta is reported as absent rather than as an infinite increase.

One thing the buckets deliberately do not contain is your own work. Tool calls you or your teammates make against the Operator MCP — including the analytics tools described below — are recorded in the separate action log that tracks CMS activity, not in the reader-facing request log. Running get_analytics twenty times does not inflate your agent figures.

Where you can see it

Know › Agents (Growth) shows agent reads and questions, signed in against anonymous, denied attempts, the tools agents used and the full query log; below Growth it shows its real totals over a blurred preview. Know › Knowledge health › Agent calls lists every Docs MCP call with the exact page versions it was served, and shows an upgrade prompt below Growth. Leed records only whether an agent was signed in or anonymous; there is no breakdown by AI client.

Why agent traffic sets no cookies

Three surfaces run entirely outside the session and cookie chain: the Docs MCP, the public agent surface at /api/agent/*, and reader search. None of them mints a session, creates a visitor record or sets a tracking cookie. A cookie-less agent request passes through a separate application before the normal middleware ever sees it.

That is a deliberate privacy choice, not an oversight, and it has a direct consequence you should expect: agent activity can never appear in a session-based metric. Unique Sessions, Unique Visitors, bounce rate, the visit funnel — none of them will ever move because an agent read your docs, no matter how much agent traffic you get. The session model those metrics are built on is described in how Leed tracks visitors, and the agent surface your readers’ tools actually call is described in the Site AI Agent. Connecting a client to the reader-facing service is covered in the Docs MCP overview.

Reader search is logged too

When live documentation search is on, every reader query lands in the same request log as agent and MCP traffic, tagged as coming from the site. That includes the queries that returned nothing — an empty search is the whole point of keeping the log, because a query with no results is a reader telling you what your documentation does not cover. A search that failed outright is flagged as failed so it cannot be mistaken for a genuine zero-result one.

Logging is best-effort and deferred: it never blocks the response and a logging failure never turns a successful search into an error. Queries are truncated to 256 characters, matching the endpoint’s own limit.

Asking the assistant for a number

The assistant inside the CMS has an analytics tool, so you can ask for a figure in English instead of opening Know. Ask about traffic, popular pages, referrers or geography and it fetches the metric and renders a chart inline in the conversation, followed by a sentence or two of summary.

What you get back depends on the metric’s shape. A counted metric renders as the number and its time series together, or just one of the two if you asked for one. A ranked metric renders as a top-ten list. The two geographic metrics render as maps — a US state map and a world map. A name the catalog does not recognize renders as Unknown metric: <name> rather than an empty chart.

Prompts that work:

  • “How many page views did we get in the last 30 days?”
  • “Show me unique visitors for the last quarter as a trend.”
  • “Which referrer hosts sent us the most sessions this month?”
The CMS assistant answering a question about page views, showing the prompt, an inline chart of the last 30 days, and a short written summary beneath it

The one rule that matters: if you name a page by its title, the assistant resolves the title to a page id first. It never passes a title where an id belongs, and neither should you when writing a tool call by hand — a title in the pageId slot silently scopes the query to nothing. The rest of what the assistant can do is described in the Leed Assistant.

Querying metrics from an MCP client

A connected Operator MCP client gets two analytics tools. Together they are a complete loop: ask what exists, then ask for one of them.

ToolAvailable toParametersReturns
list_analytics_metricsMCP clientsNoneThe catalog, split into numberMetrics, listMetrics, summaryMetrics and reportMetrics, plus metrics: each name with its arguments, plan feature and privilege
get_analyticsMCP clients and the in-CMS assistantmetric, start, end (required); type, pageId, assetId, formId, limit, offset (optional)One metric’s result for the window; report metrics return paged rows
get_analytics_chartThe in-CMS assistantmetric (number and list metrics only), start, end, type, pageId, assetIdThe same result, rendered as a chart in the conversation

Full parameter tables for these alongside the rest of the Operator MCP surface are in MCP tools: analytics and introspection, and connecting a client in the first place is covered in connecting to the Operator MCP.

For anything a Know screen shows, read the view rather than one metric: get_know_view returns the same sections and numbers as the screen, and run_saved_view runs a saved view. Reading Know from MCP and the CLI covers both, and the leed know CLI does the same from a terminal.

Discover the catalog

list_analytics_metrics takes no input at all and returns every metric name you can query, grouped by shape. Start here rather than guessing names — the catalog is the authority, and the names are query keys, not display labels.

{
  "numberMetrics": ["pageViewsMetric", "uniqueVisitorsMetric", "…"],
  "listMetrics": ["entryPagesByViewMetric", "referrerHostMetric", "sessionsByCountryMetric", "…"],
  "summaryMetrics": ["readingDepth"],
  "reportMetrics": ["formPerformanceByForm", "shortLinkClicksByCode", "shortLinkShares", "emailPerformanceByEmail", "emailPerformanceByTemplate"],
  "metrics": [
    { "name": "pageViewsMetric", "kind": "number", "requires": [], "optional": ["pageId"], "feature": null, "privilege": null, "namesPeople": false },
    { "name": "emailPerformanceByTemplate", "kind": "report", "requires": [], "optional": [], "feature": "readerIdentity", "privilege": "contact:read", "namesPeople": false }
  ]
}

The tool is read-only and workspace-agnostic: it lists what the product can measure, not what your workspace happens to have data for. Each entry in metrics says which arguments it requires (requires) or accepts (optional), the plan feature it needs (null for every plan) and any privilege it needs beyond analytics:read. namesPeople is false everywhere: every metric is an aggregate. The counted metrics are defined in the metrics reference and the ranked ones in the list metrics reference.

Query one metric

get_analytics takes a metric name, an ISO-8601 start and end, and optional narrowings: type, which picks the count or the time series for a counted metric; pageId, which scopes the query to a single page; assetId for the video, audio and document metrics; formId for formPerformanceByForm; and limit and offset to page through list and report rows. A report metric returns { metric, window, rows, total }.

A counted metric with no type returns all three things at once — the number for the window, the same number for the immediately preceding window of equal length, and a zero-filled time series:

{
  "name": "Page Views",
  "count": 4812,
  "previous": 4130,
  "line": [
    { "timeValue": 1756684800000, "count": 143 },
    { "timeValue": 1756771200000, "count": 168 }
  ]
}

timeValue is a millisecond epoch timestamp at the start of each bucket, and the bucket size is chosen from the span of the range rather than passed in. Every bucket in the window is present, including the empty ones, so a chart drawn from line has no gaps.

A ranked metric returns its declared column headers alongside the rows, so a client can render a table without knowing the metric in advance:

{
  "name": "Referrers",
  "headers": ["Referrer", "Sessions"],
  "values": [{ "referrerHost": "news.ycombinator.com", "frequency": 214 }],
  "count": 37
}

The rules that still apply

A tool call is not a back door. Everything that governs the dashboard governs it too:

  • The span cap. Any single query is capped at 365 days on every plan, including unlimited ones. Wider is a 400 Range cannot exceed 365 days, and an end on or before start is a 400 end must be after start.
  • Your plan’s history. How far back you can reach is a retention quota. A range straddling the cutoff is silently clamped to it; a range lying entirely before it returns 402 upgrade_required. Both limits are set out in the 365-day rule.
  • Gated metrics. Media engagement, element and menu clicks, inbound attribution and short link reports need Growth, and emailPerformanceByTemplate needs Starter. Asking for one below its plan returns 402 upgrade_required naming the feature — capture never stops, only the query is refused.
  • Permission. Every call carries the analytics:read privilege the person behind the client would need in the CMS, plus any privilege the metric lists (contact:read for the email reports, shortcode:read for the short link reports). A client cannot read numbers its operator could not read.
  • Unknown names. metric is checked against the catalog by the tool’s own schema, so a misspelled name is refused before the call runs. This is why you call list_analytics_metrics first.

Worked example

The same question, asked two ways: how much traffic did we get over the last 30 days, and then how much of it belonged to one page.

Ask in the conversation. The assistant picks the metric, fills in the dates, and renders the chart:

How many page views did we get in the last 30 days?

Now show me just the getting-started page.

For the second question the assistant resolves “getting-started page” to a page id before it queries, which is why you can name a page the way you talk about it.

Not every metric can be narrowed this way. Some counted metrics have no page-scoped form, and passing pageId to them does not narrow anything — the metrics reference says which. Some ranked metrics are the opposite case: they only mean something with a page id, and list_analytics_metrics lists pageId under their requires.

ESC