get_session_stats
Retrieve summarized session statistics for a website, including total sessions and unique visitors, with optional filtering by URL and referrer.
Instructions
Get summarized session statistics for a website (total sessions, unique visitors, etc.)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| websiteId | Yes | Website UUID | |
| startAt | Yes | Start timestamp in milliseconds | |
| endAt | Yes | End timestamp in milliseconds | |
| url | No | Filter by URL path | |
| referrer | No | Filter by referrer |
Implementation Reference
- src/tools/stats.ts:178-196 (handler)The "get_session_stats" tool is registered and implemented directly within the registerStatsTools function in src/tools/stats.ts. It calls the UmamiClient to fetch statistics from the /api/websites/{websiteId}/sessions/stats endpoint.
server.tool( "get_session_stats", "Get summarized session statistics for a website (total sessions, unique visitors, etc.)", { websiteId: z.string().describe("Website UUID"), ...dateRange, url: z.string().optional().describe("Filter by URL path"), referrer: z.string().optional().describe("Filter by referrer"), }, async ({ websiteId, startAt, endAt, url, referrer }) => { const data = await client.call("GET", `/api/websites/${websiteId}/sessions/stats`, undefined, { startAt, endAt, url, referrer, }); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } );