Skip to main content
Glama
mendeel

Mixpanel MCP

by mendeel

profile_event_activity

Retrieve event activity data for specific user profiles to analyze individual behavior patterns, troubleshoot user issues, and understand user journeys within Mixpanel.

Instructions

Get data for a profile's event activity. Useful for understanding individual user journeys, troubleshooting user-specific issues, and analyzing behavior patterns of specific users.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idNoThe Mixpanel project ID. Optional since it has a default.
workspace_idNoThe ID of the workspace if applicable
distinct_idsYesA JSON array as a string representing the distinct_ids to return activity feeds for. Example: ["12a34aa567eb8d-9ab1c26f345b67-89123c45-6aeaa7-89f12af345f678"]
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)

Implementation Reference

  • The handler function that implements the core logic for the 'profile_event_activity' tool. It makes an authenticated GET request to the Mixpanel /stream/query endpoint to fetch event activity for specified distinct_ids over a date range.
    async function handleProfileEventActivity(args: any, config: any) {
      const { project_id = config.DEFAULT_PROJECT_ID, workspace_id, distinct_ids, from_date, to_date } = 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
        let url = `${config.MIXPANEL_BASE_URL}/stream/query?project_id=${project_id}&distinct_ids=${encodeURIComponent(distinct_ids)}&from_date=${from_date}&to_date=${to_date}`;
        
        // Add optional workspace_id if provided
        if (workspace_id) {
          url += `&workspace_id=${workspace_id}`;
        }
        
        // 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(`API request failed with status ${response.status}: ${errorText}`);
        }
        
        const data = await response.json();
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(data)
            }
          ]
        };
      } catch (error) {
        console.error('Error fetching profile event activity:', error);
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: "text",
              text: `Error fetching profile event activity: ${errorMessage}`
            }
          ],
          isError: true
        };
      }
    }
  • The input schema definition and metadata for the 'profile_event_activity' tool, including description and required parameters, registered in the MCP tools list.
      name: "profile_event_activity",
      description: "Get data for a profile's event activity. Useful for understanding individual user journeys, troubleshooting user-specific issues, and analyzing behavior patterns of specific users.",
      inputSchema: {
        type: "object",
        properties: {
          project_id: {
            type: "string",
            description: "The Mixpanel project ID. Optional since it has a default."
          },
          workspace_id: {
            type: "string",
            description: "The ID of the workspace if applicable"
          },
          distinct_ids: {
            type: "string",
            description: "A JSON array as a string representing the distinct_ids to return activity feeds for. Example: [\"12a34aa567eb8d-9ab1c26f345b67-89123c45-6aeaa7-89f12af345f678\"]"
          },
          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)"
          }
        },
        required: ["distinct_ids", "from_date", "to_date"]
      }
    },
  • src/index.ts:619-620 (registration)
    The switch case in the tool request handler that dispatches calls to the 'profile_event_activity' handler function.
    case "profile_event_activity":
      return await handleProfileEventActivity(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