get_metrics
Retrieve aggregated website analytics data including top pages, browsers, devices, countries, and events for specified time periods.
Instructions
Get aggregated metrics for a website (e.g. top pages, browsers, countries, devices, OS, events)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| websiteId | Yes | Website UUID | |
| startAt | Yes | Start timestamp in milliseconds | |
| endAt | Yes | End timestamp in milliseconds | |
| type | Yes | Metric type to aggregate | |
| url | No | Filter by URL path | |
| referrer | No | Filter by referrer | |
| limit | No | Max results to return (default 500) |
Implementation Reference
- src/tools/stats.ts:55-94 (handler)Implementation of the 'get_metrics' tool, which handles registration of the tool with the McpServer and its execution logic, querying the UmamiClient for website metrics.
server.tool( "get_metrics", "Get aggregated metrics for a website (e.g. top pages, browsers, countries, devices, OS, events)", { websiteId: z.string().describe("Website UUID"), ...dateRange, type: z .enum([ "url", "referrer", "browser", "os", "device", "country", "region", "city", "language", "event", "query", "title", "host", "tag", ]) .describe("Metric type to aggregate"), url: z.string().optional().describe("Filter by URL path"), referrer: z.string().optional().describe("Filter by referrer"), limit: z.number().optional().describe("Max results to return (default 500)"), }, async ({ websiteId, startAt, endAt, type, url, referrer, limit }) => { const data = await client.call("GET", `/api/websites/${websiteId}/metrics`, undefined, { startAt, endAt, type, url, referrer, limit, }); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } );