振幅MCP服务器
A. 模型上下文协议(MCP) 用于将Amplitude分析集成到AI工作流中的服务器。该服务器允许像Claude这样的人工智能助手在Amplitude中跟踪事件、页面浏览量、用户注册、设置用户属性和跟踪收入。
版本1.0.1注: 工具名称现在包括 amplitude_ 前缀,以防止与其他分析MCP服务器的命名空间冲突。
目录
特性
- 在振幅中跟踪自定义事件
- 使用属性跟踪页面浏览量
- 跟踪用户注册并创建用户配置文件
- 更新现有用户属性
- 跟踪收入和购买情况
- 与Claude Desktop和其他MCP客户端简单集成
安装
先决条件
- Node.js 16或更高版本
- Amplitude API密钥(通过在 振幅)
NPM安装(推荐)
# Install globally
npm install -g amplitude-mcp-server
# Or use directly with npx
npx amplitude-mcp-server --api-key YOUR_AMPLITUDE_API_KEY手动安装
# Clone the repository
git clone https://github.com/ciaraadkins/amplitude-mcp-server.git
cd amplitude-mcp-server
# Install dependencies
npm install
# Run the server
node index.js --api-key YOUR_AMPLITUDE_API_KEY快速开始
要开始在Claude Desktop上使用Amplitude MCP服务器,请执行以下操作:
- 确保您的计算机上安装了Claude Desktop(从下载 claude.ai/下载)
- 创建或编辑Claude Desktop配置文件:
- macOS: ~/Library/Application Support/Claude/claude_desktop_config.json - 窗户: %AppData%\Claude\claude_desktop_config.json
- 添加Amplitude MCP服务器配置:
{
"mcpServers": {
"amplitude-analytics": {
"command": "npx",
"args": [
"-y",
"amplitude-mcp-server",
"--api-key",
"YOUR_AMPLITUDE_API_KEY"
]
}
}
}- 重新启动Claude Desktop并开始跟踪分析!
详细用法
使用克劳德桌面
按照快速入门部分所示设置配置文件后,您可以在与Claude的对话中直接使用振幅分析功能。
您可以使用的提示示例:
- “在Amplitude中为用户'user123'跟踪名为'document_generated'的自定义事件”
- “在Amplitude中跟踪定价页面的页面浏览量”
- “通过电子邮件在Amplitude中为John Doe创建新的用户配置文件john@example.com"
- “在Amplitude中更新用户'user123'的用户配置文件信息”
- “追踪以49.99美元购买产品X”
Claude将根据您的要求使用适当的振幅MCP工具。
与其他MCP客户端
此服务器使用标准的模型上下文协议,可以与任何MCP客户端集成:
- 启动服务器:
npx amplitude-mcp-server --api-key YOUR_AMPLITUDE_API_KEY- 使用stdio传输将MCP客户端连接到服务器
- 客户端可以发现并使用可用的工具(track_event、track_pageview、track_signup、set_user_properties、track_revenue)
工具参考
Amplitude MCP服务器提供以下工具:
amplitude_track_event
在振幅中跟踪自定义事件。
参数:
event_name(string,必填):要跟踪的事件的名称user_id(字符串,可选):用户标识符device_id(字符串,可选):设备标识符properties(对象,可选):要跟踪事件的其他属性user_properties(对象,可选):要使用此事件更新的用户属性
注: 要么 user_id 或 device_id 必须提供。
例子:
{
"event_name": "button_clicked",
"user_id": "user123",
"properties": {
"button_id": "submit_form",
"page": "checkout"
},
"user_properties": {
"last_action": "form_submit"
}
}amplitude_track_pageview
在振幅中跟踪页面查看事件。
参数:
page_name(string,必填):查看的页面名称user_id(字符串,可选):用户标识符device_id(字符串,可选):设备标识符properties(对象,可选):要跟踪事件的其他属性
注: 要么 user_id 或 device_id 必须提供。
例子:
{
"page_name": "homepage",
"user_id": "user123",
"properties": {
"referrer": "google.com",
"duration": 120
}
}amplitude_track_signup
跟踪注册事件并在Amplitude中创建用户配置文件。
参数:
user_name(string,必填):用户的全名email(string,必填):用户的电子邮件地址plan(字符串,可选):注册计划。默认为“免费”
例子:
{
"user_name": "John Doe",
"email": "john@example.com",
"plan": "premium"
}振幅_设置_用户_特性
在振幅中更新用户的配置文件属性。
参数:
user_id(字符串,必填):用户标识符properties(对象,必填):要设置的配置文件属性
例子:
{
"user_id": "user123",
"properties": {
"name": "John Doe",
"email": "john@example.com",
"plan": "premium",
"company": "Acme Inc"
}
}振幅_轨迹_位置
在Amplitude中跟踪收入事件。
参数:
user_id(字符串,必填):用户标识符product_id(string,必填):所购产品的标识符price(数字,必填):所购商品的价格quantity(数字,可选):购买的物品数量。默认为1revenue_type(字符串,可选):收入类型(例如,“购买”、“退款”、“订阅”)
例子:
{
"user_id": "user123",
"product_id": "premium_plan",
"price": 49.99,
"quantity": 1,
"revenue_type": "subscription"
}例子
以下是与Claude一起使用Amplitude MCP服务器的一些实际示例:
跟踪按钮点击
You: Can you track an event in Amplitude when a user clicks the submit button?
Claude: I'll track that event for you. Let me use the Amplitude analytics tool.
[Claude uses the amplitude_track_event tool with appropriate parameters]
Claude: I've successfully tracked the 'button_clicked' event in Amplitude with the properties you specified.创建用户配置文件
You: Create a new user profile in Amplitude for Sarah Johnson who signed up with sarah@example.com on the premium plan.
Claude: I'll create that user profile in Amplitude.
[Claude uses the amplitude_track_signup tool with appropriate parameters]
Claude: I've successfully tracked the signup for Sarah Johnson and created a profile in Amplitude with the premium plan.跟踪收入
You: Track a purchase of our premium plan for $99.99 by user12345.
Claude: I'll track that revenue event in Amplitude.
[Claude uses the amplitude_track_revenue tool with appropriate parameters]
Claude: I've successfully tracked revenue of $99.99 for the premium plan purchase by user12345.故障排除
常见问题
- 服务器未启动:
- 确保您提供了有效的Amplitude API密钥 - 检查Node.js是否已安装,以及是否为16或更高版本
- Claude Desktop未显示振幅工具:
- 验证claude_desktop_config.json文件语法 - 确保在编辑配置后重新启动了Claude Desktop - 检查服务器的路径是否正确
- 振幅中未出现的事件:
- 验证Amplitude API键是否正确 - 检查振幅项目设置,以确保正在接收数据 - 事件可能需要几分钟才能显示在振幅界面中
调试模式
要在调试模式下运行服务器以进行更详细的日志记录,请执行以下操作:
npx amplitude-mcp-server --api-key YOUR_AMPLITUDE_API_KEY --debug安全说明
- 您的Amplitude API密钥存储在Claude Desktop配置文件中。确保此文件具有适当的权限
- 考虑在生产环境中为敏感令牌使用环境变量
- 此服务器未实现速率限制-考虑为生产使用添加其他安全措施
- 事件直接发送到Amplitude的API-查看Amplitude的数据处理实践隐私政策
贡献
欢迎投稿!请随时提交拉取请求。
- 分叉存储库
- 创建功能分支(
git checkout -b feature/amazing-feature) - 提交您的更改(
git commit -m 'Add some amazing feature') - 推到分支(
git push origin feature/amazing-feature) - 打开拉取请求
许可证
此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。
