query_insights_report
Retrieve pre-configured analytics reports and dashboards from Mixpanel to access saved insights with custom date ranges.
Instructions
Get saved insights reports. Useful for accessing pre-configured analytics reports and dashboards.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| from_date | No | The date in yyyy-mm-dd format to begin querying from (inclusive) | |
| project_id | No | The Mixpanel project ID. Optional since it has a default. | |
| report_id | Yes | The ID of the saved insights report to retrieve | |
| to_date | No | The date in yyyy-mm-dd format to query to (inclusive) |
Implementation Reference
- src/index.ts:1313-1372 (handler)The handler function that executes the tool logic by making a GET request to the Mixpanel /insights endpoint with the provided report_id and date range.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 }; } }
- src/index.ts:571-594 (schema)Input schema definition for the query_insights_report tool, specifying parameters like report_id (required), project_id, from_date, and to_date.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)Registration in the tool dispatch switch case within the CallToolRequestSchema handler, routing calls to the specific handler function.case "query_insights_report": return await handleQueryInsightsReport(args, { SERVICE_ACCOUNT_USER_NAME, SERVICE_ACCOUNT_PASSWORD, DEFAULT_PROJECT_ID, MIXPANEL_BASE_URL });