Skip to main content
Glama
mendeel

Mixpanel MCP

by mendeel

query_retention_report

Analyze user retention patterns to understand how well users are retained over time and identify cohort behavior in Mixpanel data.

Instructions

Analyze user retention patterns. Useful for understanding how well you retain users over time and identifying cohort behavior.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idNoThe Mixpanel project ID. Optional since it has a default.
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)
born_eventYesThe event that defines when users are 'born' for retention analysis
eventNoThe event to measure retention for (optional, defaults to any event)
born_whereNoJSON string representing additional filters for the born event
whereNoJSON string representing additional filters for the retention event
intervalNoThe time interval for retention analysis, defaults to day
interval_countNoNumber of intervals to analyze, defaults to 30

Implementation Reference

  • The handler function that implements the core logic for the 'query_retention_report' tool. It constructs a Mixpanel API URL for retention analysis, authenticates with service account credentials, fetches the report data, and returns it as JSON or an error message.
    async function handleQueryRetentionReport(args: any, config: any) {
      const { 
        project_id = config.DEFAULT_PROJECT_ID, 
        from_date, 
        to_date, 
        born_event, 
        event, 
        born_where, 
        where, 
        interval = "day", 
        interval_count = 30 
      } = args;
      
      try {
        const credentials = `${config.SERVICE_ACCOUNT_USER_NAME}:${config.SERVICE_ACCOUNT_PASSWORD}`;
        const encodedCredentials = Buffer.from(credentials).toString('base64');
        
        let url = `${config.MIXPANEL_BASE_URL}/retention?project_id=${project_id}&from_date=${from_date}&to_date=${to_date}&born_event=${encodeURIComponent(born_event)}&interval=${interval}&interval_count=${interval_count}`;
        
        if (event) {
          url += `&event=${encodeURIComponent(event)}`;
        }
        if (born_where) {
          url += `&born_where=${encodeURIComponent(born_where)}`;
        }
        if (where) {
          url += `&where=${encodeURIComponent(where)}`;
        }
        
        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 querying retention report:", error);
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: "text",
              text: `Error querying retention report: ${errorMessage}`
            }
          ],
          isError: true
        };
      }
    }
  • Input schema defining parameters, types, descriptions, and required fields for the query_retention_report tool.
    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"]
  • src/index.ts:403-449 (registration)
    Tool registration in the MCP tools list, including name, description, and input schema.
    {
      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"]
      }
    },
  • src/index.ts:626-628 (registration)
    Dispatcher case in the main CallToolRequestHandler switch statement that routes calls to the specific handler function.
    case "query_retention_report":
      return await handleQueryRetentionReport(args, { SERVICE_ACCOUNT_USER_NAME, SERVICE_ACCOUNT_PASSWORD, DEFAULT_PROJECT_ID, MIXPANEL_BASE_URL });
Behavior2/5

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

No annotations are provided, so the description carries full burden for behavioral disclosure. The description mentions analyzing patterns but doesn't disclose important behavioral traits like whether this is a read-only operation, what permissions are required, whether it's resource-intensive, what the output format looks like, or any rate limits. For a complex analytics tool with 9 parameters, 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 appropriately concise with two sentences that efficiently convey the tool's purpose. The first sentence states what it does, and the second explains its utility. There's no wasted verbiage, though it could be slightly more structured by front-loading more specific information about the analysis type.

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 tool's complexity (9 parameters, analytics function) and lack of both annotations and output schema, the description is insufficiently complete. It doesn't explain what the tool returns, what format the retention analysis takes, whether it's a heavy operation, or how results should be interpreted. For a sophisticated reporting tool, users need more context about output and behavior.

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 9 parameters thoroughly. The description adds no parameter-specific information beyond what's in the schema. It mentions 'retention patterns' and 'cohort behavior' which aligns with parameters like born_event and interval, but doesn't provide additional semantic context beyond what the schema descriptions already cover.

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: 'Analyze user retention patterns' with specific goals of 'understanding how well you retain users over time and identifying cohort behavior.' It uses a specific verb ('analyze') and identifies the resource ('user retention patterns'), but doesn't explicitly differentiate from sibling tools like query_funnel_report or query_segmentation_report.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions the tool is 'useful for understanding how well you retain users over time' but doesn't specify when to choose it over other reporting tools like query_funnel_report or query_segmentation_report, nor does it mention any prerequisites or exclusions for usage.

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