farther-ben/api-client-mixpanel
If you are the rightful owner of api-client-mixpanel and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
A Model Context Protocol (MCP) server for interacting with the Mixpanel Analytics API, enabling AI assistants to query and manage analytics data.
Mixpanel MCP Server
A Model Context Protocol (MCP) server that provides tools for interacting with the Mixpanel Analytics API. This server enables AI assistants like Claude to query analytics data, export events, and manage data schemas directly from Mixpanel.
Features
Query API Tools
- Query Insights: Analyze event trends over time with aggregated counts, unique users, or averages
- Query Funnels: Analyze conversion rates and drop-off through event sequences
- Query Retention: Measure user return rates and cohort analysis
- Query Segmentation: Break down events by property values to understand user segments
Export API Tools
- Export Events: Download raw event data with all properties for custom analysis
Lexicon API Tools
- List Schemas: Browse all event and property definitions
- Get Schema: Retrieve specific schema details
- Create Schemas: Define or update event and property metadata
- Delete Schema: Remove schema definitions
Installation
Prerequisites
- Node.js 18 or higher
- A Mixpanel account with API access
- Service Account credentials from Mixpanel
Setup
-
Clone or create the project:
cd api-client-mixpanel npm install -
Build the TypeScript project:
npm run build
Configuration
Get Mixpanel Credentials
-
Create a Service Account:
- Log in to Mixpanel
- Navigate to Organization Settings → Service Accounts
- Click Create Service Account
- Set appropriate permissions and project access
- Save the secret immediately (you won't be able to view it again)
-
Find your Project ID:
- Go to Project Settings in Mixpanel
- Copy your Project ID from the project settings page
-
Determine your data residency:
- Check which region your Mixpanel project uses (US, EU, or India)
Environment Variables
Set the following environment variables:
export MIXPANEL_SERVICE_ACCOUNT_USERNAME="your-service-account-username"
export MIXPANEL_SERVICE_ACCOUNT_SECRET="your-service-account-secret"
export MIXPANEL_PROJECT_ID="your-project-id"
export MIXPANEL_REGION="us" # Options: us, eu, india (default: us)
Usage with Claude Desktop
Configure Claude Desktop
Add the server to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"mixpanel": {
"command": "node",
"args": ["/Users/ben/code/api-client-mixpanel/dist/index.js"],
"env": {
"MIXPANEL_SERVICE_ACCOUNT_USERNAME": "your-service-account-username",
"MIXPANEL_SERVICE_ACCOUNT_SECRET": "your-service-account-secret",
"MIXPANEL_PROJECT_ID": "your-project-id",
"MIXPANEL_REGION": "us"
}
}
}
}
Restart Claude Desktop
After updating the configuration, restart Claude Desktop to load the MCP server.
Available Tools
query_insights
Analyze event trends over time.
Parameters:
from_date(required): Start date in YYYY-MM-DD formatto_date(required): End date in YYYY-MM-DD formatevent(optional): Event name to querytype(optional): Query type (general, unique, average)unit(optional): Time unit (day, week, month)where(optional): Filter expressioninterval(optional): Number of units per interval
Example:
Show me signup trends for the last 30 days
query_funnel
Analyze conversion rates through event sequences.
Parameters:
from_date(required): Start date in YYYY-MM-DD formatto_date(required): End date in YYYY-MM-DD formatfunnel_id(optional): ID of saved funnelevents(optional): Array of event names for funnel stepson(optional): Property to segment bywhere(optional): Filter expressionunit(optional): Time unit (day, week, month)
Example:
What's the conversion rate from signup to first purchase in the last 7 days?
query_retention
Measure user return rates.
Parameters:
from_date(required): Start date in YYYY-MM-DD formatto_date(required): End date in YYYY-MM-DD formatretention_type(optional): Type (birth, compounding)born_event(optional): First event defining cohortevent(optional): Return event to measureunit(optional): Time unit (day, week, month)
Example:
Show me 7-day retention for users who signed up in the last month
query_segmentation
Break down events by property values.
Parameters:
from_date(required): Start date in YYYY-MM-DD formatto_date(required): End date in YYYY-MM-DD formatevent(required): Event name to segmenttype(optional): Aggregation type (general, unique, average)on(optional): Property to segment bywhere(optional): Filter expressionlimit(optional): Max number of segments
Example:
Break down page views by country for the last week
export_events
Export raw event data.
Parameters:
from_date(required): Start date in YYYY-MM-DD formatto_date(required): End date in YYYY-MM-DD formatevent(optional): Array of event names to filterwhere(optional): Filter expressionlimit(optional): Maximum number of events
Example:
Export all purchase events from yesterday
list_schemas
List all schemas in Lexicon.
Parameters:
entityType(optional): Filter by type (event, property, profile_property, group_property)
Example:
Show me all event schemas
get_schema
Get details of a specific schema.
Parameters:
entityType(required): Entity typename(required): Name of event or property
Example:
Get the schema for the "Purchase" event
create_schemas
Create or update schemas.
Parameters:
entries(required): Array of schema definitions
Example:
Create a schema for a new "User Upgraded" event with description and tags
delete_schema
Delete a schema.
Parameters:
entityType(required): Entity typename(required): Name of event or property
Example:
Delete the schema for the deprecated "Old Event" event
Rate Limits
The Mixpanel API has the following rate limits:
- 60 queries per hour per project
- Maximum 5 concurrent queries
This server automatically handles rate limiting by queuing requests and respecting these limits.
Development
Run in development mode:
npm run dev
Build:
npm run build
Watch mode:
npm run watch
Troubleshooting
Authentication Errors
- Verify your Service Account credentials are correct
- Ensure the Service Account has access to the project
- Check that credentials haven't expired (if you set an expiration)
Regional Errors
- Confirm your
MIXPANEL_REGIONmatches your project's data residency - US projects use
us, EU projects useeu, India projects useindia
Rate Limit Errors
- The server automatically handles rate limiting
- If you consistently hit limits, consider:
- Reducing query frequency
- Using broader date ranges instead of multiple narrow queries
- Contacting Mixpanel support for increased limits
Connection Issues
- Restart Claude Desktop after configuration changes
- Check the logs in Claude Desktop's developer console
- Verify the path to
dist/index.jsis correct in your config
Architecture
src/
├── index.ts # Main MCP server and tool registration
├── config.ts # Configuration and authentication
├── mixpanel-client.ts # HTTP client with rate limiting
├── types/
│ └── mixpanel.ts # TypeScript type definitions
└── tools/
├── query.ts # Query API tools (insights, funnels, retention, segmentation)
├── export.ts # Export API tools
└── lexicon.ts # Lexicon API tools (schema management)
License
MIT