Get Umami Active Visitors
umami_get_activeRetrieve the number of active visitors on a website within the last 5 minutes by providing the website ID. Enables real-time monitoring of current audience engagement.
Instructions
Get the number of active visitors on a website during the last 5 minutes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| websiteId | Yes | Umami website ID. Use umami_list_websites or umami_find_website first if you do not know it. |
Implementation Reference
- src/tools/active.ts:23-31 (handler)The core handler for umami_get_active tool. Calls `dependencies.client.getActive(websiteId)` and returns the active visitor count.
createToolHandler(async ({ websiteId }) => { const result = await dependencies.client.getActive(websiteId); return { websiteId, activeVisitors: result.visitors, visitors: result.visitors, }; }), - src/tools/active.ts:6-8 (schema)Input schema for umami_get_active requiring a websiteId string (via websiteIdSchema).
const getActiveInputSchema = z.object({ websiteId: websiteIdSchema, }); - src/tools/active.ts:14-32 (registration)Registration of the tool named 'umami_get_active' on the MCP server with title, description, inputSchema, and handler.
server.registerTool( "umami_get_active", { title: "Get Umami Active Visitors", description: "Get the number of active visitors on a website during the last 5 minutes.", inputSchema: getActiveInputSchema, annotations: readOnlyAnnotations, }, createToolHandler(async ({ websiteId }) => { const result = await dependencies.client.getActive(websiteId); return { websiteId, activeVisitors: result.visitors, visitors: result.visitors, }; }), ); - src/tools/helpers.ts:13-50 (helper)Generic `createToolHandler` wrapper used by umami_get_active. Wraps the handler with error handling and response formatting.
export function createToolHandler<Args extends object>( handler: (args: Args) => Promise<Record<string, unknown>>, ): (args: Args) => Promise<CallToolResult> { return async (args: Args) => { try { const payload = { ok: true, ...await handler(args), }; return { content: [ { type: "text", text: JSON.stringify(payload, null, 2), }, ], structuredContent: payload, }; } catch (error) { const payload = { ok: false, error: toErrorPayload(error), }; return { content: [ { type: "text", text: JSON.stringify(payload, null, 2), }, ], structuredContent: payload, isError: true, }; } }; } - src/tools/index.ts:18-20 (registration)Registration entry point: calls `registerActiveTool` alongside other tools.
registerActiveTool(server, dependencies); registerEventsTool(server, dependencies); }