Skip to main content
Glama
mendeel
by mendeel

aggregate_event_counts

Analyze event volume trends by aggregating counts over specified time periods to identify patterns in user activity.

Instructions

Get event counts over time periods. Useful for analyzing event volume trends and identifying patterns in user activity over time.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
eventYesThe event name to get counts for
from_dateYesThe date in yyyy-mm-dd format to begin querying from (inclusive)
project_idNoThe Mixpanel project ID. Optional since it has a default.
to_dateYesThe date in yyyy-mm-dd format to query to (inclusive)
unitNoThe time unit for aggregation, defaults to day

Implementation Reference

  • The handler function that implements the core logic for the 'aggregate_event_counts' tool by making a GET request to the Mixpanel /events endpoint to retrieve aggregated event counts over specified date range and time unit.
    async function handleAggregateEventCounts(args: any, config: any) { const { project_id = config.DEFAULT_PROJECT_ID, event, from_date, to_date, unit = "day" } = args; try { const credentials = `${config.SERVICE_ACCOUNT_USER_NAME}:${config.SERVICE_ACCOUNT_PASSWORD}`; const encodedCredentials = Buffer.from(credentials).toString('base64'); const url = `${config.MIXPANEL_BASE_URL}/events?project_id=${project_id}&event=${encodeURIComponent(event)}&from_date=${from_date}&to_date=${to_date}&unit=${unit}`; const options = { method: 'GET', headers: { 'accept': 'application/json', 'authorization': `Basic ${encodedCredentials}` } }; const response = await fetch(url, options); if (!response.ok) { const errorText = await response.text(); throw new Error(`HTTP error! status: ${response.status} - ${errorText}`); } const data = await response.json(); return { content: [ { type: "text", text: JSON.stringify(data) } ] }; } catch (error: unknown) { console.error("Error fetching event counts:", error); const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error fetching event counts: ${errorMessage}` } ], isError: true }; } }
  • The input schema definition for the 'aggregate_event_counts' tool, specifying parameters including project_id (optional), event (required), from_date (required), to_date (required), and unit (optional with enum).
    { name: "aggregate_event_counts", description: "Get event counts over time periods. Useful for analyzing event volume trends and identifying patterns in user activity over time.", inputSchema: { type: "object", properties: { project_id: { type: "string", description: "The Mixpanel project ID. Optional since it has a default." }, event: { type: "string", description: "The event name to get counts for" }, from_date: { type: "string", description: "The date in yyyy-mm-dd format to begin querying from (inclusive)" }, to_date: { type: "string", description: "The date in yyyy-mm-dd format to query to (inclusive)" }, unit: { type: "string", enum: ["hour", "day", "week", "month"], description: "The time unit for aggregation, defaults to day" } }, required: ["event", "from_date", "to_date"] } },
  • src/index.ts:612-614 (registration)
    The switch case in the CallToolRequestHandler that registers and dispatches calls to the 'aggregate_event_counts' tool to its handler function.
    case "aggregate_event_counts": return await handleAggregateEventCounts(args, { SERVICE_ACCOUNT_USER_NAME, SERVICE_ACCOUNT_PASSWORD, DEFAULT_PROJECT_ID, MIXPANEL_BASE_URL });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mendeel/mixpanel-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server