Skip to main content
Glama
mendeel

Mixpanel MCP

by mendeel

list_saved_cohorts

Retrieve saved user cohorts from Mixpanel to discover existing segments and obtain cohort IDs for detailed analysis.

Instructions

List user cohorts in the project. Useful for discovering existing user segments and getting cohort IDs for analysis.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idNoThe Mixpanel project ID. Optional since it has a default.

Implementation Reference

  • The handler function that executes the tool logic by making a GET request to Mixpanel's /cohorts/list API endpoint with Basic Auth, returning the list of saved cohorts or an error.
    async function handleListSavedCohorts(args: any, config: any) {
      const { project_id = config.DEFAULT_PROJECT_ID } = 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}/cohorts/list?project_id=${project_id}`;
        
        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 listing saved cohorts:", error);
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: "text",
              text: `Error listing saved cohorts: ${errorMessage}`
            }
          ],
          isError: true
        };
      }
    }
  • The input schema definition for the list_saved_cohorts tool, specifying optional project_id parameter.
    {
      name: "list_saved_cohorts",
      description: "List user cohorts in the project. Useful for discovering existing user segments and getting cohort IDs for analysis.",
      inputSchema: {
        type: "object",
        properties: {
          project_id: {
            type: "string",
            description: "The Mixpanel project ID. Optional since it has a default."
          }
        }
      }
    },
  • src/index.ts:632-637 (registration)
    The switch case registration in the CallToolRequestSchema handler that routes calls to list_saved_cohorts to the handleListSavedCohorts function.
    case "list_saved_funnels":
      return await handleListSavedFunnels(args, { SERVICE_ACCOUNT_USER_NAME, SERVICE_ACCOUNT_PASSWORD, DEFAULT_PROJECT_ID, MIXPANEL_BASE_URL });
      
    case "list_saved_cohorts":
      return await handleListSavedCohorts(args, { SERVICE_ACCOUNT_USER_NAME, SERVICE_ACCOUNT_PASSWORD, DEFAULT_PROJECT_ID, MIXPANEL_BASE_URL });
  • src/index.ts:232-597 (registration)
    The tool is registered in the ListToolsRequestSchema handler's tools array for tool discovery.
    return {
      tools: [
        // Event Tools
        {
          name: "get_today_top_events",
          description: "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.",
          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"
              }
            }
          }
        },
        {
          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"
              }
            }
          }
        },
        {
          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"]
          }
        },
        {
          name: "aggregated_event_property_values",
          description: "Analyze specific event properties and their values. Useful for understanding property distributions and identifying common values.",
          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 analyze properties for"
              },
              property: {
                type: "string",
                description: "The property name to get values 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)"
              },
              limit: {
                type: "number",
                description: "Maximum number of property values to return"
              }
            },
            required: ["event", "property", "from_date", "to_date"]
          }
        },
        
        // User Profile Tools
        {
          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"]
          }
        },
        {
          name: "query_profiles",
          description: "Query user profiles with filtering. Useful for finding users based on profile properties and analyzing user segments.",
          inputSchema: {
            type: "object",
            properties: {
              project_id: {
                type: "string",
                description: "The Mixpanel project ID. Optional since it has a default."
              },
              where: {
                type: "string",
                description: "JSON string representing the filter conditions for profiles"
              },
              select: {
                type: "string",
                description: "JSON array string of properties to return. If not specified, returns all properties"
              },
              limit: {
                type: "number",
                description: "Maximum number of profiles to return"
              }
            }
          }
        },
    
        // Analytics Tools
        {
          name: "query_retention_report",
          description: "Analyze user retention patterns. Useful for understanding how well you retain users over time and identifying cohort behavior.",
          inputSchema: {
            type: "object",
            properties: {
              project_id: {
                type: "string",
                description: "The Mixpanel project ID. Optional since it has a default."
              },
              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)"
              },
              born_event: {
                type: "string",
                description: "The event that defines when users are 'born' for retention analysis"
              },
              event: {
                type: "string",
                description: "The event to measure retention for (optional, defaults to any event)"
              },
              born_where: {
                type: "string",
                description: "JSON string representing additional filters for the born event"
              },
              where: {
                type: "string",
                description: "JSON string representing additional filters for the retention event"
              },
              interval: {
                type: "string",
                enum: ["day", "week", "month"],
                description: "The time interval for retention analysis, defaults to day"
              },
              interval_count: {
                type: "number",
                description: "Number of intervals to analyze, defaults to 30"
              }
            },
            required: ["from_date", "to_date", "born_event"]
          }
        },
        {
          name: "query_funnel_report",
          description: "Get funnel conversion data. Useful for analyzing conversion rates through multi-step user flows and identifying drop-off points.",
          inputSchema: {
            type: "object",
            properties: {
              project_id: {
                type: "string",
                description: "The Mixpanel project ID. Optional since it has a default."
              },
              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)"
              },
              events: {
                type: "string",
                description: "JSON array string of events that make up the funnel steps"
              },
              funnel_window: {
                type: "number",
                description: "Number of days users have to complete the funnel"
              },
              interval: {
                type: "string",
                enum: ["day", "week", "month"],
                description: "The time interval for funnel analysis"
              }
            },
            required: ["from_date", "to_date", "events"]
          }
        },
        {
          name: "list_saved_funnels",
          description: "List available saved funnels in the project. Useful for discovering existing funnel analyses and getting funnel IDs for further analysis.",
          inputSchema: {
            type: "object",
            properties: {
              project_id: {
                type: "string",
                description: "The Mixpanel project ID. Optional since it has a default."
              }
            }
          }
        },
        {
          name: "list_saved_cohorts",
          description: "List user cohorts in the project. Useful for discovering existing user segments and getting cohort IDs for analysis.",
          inputSchema: {
            type: "object",
            properties: {
              project_id: {
                type: "string",
                description: "The Mixpanel project ID. Optional since it has a default."
              }
            }
          }
        },
    
        // Advanced Tools
        {
          name: "custom_jql",
          description: "Run custom JQL (JSON Query Language) queries. Useful for advanced analytics and custom data analysis beyond standard reports.",
          inputSchema: {
            type: "object",
            properties: {
              project_id: {
                type: "string",
                description: "The Mixpanel project ID. Optional since it has a default."
              },
              script: {
                type: "string",
                description: "The JQL script to execute"
              }
            },
            required: ["script"]
          }
        },
        {
          name: "query_segmentation_report",
          description: "Segment events by properties. Useful for analyzing how different user segments behave and comparing event patterns across groups.",
          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 to segment"
              },
              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)"
              },
              on: {
                type: "string",
                description: "The property to segment by"
              },
              where: {
                type: "string",
                description: "JSON string representing additional filters"
              },
              unit: {
                type: "string",
                enum: ["hour", "day", "week", "month"],
                description: "The time unit for segmentation, defaults to day"
              }
            },
            required: ["event", "from_date", "to_date", "on"]
          }
        },
        {
          name: "query_insights_report",
          description: "Get saved insights reports. Useful for accessing pre-configured analytics reports and dashboards.",
          inputSchema: {
            type: "object",
            properties: {
              project_id: {
                type: "string",
                description: "The Mixpanel project ID. Optional since it has a default."
              },
              report_id: {
                type: "string",
                description: "The ID of the saved insights report to retrieve"
              },
              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: ["report_id"]
          }
        }
      ]
    };
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 tool lists cohorts and is useful for discovery and ID retrieval, but doesn't describe key behaviors like whether it returns all cohorts or is paginated, what the output format looks like, or any permissions or rate limits. This leaves significant gaps 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 front-loaded with the core purpose in the first sentence, followed by a useful context sentence. It's appropriately sized with two sentences that add value, though it could be slightly more structured by explicitly separating purpose from usage guidelines.

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 no annotations and no output schema, the description provides basic purpose and usage context but is incomplete. It doesn't cover output details, behavioral traits, or advanced usage scenarios, which are important for a tool with one parameter and no structured safety or output information. This is minimally adequate but has clear gaps.

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 input schema already documents the single parameter 'project_id' with its type and optionality. The description adds no additional parameter information beyond what's in the schema, such as format examples or default values. This meets the baseline for high schema coverage but doesn't enhance 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 verb ('List') and resource ('user cohorts in the project'), making the purpose understandable. It distinguishes from siblings like 'list_saved_funnels' by specifying cohorts, but doesn't explicitly contrast with other list/query tools like 'query_profiles' or 'query_segmentation_report' that might also involve user segments.

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 mentioning it's 'useful for discovering existing user segments and getting cohort IDs for analysis,' which suggests when to use it. However, it lacks explicit guidance on when to choose this tool over alternatives like 'query_profiles' or 'query_segmentation_report' for similar purposes, 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