Skip to main content
Glama
mendeel

Mixpanel MCP

by mendeel

query_insights_report

Retrieve pre-configured analytics reports and dashboards from Mixpanel to access saved insights with date filtering.

Instructions

Get saved insights reports. Useful for accessing pre-configured analytics reports and dashboards.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idNoThe Mixpanel project ID. Optional since it has a default.
report_idYesThe ID of the saved insights report to retrieve
from_dateNoThe date in yyyy-mm-dd format to begin querying from (inclusive)
to_dateNoThe date in yyyy-mm-dd format to query to (inclusive)

Implementation Reference

  • The handler function that implements the core logic for the 'query_insights_report' tool, making an authenticated GET request to Mixpanel's /insights endpoint and returning the JSON response.
    async function handleQueryInsightsReport(args: any, config: any) {
      const { 
        project_id = config.DEFAULT_PROJECT_ID, 
        report_id, 
        from_date, 
        to_date 
      } = 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}/insights?project_id=${project_id}&report_id=${report_id}`;
        
        if (from_date) {
          url += `&from_date=${from_date}`;
        }
        if (to_date) {
          url += `&to_date=${to_date}`;
        }
        
        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 insights report:", error);
        const errorMessage = error instanceof Error ? error.message : String(error);
        return {
          content: [
            {
              type: "text",
              text: `Error querying insights report: ${errorMessage}`
            }
          ],
          isError: true
        };
      }
    }
  • Input schema definition for the 'query_insights_report' tool, specifying parameters like report_id (required), project_id, from_date, and to_date.
    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"]
    }
  • src/index.ts:570-595 (registration)
    Tool registration in the ListTools response, including name, description, and input schema for 'query_insights_report'.
    {
      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"]
      }
    }
  • src/index.ts:645-646 (registration)
    Dispatch case in the CallToolRequestSchema handler that routes calls to the 'query_insights_report' handler function.
    case "query_insights_report":
      return await handleQueryInsightsReport(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