Communitygithub.com

amplitude/builder-skills

为基于Node/TypeScript的MCP服务器接入Amplitude的@amplitude/mcp-analytics SDK,将工具调用、会话和推理过程作为Amplitude事件进行追踪。

builder-skills 是什么?

该技能用于将Amplitude分析功能集成到MCP服务器中,使每个工具调用、会话和推理过程都成为可追踪的Amplitude事件,并能够与产品现有的Web/移动端Amplitude数据无缝关联。它支持Claude Code、Cursor、Codex等AI代理平台,确保代理流量能够正确归因到Amplitude。 配置过程分为四个步骤:步骤1(必需)安装SDK并追踪工具调用,步骤2(必需)正确设置用户身份以确保事件与产品数据可关联,步骤3(推荐)捕获推理过程以了解代理为何调用工具,步骤4(推荐,仅当服务器返回链接时)为出站链接添加UTM参数以便归因代理流量。 该技能强调始终参考最新的SDK README(https://github.com/amplitude/Amplitude-MCP-Analytics-Node),因为SDK处于预览阶段且快速迭代。它不依赖记忆的代码片段,而是指导用户阅读SDK文档中的相关部分,并提供了SDK文档未覆盖的服务器端和Web端集成细节。

兼容平台✓Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/amplitude/builder-skills/tree/HEAD/engineering-skills/skills/instrument-mcp-server

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Amplitude MCP 分析设置

为MCP服务器添加埋点,使每个工具调用都成为Amplitude事件,并能够与产品其余部分的Amplitude数据(留存、收入、Web/移动端使用情况)关联起来。

权威SDK参考文档位于包README中: https://github.com/amplitude/Amplitude-MCP-Analytics-Node (npm: @amplitude/mcp-analytics) SDK处于预览阶段且演进迅速——务必获取最新的README并按照其说明进行安装、API形状、配置和默认事件的操作。 不要依赖记忆中的代码片段或本技能的摘要作为SDK API细节的依据;如有冲突,以README为准。

共分四个步骤。步骤1–2是必需的,并在README中有文档说明——本技能告诉您应遵循哪些章节以及应验证哪些不变条件。步骤3–4是强烈推荐的,并在此处完整记录,因为它们需要修改SDK之外的内容(服务器的工具模式及产品的Web应用),而SDK README有意未涵盖这些内容。

按顺序执行:步骤1(工具调用)→ 步骤2(身份)→ 步骤3(推理过程)→ 步骤4(UTM,仅当服务器返回链接时)。在确认一切“完成”之前,请先正确设置身份——下游所有内容都依赖于此。

开始之前

确认:

  1. 这是一个基于 @modelcontextprotocol/sdk 构建的 Node/TypeScript MCP服务器。此SDK不支持其他语言/运行时。
  2. 用户拥有(或可以获得)要发送事件的目标项目的 Amplitude API密钥 。
  3. 仓库使用的包管理器(pnpm/npm/yarn)——据此调整安装命令。

步骤 1 — 安装SDK并追踪工具调用(必需)

获取README并遵循其 安装 和 快速入门 部分。始终安装最新的发布版本(例如 pnpm add @amplitude/mcp-analytics@latest)——永远不要从记忆中固定版本,也不要复现本技能中的安装命令。

连接完成后需要验证的不变条件(README解释了每一项):

  • analytics.instrumentServer(server, ...) 在 server.connect() 之前 运行——顺序很重要。
  • 每个 工具处理程序都用 analytics.instrumentTool(...) 包装。未包装的工具不会被追踪。该包装器与处理程序具有完全相同的形状,并且如果服务器从未绑定,则它是一个空操作直通,因此防御性地包装是安全的。
  • 默认事件都带有 [MCP] 前缀,因此它们永远不会与产品现有的Amplitude事件冲突。有关当前的事件集和属性,请参阅README的 默认事件 表格(以及仓库中的 docs/events.md)。

可选:通过 instrumentTool/instrumentServer 上的 extra 附加稳定的自定义维度(套餐层级、团队、功能开关)——请参阅README的 自定义事件属性 部分。

步骤 2 — 正确设置身份(必需,在将步骤1称为“完成”之前执行此操作)

MCP事件必须携带产品已经通过Web/移动端发送到Amplitude的 相同的 user_id 。跳过此步骤,MCP使用情况将显示为一个无法与产品数据关联的孤立人群——这会使集成的大部分意义失效。

请遵循README的 身份 部分以了解当前API:它提供了服务器级绑定、处理程序内部的 setIdentity() 方法,以及基于请求的 authInfo 声明的可选 resolveIdentity 映射。选择适合服务器认证模型的方案。

需要向用户说明的一个行为:完全匿名、无标识的事件 默认被丢弃(不计算为用户),除非通过 emitAnonymousEvent: true 明确选择加入以进行仅聚合跟踪——在启用此选项之前请询问用户,因为它会改变计数内容。

步骤 3 — 捕获推理过程(推荐)

与人类点击按钮不同,代理可以告诉您 为什么 它调用了某个工具。捕获这个信息可以将数据从“发生了什么”转变为“用户试图做什么”。

SDK端只需一次调用(analytics.setRationale(...)——请参阅README的 推理过程 部分),但SDK本身不会从工具输入中读取推理过程:推理过程如何到达服务器是本技能实现的服务器端约定。 经过实战检验的模式是模式注入——向 每个 工具的输入模式添加一个可选的 rationale 字段。由于参数已在代理读取的模式中进行描述,代理会在无需任何客户端更改的情况下,在所有客户端上主动填写它:

// 添加到每个工具的输入模式(zod示例):
rationale: z
  .string()
  .optional()
  .describe(
    '简要说明您为何调用此工具以及您期望从结果中学到什么。',
  ),

然后在被检测的处理程序内部读取它并将其传递给SDK:

analytics.instrumentTool(async (args, extra) => {
  if (typeof args.rationale === 'string') {
    analytics.setRationale(args.rationale);
  }
  return doWork(args);
}, { name: 'search' });

使该字段为可选项意味着当代理省略它时不会破坏任何功能。它作为保留的 [MCP] Rationale 属性发出(截断为1,000个字符;最后一次写入生效)。值得在每个工具上执行此操作,而不仅仅是示例。

步骤 4 — 为出站链接添加UTM参数(推荐,仅当服务器返回URL时)

此步骤完全在SDK之外——它改变了服务器构建URL的方式,并依赖于产品Web端的分析。SDK README 未 涵盖此内容。

如果任何工具响应包含链接(仪表盘、文档、产品页面),请在链接离开服务器之前添加标签,以便点击归因于MCP/代理流量,而不是显示为直接访问:

function addUtmParams(url: string, clientName?: string): string {
  const u = new URL(url);
  u.searchParams.append('utm_source', 'mcp');
  u.searchParams.append('utm_medium', 'referral');
  // 连接的客户端(例如"Claude"、"Cursor"),如果您知道的话:
  u.searchParams.append('utm_content', clientName ?? 'unknown');
  return u.toString();
}

将工具响应中所有构建URL的路径都通过像这样的一个中央函数——单个未添加标签的链接会破坏该流程的归因效果。

前提条件(明确告知用户): 这仅在他们的Web分析工具在页面浏览事件(或他们的网站在着陆时触发的任何其他事件)中捕获UTM参数时才有效。Amplitude的Browser SDK 2默认执行此操作——请参阅 追踪营销归因(UTM、引荐来源和点击ID参数开箱即用即可捕获)。如果他们使用自定义的页面浏览追踪器,则需要确认UTM值也落到了这些事件上,否则就没有什么可以将MCP标签点击关联起来了。

相关的Amplitude文档:

完成埋点后

一旦事件开始流动,让编码代理指向Amplitude发布的 analyze-mcp-server 技能,以运行意图聚类并展示按意图分类的工具调用错误模式。(如果该项目已安装 mcp-intent-error-analysis 技能,则使用该技能——一旦用户有数据流动并希望进行分析时使用,而不是在此处重复该分析。)

需要标记的常见错误

  • 遵循过时的API代码片段,而不是当前的README——请获取最新版本;SDK处于预览阶段且变化迅速。
  • 安装固定/较旧的版本,而不是最新版本。
  • 在 server.connect() 之后调用 instrumentServer() ——必须在之前调用。
  • 包装了某些工具处理程序,但没有包装其他工具——每个工具都需要 instrumentTool。
  • 发送的 user_id 与Web/移动端使用的 user_id 不匹配——破坏了可关联性,而这正是集成的全部意义所在。
  • 在用户不理解的情况下启用 emitAnonymousEvent: true,这会使聚合计数因无标识流量而膨胀。
  • 忘记UTM的前提条件(Web端捕获),并假设仅添加标签就足够了。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

amplitude/builder-skills

Performs deep analysis of a specific Amplitude chart to explain trends, anomalies, and likely drivers. Use when a metric looks unusual, investigating a spike or drop, or understanding the "why" behind numbers.

amplitude/builder-skills

Deeply analyze Amplitude dashboards by analyzing key charts, surfacing top areas for concern and takeaways, identify anomalies, then explain changes using customer feedback trends.

amplitude/builder-skills

Designs A/B tests with proper metrics and variants, analyzes running or completed experiments, and interprets results with statistical rigor. Use when setting up experiments, checking experiment status, analyzing results, or making ship decisions.

amplitude/builder-skills

Synthesizes customer feedback into actionable themes including feature requests, bugs, pain points, and praise. Use when planning product roadmap, understanding user sentiment, investigating specific issues, or preparing voice-of-customer reports.

amplitude/builder-skills

Analyze MCP server usage instrumented with Amplitude's MCP Analytics SDK: break usage and errors down by tool, read the rationales within each tool to see what callers are trying to do, and produce a prioritized write-up of actionable fixes. Use this skill whenever the user asks to understand how their MCP server is being used, what agents/users are trying to do with it, why tool calls are failing, what to fix or improve in their MCP server, or asks for an "MCP usage report", "tool error analysis", "intent analysis", "rationale clustering", or "MCP insights". Also trigger when the user mentions [MCP]-prefixed events, tool rationale, tool call errors, or just finished instrumenting their MCP server and wants to see what the data says. Requires the Amplitude MCP connector.

amplitude/builder-skills

Read lost deals and churned accounts from your CRM, extract reasons clustered by theme (missing features, pricing, competitors, UX), and write a prioritized weekly analysis with product improvement recommendations. Use before roadmap planning or to build the case for prioritizing retention work.

amplitude/builder-skills

Creates Amplitude charts from natural language descriptions, handling event selection, filters, groupings, and visualization choices. Use when you know what you want to measure but prefer not to build the chart manually.

amplitude/builder-skills

Guide an Amplitude user through building a custom agent by suggesting use cases grounded in their role and data, shaping the idea into a well-formed spec, and generating a ready-to-run Global Agent deeplink that creates it. Use to create, build, or set up a custom agent, automate a recurring analysis, or put a repeated report on a schedule.

amplitude/builder-skills

Builds comprehensive Amplitude dashboards from requirements or goals, organizing charts into logical sections with appropriate layouts. Use when creating a complete dashboard from scratch or assembling existing charts into a cohesive view.

amplitude/builder-skills

Monitors all active and recently completed experiments across Amplitude projects, triages them by importance, then runs deep analysis and reporting on the most impactful ones. Use when the user asks to "check on experiments", "experiment status", "experiment review", "what experiments are running", or wants a periodic experiment health report.

amplitude/builder-skills

Pull Intercom tickets and Slack support messages from the past 7 days, classify each signal, enrich with CRM data (ARR, plan, renewal), score by customer value and churn risk, and output a tiered priority report saved to Drive. Use when you need a fast, data-driven view of what support signals matter most.

amplitude/builder-skills

Use this skill whenever a user wants to improve existing pages on their website to get cited more by AI models — whether they say "our pages aren't getting cited", "improve this page for AI visibility", "which of our pages should we update", "make this article more cite-worthy", "our competitors are getting cited instead of us", "update our content for AI search", or any variation where the goal is improving an existing asset rather than creating something new. This skill pulls owned pages from AI Visibility, identifies which ones have citation potential but are underperforming, compares them against the external pages that are winning citations on the same topics, and produces section-level rewrites or a full-page update — then pushes the revision to the CMS as a draft. Trigger even if the user just says "help me get cited more" or "why is [competitor] getting cited instead of us".

amplitude/builder-skills

Use this skill whenever a user wants to win AI citations on prompts that competitors currently dominate — whether they say "competitors are getting cited instead of us", "we're losing on these prompts", "how do I outrank [competitor] in AI answers", "find prompts where we should be winning", "create content to beat [competitor]", or any variation where the goal is capturing AI share on prompts a competitor currently owns. This skill pulls competitor visibility data from AI Visibility, identifies the specific prompts where competitors win and Amplitude is absent, clusters them by intent, and produces targeted comparison pages, alternatives content, or rebuttal assets — then pushes drafts to CMS. Trigger on any mention of competitor, prompt hijack, outrank, or "why is [competitor] getting cited instead of us".

amplitude/builder-skills

Use this skill whenever a user wants to turn AI Visibility data into published content — whether they say "find content gaps", "what should we write about", "which topics have low visibility", "help me get cited by AI models", "create a blog post from our AI Visibility gaps", "we're losing to competitors on these prompts", or any variation where they want to go from AI visibility weakness to a draft article, landing page, or FAQ. This skill connects directly to Amplitude AI Visibility data (topics, prompts, visibility scores, citations, competitor data, full LLM responses and sources) and produces a publish-ready content brief plus full article draft. If the user mentions CMS (WordPress, Webflow, Contentful, Sanity, HubSpot, Ghost, Shopify), also trigger this skill to push the draft directly. Trigger even if they just say something vague like "what content should we create?" in an AI Visibility context.

amplitude/builder-skills

Use this skill whenever a user wants to test content variants before publishing to find which one will get cited most by AI models — whether they say "which version of this content will perform better", "test this article before we publish", "simulate how AI will respond to this content", "which angle should we use", "generate content variants and pick the winner", "run a simulation before publishing", or any variation where the goal is data-driven content selection rather than gut-feel publishing. This skill takes an identified content opportunity, generates 2–3 distinct variants with different angles or structures, scores them against actual AI model responses from AI Visibility, references the Simulate Changes feature for pre-publish validation, and produces a clear recommendation on which variant to publish — then pushes the winner to CMS. Trigger on any mention of "simulate", "test variants", "which performs better", "A/B content", or "before we publish".

amplitude/builder-skills

Use this skill whenever a user wants to understand which external sources are being cited by AI models on topics relevant to their brand, and wants to create content that will outrank those sources — whether they say "what sources are AI models citing", "why is [third-party site] being cited instead of us", "we want to be the definitive source on X", "build something that gets cited more than G2 or TechRadar", "create an authoritative asset", or any variation where the goal is producing a new reference asset (definition page, benchmark, methodology, glossary, comparison hub) designed to beat existing top-cited sources. This skill analyzes AI Visibility source data, reverse-engineers what makes top-cited pages authoritative, and produces a superior source asset — then pushes it to CMS as a draft. Trigger on any mention of "sources", "third-party citations", "authoritative content", "definitional pages", or "outrank".

amplitude/builder-skills

Instruments a pull request with Amplitude analytics that conform to the project's existing taxonomy. Reads the tracking plan via the Amplitude MCP server (events, properties, naming conventions), analyzes the PR diff to find the few user actions genuinely worth tracking, detects the codebase's SDK and tracking patterns, and adds instrumentation that matches both. Optionally (opt-in) stages new events and properties on an Amplitude tracking-plan branch for data-governance review. Use when asked to "instrument this PR", "add analytics to this change", "add tracking", "add Amplitude events", "instrument this feature", or "what should I track here".

amplitude/builder-skills

Diagnoses product health by cross-referencing Amplitude analytics (dashboards, charts, funnels, feedback, AI agent analytics), optionally Datadog (errors, latency, stack traces), and optionally Slack (qualitative feedback, bug reports, feature requests). Identifies what's broken, what's working, and what to do about it — with root causes, not just symptoms. Use when asked to "diagnose my product", "what's going on", "product health check", "what's broken", "where are users struggling", "give me a product diagnosis", or "what should I focus on".

amplitude/builder-skills

Turn one or more meeting transcripts, notes, or Slack threads into concise takeaways and clear action items with DRIs. Works with a single meeting or a batch from the whole week.

amplitude/builder-skills

Summarizes B2B account health by analyzing usage patterns, engagement trends, risk signals, and expansion opportunities. Use for customer success reviews, renewal preparation, QBRs, or account prioritization.

相关技能