query_funnel_report
Analyze conversion rates through multi-step user flows and identify drop-off points in Mixpanel funnels using date ranges and event sequences.
Instructions
Get funnel conversion data. Useful for analyzing conversion rates through multi-step user flows and identifying drop-off points.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | No | The Mixpanel project ID. Optional since it has a default. | |
| from_date | Yes | The date in yyyy-mm-dd format to begin querying from (inclusive) | |
| to_date | Yes | The date in yyyy-mm-dd format to query to (inclusive) | |
| events | Yes | JSON array string of events that make up the funnel steps | |
| funnel_window | No | Number of days users have to complete the funnel | |
| interval | No | The time interval for funnel analysis |
Implementation Reference
- src/index.ts:1046-1100 (handler)The handler function that executes the tool logic by making a GET request to Mixpanel's /funnels API endpoint with authentication and parameters, returning the JSON response or error.async function handleQueryFunnelReport(args: any, config: any) { const { project_id = config.DEFAULT_PROJECT_ID, from_date, to_date, events, funnel_window = 14, interval = "day" } = 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}/funnels?project_id=${project_id}&from_date=${from_date}&to_date=${to_date}&events=${encodeURIComponent(events)}&funnel_window=${funnel_window}&interval=${interval}`; 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 funnel report:", error); const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error querying funnel report: ${errorMessage}` } ], isError: true }; } }
- src/index.ts:451-483 (schema)The tool definition including name, description, and inputSchema for validation in the MCP tools list.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"] }
- src/index.ts:629-630 (registration)The switch case in the tool request handler that dispatches to the handleQueryFunnelReport function.case "query_funnel_report": return await handleQueryFunnelReport(args, { SERVICE_ACCOUNT_USER_NAME, SERVICE_ACCOUNT_PASSWORD, DEFAULT_PROJECT_ID, MIXPANEL_BASE_URL });