Skip to main content
Glama
mendeel

Mixpanel MCP

by mendeel

get_top_events

Retrieve the most common events from Mixpanel to identify key user actions, prioritize feature development, and understand platform usage patterns.

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
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
limitNoMaximum number of events to return

Implementation Reference

  • The handler function that implements the core logic of the get_top_events tool. It authenticates with Mixpanel using service account credentials, constructs the API URL for /events/names endpoint with parameters project_id, type, and limit, fetches the data, and returns the JSON response or error.
    async function handleGetTopEvents(args: any, config: any) {
      const { project_id = config.DEFAULT_PROJECT_ID, type = "general", limit = 10 } = args;
      
      try {
        // Create authorization header using base64 encoding of credentials
        const credentials = `${config.SERVICE_ACCOUNT_USER_NAME}:${config.SERVICE_ACCOUNT_PASSWORD}`;
        const encodedCredentials = Buffer.from(credentials).toString('base64');
        
        // Construct URL with query parameters
        const url = `${config.MIXPANEL_BASE_URL}/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
        };
      }
    }
  • src/index.ts:609-610 (registration)
    The switch case in the CallToolRequestSchema handler that dispatches calls to the get_top_events tool to its handler function.
    case "get_top_events":
      return await handleGetTopEvents(args, { SERVICE_ACCOUNT_USER_NAME, SERVICE_ACCOUNT_PASSWORD, DEFAULT_PROJECT_ID, MIXPANEL_BASE_URL });
  • src/index.ts:257-278 (registration)
    The tool registration object returned by ListToolsRequestSchema handler, defining the name, description, and input schema for get_top_events.
    {
      name: "get_top_events",
      description: "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.",
      inputSchema: {
        type: "object",
        properties: {
          project_id: {
            type: "string",
            description: "The Mixpanel project ID. Optional since it has a default."
          },
          type: {
            type: "string",
            enum: ["general", "average", "unique"],
            description: "The type of events to fetch, either general, average, or unique, defaults to general"
          },
          limit: {
            type: "number",
            description: "Maximum number of events to return"
          }
        }
      }
    },
  • The input schema definition for the get_top_events tool, specifying properties for project_id (string, optional), type (string enum, optional), and limit (number, optional). Used for client-side validation and documentation.
    inputSchema: {
      type: "object",
      properties: {
        project_id: {
          type: "string",
          description: "The Mixpanel project ID. Optional since it has a default."
        },
        type: {
          type: "string",
          enum: ["general", "average", "unique"],
          description: "The type of events to fetch, either general, average, or unique, defaults to general"
        },
        limit: {
          type: "number",
          description: "Maximum number of events to return"
        }
      }
    }
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. It mentions the time range ('last 31 days') and high-level use cases, but it doesn't cover critical behavioral aspects such as whether this is a read-only operation, if there are rate limits, authentication requirements, or what the output format looks like (e.g., list structure, pagination). For a tool with zero annotation coverage, this is a significant gap.

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

Conciseness4/5

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

The description is concise and well-structured with two sentences: the first states the core functionality, and the second provides usage context. There's no unnecessary repetition or fluff, and it's front-loaded with the main purpose. It could be slightly more detailed without losing conciseness, but it efficiently conveys key information.

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 complexity of a data querying tool with 3 parameters, no annotations, and no output schema, the description is incomplete. It lacks details on behavioral traits (e.g., safety, performance), output format, and explicit differentiation from siblings. While it covers the basic purpose and usage context, it doesn't provide enough information for an agent to fully understand how to invoke and interpret results, especially without structured output guidance.

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 schema description coverage is 100%, so the schema already documents all three parameters (project_id, type, limit) with descriptions and enums for 'type'. The description doesn't add any parameter-specific details beyond what's in the schema, such as explaining the differences between 'general', 'average', and 'unique' event types. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but doesn't detract either.

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. 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 context by stating it's 'useful for identifying key user actions, prioritizing feature development, and understanding overall platform usage patterns.' This gives some guidance on when to use it, but it doesn't explicitly mention when not to use it or name alternatives like 'get_today_top_events' for different time ranges, leaving room for improvement.

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