top_event_property_values
Identify the top values of a specific property within Mixpanel data to analyze value distribution, uncover common categories, and plan targeted insights.
Instructions
Get the top values for a property. Useful for understanding the distribution of values for a specific property, identifying the most common categories or segments, and planning further targeted analyses.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| event | Yes | The event that you wish to get data for. Note: this is a single event name, not an array | |
| limit | No | The maximum number of values to return. Defaults to 255 | |
| name | Yes | The name of the property you would like to get data for | |
| project_id | No | The Mixpanel project ID | |
| workspace_id | No | The ID of the workspace if applicable |
Implementation Reference
- src/index.ts:1482-1540 (handler)The handler function for the 'top_event_property_values' tool. It makes a GET request to Mixpanel's API endpoint '/api/query/events/properties/values' with the provided event name and property name, authenticates using service account credentials, and returns the top property values or an error.async ({ project_id = DEFAULT_PROJECT_ID, workspace_id, event, name, limit }) => { try { // Create authorization header using base64 encoding of credentials const credentials = `${SERVICE_ACCOUNT_USER_NAME}:${SERVICE_ACCOUNT_PASSWORD}`; const encodedCredentials = Buffer.from(credentials).toString('base64'); // Construct base URL with required parameters let url = `https://mixpanel.com/api/query/events/properties/values?project_id=${project_id}&event=${encodeURIComponent(event)}&name=${encodeURIComponent(name)}`; // Add optional parameters if they exist if (workspace_id) url += `&workspace_id=${workspace_id}`; if (limit !== undefined) url += `&limit=${limit}`; // Set up request options const options = { method: 'GET', headers: { 'accept': 'application/json', 'authorization': `Basic ${encodedCredentials}` } }; // Make the API request const response = await fetch(url, options); if (!response.ok) { const errorText = await response.text(); throw new Error(`API request failed with status ${response.status}: ${errorText}`); } const data = await response.json(); return { content: [ { type: "text", text: JSON.stringify(data) } ] }; } catch (error) { console.error('Error fetching top event property values:', error); return { content: [ { type: "text", text: `Error fetching top event property values: ${error}` } ], isError: true }; } } );
- src/index.ts:1475-1481 (schema)Zod schema defining the input parameters for the 'top_event_property_values' tool, including project_id, workspace_id, event, name, and optional limit.{ project_id: z.string().describe("The Mixpanel project ID").optional(), workspace_id: z.string().describe("The ID of the workspace if applicable").optional(), event: z.string().describe("The event that you wish to get data for. Note: this is a single event name, not an array"), name: z.string().describe("The name of the property you would like to get data for"), limit: z.number().describe("The maximum number of values to return. Defaults to 255").optional(), },
- src/index.ts:1472-1540 (registration)Registration of the 'top_event_property_values' tool using server.tool(), including name, description, input schema, and handler function.server.tool( "top_event_property_values", "Get the top values for a property. Useful for understanding the distribution of values for a specific property, identifying the most common categories or segments, and planning further targeted analyses.", { project_id: z.string().describe("The Mixpanel project ID").optional(), workspace_id: z.string().describe("The ID of the workspace if applicable").optional(), event: z.string().describe("The event that you wish to get data for. Note: this is a single event name, not an array"), name: z.string().describe("The name of the property you would like to get data for"), limit: z.number().describe("The maximum number of values to return. Defaults to 255").optional(), }, async ({ project_id = DEFAULT_PROJECT_ID, workspace_id, event, name, limit }) => { try { // Create authorization header using base64 encoding of credentials const credentials = `${SERVICE_ACCOUNT_USER_NAME}:${SERVICE_ACCOUNT_PASSWORD}`; const encodedCredentials = Buffer.from(credentials).toString('base64'); // Construct base URL with required parameters let url = `https://mixpanel.com/api/query/events/properties/values?project_id=${project_id}&event=${encodeURIComponent(event)}&name=${encodeURIComponent(name)}`; // Add optional parameters if they exist if (workspace_id) url += `&workspace_id=${workspace_id}`; if (limit !== undefined) url += `&limit=${limit}`; // Set up request options const options = { method: 'GET', headers: { 'accept': 'application/json', 'authorization': `Basic ${encodedCredentials}` } }; // Make the API request const response = await fetch(url, options); if (!response.ok) { const errorText = await response.text(); throw new Error(`API request failed with status ${response.status}: ${errorText}`); } const data = await response.json(); return { content: [ { type: "text", text: JSON.stringify(data) } ] }; } catch (error) { console.error('Error fetching top event property values:', error); return { content: [ { type: "text", text: `Error fetching top event property values: ${error}` } ], isError: true }; } } );