Skip to main content
Glama
mendeel

Mixpanel MCP

by mendeel

query_profiles

Filter and retrieve user profiles based on specific properties to analyze user segments and identify target audiences within Mixpanel.

Instructions

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

Input Schema

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

Implementation Reference

  • The handler function that implements the core logic of the 'query_profiles' tool. It constructs a request to Mixpanel's /engage endpoint using provided parameters (project_id, where, select, limit), authenticates with service account credentials, fetches user profiles, and returns the JSON data or an error.
    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 tool definition including name, description, and inputSchema for validating parameters (project_id, where, select, limit) when listing or calling the tool.
    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"
        }
      }
    }
  • src/index.ts:622-623 (registration)
    The switch case in the CallToolRequestHandler that registers and dispatches calls to the 'query_profiles' handler function.
    case "query_profiles":
      return await handleQueryProfiles(args, { SERVICE_ACCOUNT_USER_NAME, SERVICE_ACCOUNT_PASSWORD, DEFAULT_PROJECT_ID, MIXPANEL_BASE_URL });
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 of behavioral disclosure. It mentions 'query' and 'filtering,' which imply a read-only operation, but it doesn't specify whether this requires authentication, rate limits, pagination behavior, or what the output format looks like. For a tool with 4 parameters and no annotations, this leaves significant gaps in understanding its behavior.

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 concise and front-loaded with the core purpose in the first sentence. The second sentence adds useful context without redundancy. It's appropriately sized for the tool's complexity, though it could be slightly more structured by explicitly linking to parameters.

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 has 4 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain the return values, error conditions, or behavioral details like pagination or authentication needs. For a query tool with filtering capabilities, this lack of context makes it harder for an agent to use effectively.

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?

The schema description coverage is 100%, so the input schema already documents all parameters thoroughly. The description adds minimal value beyond the schema by mentioning 'filtering' and 'profile properties,' which loosely relate to the 'where' and 'select' parameters, but it doesn't provide additional syntax, examples, or constraints. This meets the baseline for high schema coverage.

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: 'Query user profiles with filtering.' It specifies the resource (user profiles) and the action (query with filtering). However, it doesn't explicitly differentiate from sibling tools like 'profile_event_activity' or 'list_saved_cohorts', which might also involve user data, so it doesn't reach the highest score.

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 some implied usage context: 'Useful for finding users based on profile properties and analyzing user segments.' This suggests when to use it, but it doesn't offer explicit guidance on when not to use it or name alternatives among the sibling tools, such as 'profile_event_activity' for event-related queries or 'list_saved_cohorts' for pre-defined groups.

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

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