Skip to main content
Glama
dragonkhoi

mixpanel

query_insights_report

Access pre-configured Insights reports to retrieve saved analyses, standardized metrics, and complex visualizations for your Mixpanel project data.

Instructions

Get data from your Insights reports. Useful for accessing saved analyses, sharing standardized metrics across teams, and retrieving complex pre-configured visualizations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bookmark_idYesThe ID of your Insights report
project_idNoThe Mixpanel project ID. Optional since it has a default.
workspace_idNoThe ID of the workspace if applicable

Implementation Reference

  • Full implementation of the 'query_insights_report' MCP tool, including registration, input schema validation with Zod, and the handler function that authenticates with Mixpanel service account credentials and fetches Insights report data via the /api/query/insights endpoint using the provided bookmark_id.
    server.tool(
      "query_insights_report",
      "Get data from your Insights reports. Useful for accessing saved analyses, sharing standardized metrics across teams, and retrieving complex pre-configured visualizations.",
      {
        project_id: z.string().describe("The Mixpanel project ID. Optional since it has a default.").optional(),
        workspace_id: z.string().optional().describe("The ID of the workspace if applicable"),
        bookmark_id: z.string().describe("The ID of your Insights report"),
      },
      async ({ project_id = DEFAULT_PROJECT_ID, workspace_id, bookmark_id }) => {
        try {
          const credentials = `${SERVICE_ACCOUNT_USER_NAME}:${SERVICE_ACCOUNT_PASSWORD}`;
          const encodedCredentials = Buffer.from(credentials).toString('base64');
          
          const queryParams = new URLSearchParams({
            project_id: project_id || '',
            bookmark_id: bookmark_id
          });
          
          if (workspace_id) {
            queryParams.append('workspace_id', workspace_id);
          }
          
          const url = `https://mixpanel.com/api/query/insights?${queryParams.toString()}`;
          
          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 fetching Mixpanel insights:", error);
          const errorMessage = error instanceof Error ? error.message : String(error);
          return {
            content: [
              {
                type: "text",
                text: `Error fetching Mixpanel insights: ${errorMessage}`
              }
            ],
            isError: true
          };
        }
      }
    );
  • Zod schema defining the input parameters for the query_insights_report tool: project_id (optional), workspace_id (optional), bookmark_id (required).
    {
      project_id: z.string().describe("The Mixpanel project ID. Optional since it has a default.").optional(),
      workspace_id: z.string().optional().describe("The ID of the workspace if applicable"),
      bookmark_id: z.string().describe("The ID of your Insights report"),
    },
  • src/index.ts:417-480 (registration)
    Registration of the 'query_insights_report' tool on the MCP server using server.tool(), including name, description, schema, and handler.
    server.tool(
      "query_insights_report",
      "Get data from your Insights reports. Useful for accessing saved analyses, sharing standardized metrics across teams, and retrieving complex pre-configured visualizations.",
      {
        project_id: z.string().describe("The Mixpanel project ID. Optional since it has a default.").optional(),
        workspace_id: z.string().optional().describe("The ID of the workspace if applicable"),
        bookmark_id: z.string().describe("The ID of your Insights report"),
      },
      async ({ project_id = DEFAULT_PROJECT_ID, workspace_id, bookmark_id }) => {
        try {
          const credentials = `${SERVICE_ACCOUNT_USER_NAME}:${SERVICE_ACCOUNT_PASSWORD}`;
          const encodedCredentials = Buffer.from(credentials).toString('base64');
          
          const queryParams = new URLSearchParams({
            project_id: project_id || '',
            bookmark_id: bookmark_id
          });
          
          if (workspace_id) {
            queryParams.append('workspace_id', workspace_id);
          }
          
          const url = `https://mixpanel.com/api/query/insights?${queryParams.toString()}`;
          
          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 fetching Mixpanel insights:", error);
          const errorMessage = error instanceof Error ? error.message : String(error);
          return {
            content: [
              {
                type: "text",
                text: `Error fetching Mixpanel insights: ${errorMessage}`
              }
            ],
            isError: true
          };
        }
      }
    );
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. It mentions the tool retrieves data from saved reports but doesn't disclose behavioral traits like whether it's read-only, requires authentication, has rate limits, returns paginated results, or what format the data comes in. For a data retrieval tool with zero annotation coverage, 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 sized (two sentences) and front-loaded with the core purpose. The second sentence adds useful context about use cases without being verbose. Every sentence earns its place, though it could be slightly more structured.

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 (data retrieval with 3 parameters), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the returned data looks like, error conditions, or important behavioral constraints. For a query tool in a crowded namespace, more context is needed.

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. The description doesn't add any parameter-specific information beyond what's in the schema (e.g., it doesn't explain what an 'Insights report' is or how to find bookmark_id). Baseline 3 is appropriate when the schema does the heavy lifting.

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 data from your Insights reports' (verb+resource). It distinguishes from siblings by specifying 'Insights reports' rather than events, funnels, or profiles, though it doesn't explicitly contrast with similar tools like query_frequency_report or query_funnel_report.

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 accessing saved analyses, sharing standardized metrics across teams, and retrieving complex pre-configured visualizations.' This suggests when to use it (for saved/pre-configured reports) but doesn't explicitly state when not to use it or name alternatives among the many sibling query tools.

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