Mixpanel MCP 服务器(模型上下文协议服务器)
一种模型上下文协议服务器,使像 Claude 这样的 AI 助手能够与 Mixpanel 分析进行交互,从而通过自然语言请求直接跟踪事件、页面浏览量、用户注册和更新用户资料。
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"mixpanel-analytics": {
"args": [
"-y",
"mixpanel-mcp-server",
"--token",
"YOUR_MIXPANEL_TOKEN"
],
"command": "npx"
}
}
}
服务介绍
Mixpanel MCP 服务器
一个用于将 Mixpanel 分析集成到 AI 工作流中的 Model Context Protocol (MCP) 服务器。此服务器允许像 Claude 这样的 AI 助手在 Mixpanel 中跟踪事件、页面浏览量、用户注册并更新用户资料。
版本 2.0.1 注意事项: 工具名称现在包含 mixpanel_ 前缀,以防止与其他分析 MCP 服务器的命名空间冲突。
目录
特性
- 在 Mixpanel 中跟踪自定义事件
- 跟踪带有引荐来源信息的页面浏览量
- 跟踪用户注册并创建用户资料
- 更新现有用户资料
- 与 Claude Desktop 和其他 MCP 客户端简单集成
安装
先决条件
- Node.js 16 或更高版本
- 一个 Mixpanel 项目令牌(通过在 Mixpanel 注册获取)
NPM 安装(推荐)
# Install globally
npm install -g mixpanel-mcp-server
# Or use directly with npx
npx mixpanel-mcp-server --token YOUR_MIXPANEL_TOKEN
手动安装
# Clone the repository
git clone https://github.com/yourusername/mixpanel-mcp-server.git
cd mixpanel-mcp-server
# Install dependencies
npm install
# Run the server
node index.js --token YOUR_MIXPANEL_TOKEN
快速开始
要开始使用 Mixpanel MCP 服务器与 Claude Desktop:
-
确保您的计算机上已安装 Claude Desktop(从 claude.ai/download 下载)
-
创建或编辑 Claude Desktop 配置文件:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%AppData%\Claude\claude_desktop_config.json
- macOS:
-
添加 Mixpanel MCP 服务器配置:
{
"mcpServers": {
"mixpanel-analytics": {
"command": "npx",
"args": [
"-y",
"mixpanel-mcp-server",
"--token",
"YOUR_MIXPANEL_TOKEN"
]
}
}
}
- 重启 Claude Desktop 并开始跟踪分析数据!
详细使用说明
与 Claude Desktop 一起使用
按照“快速开始”部分所示设置配置文件后,您可以在与 Claude 的对话中直接使用 Mixpanel 分析功能。
您可以使用的提示示例:
- "为用户 'user123' 在 Mixpanel 中跟踪名为 'document_generated' 的自定义事件"
- "在 Mixpanel 中跟踪主页的页面浏览量"
- "为 John Doe 创建一个新的 Mixpanel 用户资料,邮箱为 john@example.com"
- "在 Mixpanel 中更新用户 'user123' 的用户资料信息"
Claude 将根据您的请求使用适当的 Mixpanel MCP 工具。
与其他 MCP 客户端一起使用
此服务器使用标准的 Model Context Protocol,并可以与任何 MCP 客户端集成:
-
启动服务器:
npx mixpanel-mcp-server --token YOUR_MIXPANEL_TOKEN -
使用 stdio 传输方式将您的 MCP 客户端连接到服务器
-
客户端可以发现并使用可用工具(mixpanel_track_event, mixpanel_track_pageview, mixpanel_track_signup, mixpanel_set_user_profile)
工具参考
Mixpanel MCP 服务器提供了以下工具:
mixpanel_track_event
在 Mixpanel 中跟踪自定义事件。
参数:
event_name(字符串,必填):要跟踪的事件名称distinct_id(字符串,可选):用户标识符。默认为 'anonymous'properties(对象,可选):与事件一起跟踪的附加属性
示例:
{
"event_name": "button_clicked",
"distinct_id": "user123",
"properties": {
"button_id": "submit_form",
"page": "checkout"
}
}
mixpanel_track_pageview
在 Mixpanel 中跟踪页面浏览事件。
参数:
page_name(字符串,必填):查看的页面名称distinct_id(字符串,可选):用户标识符。默认为 'anonymous'referrer(字符串,可选):引荐页面
示例:
{
"page_name": "homepage",
"distinct_id": "user123",
"referrer": "google.com"
}
mixpanel_track_signup
在 Mixpanel 中跟踪注册事件并创建用户档案。
参数:
user_name(字符串,必填):用户的全名email(字符串,必填):用户的电子邮件地址plan(字符串,可选):注册计划。默认为 'free'
示例:
{
"user_name": "John Doe",
"email": "john@example.com",
"plan": "premium"
}
mixpanel_set_user_profile
在 Mixpanel 中更新用户的档案属性。
参数:
distinct_id(字符串,必填):用户标识符properties(对象,必填):要设置的档案属性
示例:
{
"distinct_id": "user123",
"properties": {
"$name": "John Doe",
"$email": "john@example.com",
"plan": "premium",
"company": "Acme Inc"
}
}
示例
以下是一些使用 Mixpanel MCP 服务器和 Claude 的实际示例:
跟踪按钮点击
You: Can you track an event in Mixpanel when a user clicks the submit button?
Claude: I'll track that event for you. Let me use the Mixpanel analytics tool.
[Claude uses the mixpanel_track_event tool with appropriate parameters]
Claude: I've successfully tracked the 'button_clicked' event in Mixpanel with the properties you specified.
创建用户档案
You: Create a new user profile in Mixpanel for Sarah Johnson who signed up with sarah@example.com on the premium plan.
Claude: I'll create that user profile in Mixpanel.
[Claude uses the mixpanel_track_signup tool with appropriate parameters]
Claude: I've successfully tracked the signup for Sarah Johnson and created a profile in Mixpanel with the premium plan.
故障排除
常见问题
-
服务器无法启动:
- 确保您提供了有效的 Mixpanel 令牌
- 检查 Node.js 是否已安装且版本为 16 或更高
-
Claude Desktop 未显示 Mixpanel 工具:
- 验证您的 claude_desktop_config.json 文件语法
- 确保在编辑配置后重启了 Claude Desktop
- 检查服务器路径是否正确
-
事件未出现在 Mixpanel 中:
- 验证您的 Mixpanel 令牌是否正确
- 检查 Mixpanel 项目设置以确保正在接收数据
- 事件可能需要几分钟才能出现在 Mixpanel 界面中
调试模式
要以调试模式运行服务器以获得更详细的日志记录:
npx mixpanel-mcp-server --token YOUR_MIXPANEL_TOKEN --debug
安全注意事项
- 您的 Mixpanel 令牌存储在 Claude Desktop 配置文件中。确保此文件具有适当的权限
- 在生产环境中考虑使用环境变量来处理敏感令牌
- 该服务器未实现速率限制 - 考虑在生产环境中添加额外的安全措施
- 事件直接发送到 Mixpanel 的 API - 查看 Mixpanel 的隐私政策以了解数据处理实践
贡献
欢迎贡献!请随时提交 Pull Request。
- 叉仓库
- 创建您的功能分支 (
git checkout -b feature/amazing-feature) - 提交您的更改 (
git commit -m 'Add some amazing feature') - 推送到分支 (
git push origin feature/amazing-feature) - 打开 Pull Request
许可证
该项目采用 MIT 许可证 - 详情请参阅 LICENSE 文件。