Skip to main content
Glama
dragonkhoi

mixpanel

get_today_top_events

Retrieve today's most active events in Mixpanel to monitor real-time user activity, identify trends, and analyze engagement. Supports filtering by event type and limiting results.

Instructions

Get today's top events from Mixpanel. Useful for quickly identifying the most active events happening today, spotting trends, and monitoring real-time user activity.

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 handler function that executes the tool: authenticates with Mixpanel service account, fetches today's top events via API (`/api/query/events/top`), handles errors, and returns JSON data.
    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/top?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 input schema defining parameters: 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:21-79 (registration)
    MCP server.tool() registration of the 'get_today_top_events' tool with name, description, input schema, and handler function.
    server.tool(
      "get_today_top_events",
      "Get today's top events from Mixpanel. Useful for quickly identifying the most active events happening today, spotting trends, and monitoring real-time user activity.",
      {
        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/top?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?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the tool is for 'real-time user activity' monitoring, which implies freshness of data, but doesn't disclose critical behavioral traits like rate limits, authentication requirements, error conditions, or what format the results return. The description adds some context about use cases but lacks operational transparency needed for a tool with no annotation coverage.

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 appropriately sized with two sentences. The first sentence states the core purpose, and the second provides usage context. Both sentences earn their place by adding value. It's front-loaded with the main function. Could be slightly more structured but efficiently conveys key information without waste.

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 3 parameters with full schema coverage but no annotations and no output schema, the description provides adequate purpose and usage context but lacks completeness about behavioral aspects. For a data retrieval tool with multiple parameters and no output schema, the description should ideally mention something about return format or data structure. It's minimally viable but has clear gaps in operational transparency.

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 already documents all three parameters (limit, project_id, type) with descriptions and enum values. The description adds no parameter-specific information beyond what's in the schema. With high schema coverage, the baseline is 3 even without param details in the description.

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 today's top events from Mixpanel' with specific verb ('Get') and resource ('today's top events'). It distinguishes from siblings like 'get_top_events' by specifying 'today's' scope. However, it doesn't fully differentiate from other event-related tools like 'aggregate_event_counts' or 'top_event_properties' beyond the temporal focus.

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 quickly identifying the most active events happening today, spotting trends, and monitoring real-time user activity.' This suggests when to use it (for real-time monitoring and trend spotting), but doesn't explicitly state when NOT to use it or name alternatives among the many sibling tools. No explicit exclusions or comparisons are provided.

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