Skip to main content
Glama
dragonkhoi

mixpanel

get_top_events

Retrieve the most frequent events from the last 31 days to analyze user actions, prioritize feature development, and understand platform usage patterns in Mixpanel.

Instructions

Get a list of the most common events over the last 31 days. Useful for identifying key user actions, prioritizing feature development, and understanding overall platform usage patterns.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of events to return
project_idNoThe Mixpanel project ID. Optional since it has a default.
typeNoThe type of events to fetch, either general, average, or unique, defaults to general

Implementation Reference

  • The asynchronous handler function for the 'get_top_events' tool. It authenticates with Mixpanel using service account credentials, constructs a URL for the /api/query/events/names endpoint with parameters project_id, type (general/average/unique), and optional limit, performs a GET request, parses the JSON response, and returns it as tool content or an error message.
    async ({ project_id = DEFAULT_PROJECT_ID, type = "general", limit = 10 }) => {
      try {
        // Create authorization header using base64 encoding of credentials
        const credentials = `${SERVICE_ACCOUNT_USER_NAME}:${SERVICE_ACCOUNT_PASSWORD}`;
        const encodedCredentials = Buffer.from(credentials).toString('base64');
        
        // Construct URL with query parameters
        const url = `https://mixpanel.com/api/query/events/names?project_id=${project_id}&type=${type}${limit ? `&limit=${limit}` : ''}`;
        
        // Set up request options
        const options = {
          method: 'GET',
          headers: {
            'accept': 'application/json',
            'authorization': `Basic ${encodedCredentials}`
          }
        };
        
        // Make the API request
        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 Mixpanel events:", error);
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: "text",
              text: `Error fetching Mixpanel events: ${errorMessage}`
            }
          ],
          isError: true
        };
      }
    }
  • Zod schema defining the input parameters for the get_top_events tool: project_id (optional string), type (optional enum: general/average/unique), limit (optional number).
      project_id: z.string().describe("The Mixpanel project ID. Optional since it has a default.").optional(),
      type: z.enum(["general", "average", "unique"]).describe("The type of events to fetch, either general, average, or unique, defaults to general").optional(),
      limit: z.number().optional().describe("Maximum number of events to return"),
    },
  • src/index.ts:147-205 (registration)
    The server.tool() registration call for 'get_top_events', specifying the tool name, description ('Get a list of the most common events over the last 31 days...'), input schema, and inline handler implementation.
    server.tool(
      "get_top_events",
      "Get a list of the most common events over the last 31 days. Useful for identifying key user actions, prioritizing feature development, and understanding overall platform usage patterns.",
      {
        project_id: z.string().describe("The Mixpanel project ID. Optional since it has a default.").optional(),
        type: z.enum(["general", "average", "unique"]).describe("The type of events to fetch, either general, average, or unique, defaults to general").optional(),
        limit: z.number().optional().describe("Maximum number of events to return"),
      },
      async ({ project_id = DEFAULT_PROJECT_ID, type = "general", limit = 10 }) => {
        try {
          // Create authorization header using base64 encoding of credentials
          const credentials = `${SERVICE_ACCOUNT_USER_NAME}:${SERVICE_ACCOUNT_PASSWORD}`;
          const encodedCredentials = Buffer.from(credentials).toString('base64');
          
          // Construct URL with query parameters
          const url = `https://mixpanel.com/api/query/events/names?project_id=${project_id}&type=${type}${limit ? `&limit=${limit}` : ''}`;
          
          // Set up request options
          const options = {
            method: 'GET',
            headers: {
              'accept': 'application/json',
              'authorization': `Basic ${encodedCredentials}`
            }
          };
          
          // Make the API request
          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 Mixpanel events:", error);
          const errorMessage = error instanceof Error ? error.message : String(error);
          return {
            content: [
              {
                type: "text",
                text: `Error fetching Mixpanel events: ${errorMessage}`
              }
            ],
            isError: true
          };
        }
      }
    )
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. While it mentions the 31-day time window and general purpose, it fails to describe key behavioral traits: whether this is a read-only operation, what the output format looks like (e.g., list structure, pagination), or any rate limits or authentication requirements. For a tool with no annotation coverage, this leaves significant gaps in understanding how it behaves.

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 efficiently structured in two sentences: the first states the core functionality, and the second provides usage context. Every sentence earns its place by adding value—no redundancy or fluff. It's appropriately sized and front-loaded with the main purpose.

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

Completeness3/5

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

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is partially complete. It covers the purpose and usage context well but lacks details on behavioral traits (e.g., output format, safety profile) and doesn't leverage the absence of an output schema to explain return values. For a tool with no annotations, it should do more to compensate, but it meets a minimum viable threshold.

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?

The input schema has 100% description coverage, with clear documentation for all three parameters (limit, project_id, type). The description adds no additional parameter semantics beyond what's in the schema—it doesn't explain parameter interactions, default values, or usage examples. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, but the description doesn't enhance parameter understanding.

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 a list of the most common events over the last 31 days.' It specifies the verb ('Get'), resource ('most common events'), and time scope ('last 31 days'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'get_today_top_events' or 'aggregate_event_counts', which prevents a perfect score.

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 guidance by stating the tool is 'useful for identifying key user actions, prioritizing feature development, and understanding overall platform usage patterns.' This suggests appropriate contexts for use. However, it lacks explicit guidance on when to choose this tool over alternatives like 'get_today_top_events' (for today's data) or 'aggregate_event_counts' (for custom date ranges), which would be needed for a higher score.

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

Related 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/dragonkhoi/mixpanel-mcp'

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