Skip to main content
Glama
mendeel

Mixpanel MCP

by mendeel

aggregate_event_counts

Analyze event volume trends by retrieving aggregated 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
project_idNoThe Mixpanel project ID. Optional since it has a default.
eventYesThe event name to get counts for
from_dateYesThe date in yyyy-mm-dd format to begin querying from (inclusive)
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, making an authenticated GET request to Mixpanel's /events endpoint to retrieve aggregated event counts over the specified time period.
    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
        };
      }
    }
  • Input schema defining the parameters for the aggregate_event_counts tool, including required fields event, from_date, to_date, and optional project_id and unit.
    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:279-309 (registration)
    Tool registration in the ListTools handler response, defining the name, description, and input schema for aggregate_event_counts.
    {
      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-613 (registration)
    Dispatcher case in the CallToolRequestSchema handler that routes calls to the aggregate_event_counts handler function.
    case "aggregate_event_counts":
      return await handleAggregateEventCounts(args, { SERVICE_ACCOUNT_USER_NAME, SERVICE_ACCOUNT_PASSWORD, DEFAULT_PROJECT_ID, MIXPANEL_BASE_URL });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral disclosure. It mentions the tool is 'useful for analyzing trends' but doesn't specify whether it's read-only, requires authentication, has rate limits, returns paginated results, or what format the counts are in. For a data query tool with zero annotation coverage, this leaves significant gaps in understanding its operational behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is perfectly concise: two sentences that directly state the purpose and utility without redundancy. Every word earns its place, and it's front-loaded with the core functionality. No structural issues or wasted verbiage.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (5 parameters, no output schema, no annotations), the description is insufficient. It doesn't explain what the output looks like (counts per time period), how results are structured, or any limitations (e.g., date range constraints). For an aggregation tool with multiple parameters and no output schema, more context is needed to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all 5 parameters. The description adds no parameter-specific information beyond what's in the schema—it doesn't explain how parameters interact (e.g., how 'unit' affects aggregation) or provide examples. Baseline 3 is appropriate when the schema does all the work, though the description could have added value with context like default behaviors.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get event counts over time periods' specifies the verb (get) and resource (event counts) with temporal aggregation. It distinguishes from siblings by focusing on count aggregation rather than property values, funnels, or profiles. However, it doesn't explicitly name alternatives like 'query_segmentation_report' for similar analytics.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides implied usage context: 'Useful for analyzing event volume trends and identifying patterns in user activity over time' suggests when to use it. However, it lacks explicit guidance on when to choose this tool over alternatives like 'query_insights_report' or 'get_top_events', and doesn't mention prerequisites or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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