get_stats
Retrieve website analytics statistics including pageviews, visitors, visits, bounces, and total time for specified time periods and filters.
Instructions
Get summary statistics for a website (pageviews, visitors, visits, bounces, totaltime)
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:20-28 (handler)The handler function for the get_stats tool which calls the Umami API to fetch website statistics.
async ({ websiteId, startAt, endAt, url, referrer }) => { const data = await client.call("GET", `/api/websites/${websiteId}/stats`, undefined, { startAt, endAt, url, referrer, }); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } - src/tools/stats.ts:11-29 (registration)Registration of the get_stats tool using the MCP server instance, including parameter schema definition.
server.tool( "get_stats", "Get summary statistics for a website (pageviews, visitors, visits, bounces, totaltime)", { 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}/stats`, undefined, { startAt, endAt, url, referrer, }); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } );