Skip to main content
Glama
mendeel
by mendeel

query_profiles

Filter and retrieve user profiles from Mixpanel based on specific properties and criteria to analyze user segments and behaviors.

Instructions

Query user profiles with filtering. Useful for finding users based on profile properties and analyzing user segments.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of profiles to return
project_idNoThe Mixpanel project ID. Optional since it has a default.
selectNoJSON array string of properties to return. If not specified, returns all properties
whereNoJSON string representing the filter conditions for profiles

Implementation Reference

  • The primary handler function that executes the 'query_profiles' tool. It authenticates with Mixpanel using service account credentials, constructs the /engage API URL with provided where, select, and limit parameters, fetches the profile data, and returns it as JSON string in the MCP response format. Handles errors gracefully.
    async function handleQueryProfiles(args: any, config: any) { const { project_id = config.DEFAULT_PROJECT_ID, where, select, limit = 100 } = 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}/engage?project_id=${project_id}`; if (where) { url += `&where=${encodeURIComponent(where)}`; } if (select) { url += `&select=${encodeURIComponent(select)}`; } if (limit) { url += `&limit=${limit}`; } 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 profiles:", error); const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error querying profiles: ${errorMessage}` } ], isError: true }; } }
  • The input schema definition for the 'query_profiles' tool, specifying the expected parameters: project_id (optional string), where (string filter), select (string array), and limit (number). Used for validation in tool calls.
    inputSchema: { type: "object", properties: { project_id: { type: "string", description: "The Mixpanel project ID. Optional since it has a default." }, where: { type: "string", description: "JSON string representing the filter conditions for profiles" }, select: { type: "string", description: "JSON array string of properties to return. If not specified, returns all properties" }, limit: { type: "number", description: "Maximum number of profiles to return" } } } },
  • src/index.ts:622-623 (registration)
    Registration and dispatch of the 'query_profiles' handler in the switch statement within the CallToolRequestSchema request handler. Maps the tool name to its execution.
    case "query_profiles": return await handleQueryProfiles(args, { SERVICE_ACCOUNT_USER_NAME, SERVICE_ACCOUNT_PASSWORD, DEFAULT_PROJECT_ID, MIXPANEL_BASE_URL });
  • src/index.ts:376-401 (registration)
    Tool registration entry in the ListToolsRequestSchema response, defining the name, description, and input schema for 'query_profiles'.
    { name: "query_profiles", description: "Query user profiles with filtering. Useful for finding users based on profile properties and analyzing user segments.", inputSchema: { type: "object", properties: { project_id: { type: "string", description: "The Mixpanel project ID. Optional since it has a default." }, where: { type: "string", description: "JSON string representing the filter conditions for profiles" }, select: { type: "string", description: "JSON array string of properties to return. If not specified, returns all properties" }, limit: { type: "number", description: "Maximum number of profiles to return" } } } },

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