Mixpanel分析集成服务器

一个用于将Mixpanel分析功能集成到AI工作流中的服务器,支持跟踪事件、页面浏览、用户注册和更新用户档案。

  • by ciaraadkins
  • JavaScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 ciaraadkins/mixpanel-mcp-server

使用说明

Mixpanel MCP服务器

A. 模型上下文协议(MCP) 用于将Mixpanel分析集成到AI工作流中的服务器。该服务器允许像Claude这样的人工智能助手跟踪事件、页面浏览量、用户注册,并在Mixpanel中更新用户配置文件。

2.0.1版本注: 工具名称现在包括 mixpanel_ 前缀,以防止与其他分析MCP服务器的命名空间冲突。

目录

特性

  • 在Mixpanel中跟踪自定义事件
  • 使用推荐人信息跟踪页面浏览量
  • 跟踪用户注册并创建用户配置文件
  • 更新现有用户配置文件
  • 与Claude Desktop和其他MCP客户端简单集成

安装

先决条件

  • Node.js 16或更高版本
  • 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

快速开始

要开始在Claude Desktop上使用Mixpanel MCP服务器,请执行以下操作:

  1. 确保您的计算机上安装了Claude Desktop(从下载 claude.ai/下载)

  2. 创建或编辑Claude Desktop配置文件:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • 窗户: %AppData%\Claude\claude_desktop_config.json
  3. 添加Mixpanel MCP服务器配置:

{
  "mcpServers": {
    "mixpanel-analytics": {
      "command": "npx",
      "args": [
        "-y",
        "mixpanel-mcp-server",
        "--token",
        "YOUR_MIXPANEL_TOKEN"
      ]
    }
  }
}
  1. 重新启动Claude Desktop并开始跟踪分析!

详细用法

使用克劳德桌面

按照快速入门部分所示设置配置文件后,您可以在与Claude的对话中直接使用Mixpanel分析功能。

您可以使用的提示示例:

  • “在Mixpanel中为用户'user123'跟踪名为'document_generated'的自定义事件”
  • “在Mixpanel中跟踪主页的页面浏览量”
  • “使用电子邮件在Mixpanel中为John Doe创建新的用户配置文件john@example.com"
  • “更新Mixpanel中用户'user123'的用户配置文件信息”

Claude将根据您的要求使用适当的Mixpanel MCP工具。

与其他MCP客户端

此服务器使用标准的模型上下文协议,可以与任何MCP客户端集成:

  1. 启动服务器:

    npx mixpanel-mcp-server --token YOUR_MIXPANEL_TOKEN
    
  2. 使用stdio传输将MCP客户端连接到服务器

  3. 客户端可以发现并使用可用的工具(mixpanel_track_event、mixpanel_track_pageview、mixpanel_track_signup、mixpanel_set_user_profile)

工具参考

Mixpanel MCP服务器提供以下工具:

mixpanel_track_event

在Mixpanel中跟踪自定义事件。

参数:

  • event_name (string,必填):要跟踪的事件的名称
  • distinct_id (字符串,可选):用户标识符。默认为“匿名”
  • properties (对象,可选):要跟踪事件的其他属性

例子:

{
  "event_name": "button_clicked",
  "distinct_id": "user123",
  "properties": {
    "button_id": "submit_form",
    "page": "checkout"
  }
}

mixpanel_track_pageview

在Mixpanel中跟踪页面浏览事件。

参数:

  • page_name (string,必填):查看的页面名称
  • distinct_id (字符串,可选):用户标识符。默认为“匿名”
  • referrer (字符串,可选):引用页面

例子:

{
  "page_name": "homepage",
  "distinct_id": "user123",
  "referrer": "google.com"
}

mixpanel_track_注册

跟踪注册事件并在Mixpanel中创建用户配置文件。

参数:

  • user_name (string,必填):用户的全名
  • email (string,必填):用户的电子邮件地址
  • plan (字符串,可选):注册计划。默认为“免费”

例子:

{
  "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"
  }
}

例子

以下是与Claude一起使用Mixpanel MCP服务器的一些实际示例:

跟踪按钮点击

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.

故障排除

常见问题

  1. 服务器未启动:

    • 确保您提供了有效的Mixpanel令牌
    • 检查Node.js是否已安装,以及是否为16或更高版本
  2. Claude Desktop未显示Mixpanel工具:

    • 验证claude_desktop_config.json文件语法
    • 确保在编辑配置后重新启动了Claude Desktop
    • 检查服务器的路径是否正确
  3. Mixpanel中未显示的事件:

    • 验证您的Mixpanel令牌是否正确
    • 检查您的Mixpanel项目设置,以确保收到数据
    • 事件可能需要几分钟才能出现在Mixpanel界面中

调试模式

要在调试模式下运行服务器以进行更详细的日志记录,请执行以下操作:

npx mixpanel-mcp-server --token YOUR_MIXPANEL_TOKEN --debug

安全说明

  • 您的Mixpanel令牌存储在Claude Desktop配置文件中。确保此文件具有适当的权限
  • 考虑在生产环境中为敏感令牌使用环境变量
  • 此服务器未实现速率限制-考虑为生产使用添加其他安全措施
  • 事件直接发送到Mixpanel的API-查看Mixpaned的数据处理实践隐私政策

贡献

欢迎投稿!请随时提交拉取请求。

  1. 分叉存储库
  2. 创建功能分支(git checkout -b feature/amazing-feature)
  3. 提交您的更改(git commit -m 'Add some amazing feature')
  4. 推到分支(git push origin feature/amazing-feature)
  5. 打开拉取请求

许可证

此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。