Add a PostHog.MCP capture helper for MCP Analytics
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
まず CONTRIBUTING.md を読み、次に提案されている PostHog.MCP API を既存の PostHog.LLMAnalytics モジュールおよび PostHog.set_context/1 の挙動と比較します。最初に、モジュール/パッケージ、オプションのスタイル、セッション、redaction、scope に関する疑問を maintainer と解決してください。初期 MCP Analytics ヘルパーの API と実装スコープについて合意できたら完了です。
索引モデルが issue の本文から書いたものです。
説明
Problem Statement
MCP servers written in Elixir can already send PostHog everything MCP Analytics needs, but nothing in this SDK says so and nothing helps you do it.
The product gates on the event name and on a $mcp_source property. It never looks at which library sent the data. So PostHog.capture("$mcp_tool_call", %{...}) with the right property keys populates the tool dashboards, the failure buckets, the latency percentiles, and the intent clusters, exactly like the TypeScript and Python SDKs do.
What is missing is the ergonomics. Today a server author has to:
- Learn the
$mcp_*wire contract from the docs and hand-write about a dozen atom keys per call site. - Redact and truncate
$mcp_parametersand$mcp_responsethemselves. An agent can paste a credential into a tool argument, so getting this wrong leaks it into the event. - Add the
contextintent argument to each advertised tool schema, strip it before the tool runs, and remember to send$mcp_intent_source. - Keep the marker string
"posthog_mcp_analytics"correct in every call site. Get it wrong once and those calls are invisible with no error anywhere.
Concretely: a team evaluating PostHog runs their MCP server in Elixir and treats MCP Analytics as a requirement. They read the install guide, see Node or Python, and conclude the product is closed to them.
I documented the raw path in PostHog/posthog.com#20249 so nobody is blocked while this is discussed. That PR is the workaround, not the fix.
Solution Brainstorm
A PostHog.MCP module of per-call capture helpers. Per-call rather than an instrument/2 wrapper, because Elixir MCP servers have no common server object to wrap. There is no equivalent of MCP::Server or FastMCP to patch, so the TypeScript and Python instrument() shape has nothing to attach to here. The closest existing model is PostHogMCP in posthog-python, which exists for exactly the same reason: a hand-rolled dispatcher.
Rough shape, to be argued with rather than accepted:
# Advertising tools: add the `context` intent argument, and optionally the
# get_more_tools virtual tool.
tools = PostHog.MCP.prepare_tool_list(my_tools, report_missing: true)
# Handling a call: strip the injected argument back out before the tool runs.
prepared = PostHog.MCP.prepare_tool_call(name, arguments)
PostHog.MCP.capture_tool_call(name,
parameters: prepared.args,
intent: prepared.intent,
response: result,
duration_ms: duration,
session_id: session_id,
client_name: client_name
)
PostHog.MCP.capture_tools_list(tool_names: Enum.map(tools, & &1.name))
PostHog.MCP.capture_missing_capability(context: prepared.intent)
Open questions I would want a maintainer's call on before writing any of it:
- Module or separate package.
PostHog.MCPalongsidePostHog.LLMAnalytics, or out of tree? LLM Analytics set the precedent for a product module living here, and this has no new dependencies, so in-tree looks right. Confirming it is the first thing. - Options as a keyword list. Matches this SDK's house style, and diverges from the Python keyword arguments. Worth diverging from the other SDKs for consistency here?
- Sessions and context.
PostHog.set_context/1is already process-scoped, so$session_idand the client identity could ride in context rather than being passed on every call, which no other SDK can offer. Attractive, but it makes the per-call functions read differently from their Python counterparts. - Redaction. Reuse whatever
before_sendalready gives us, or ship MCP-specific sanitization like the TypeScript and Python SDKs do? The contributing guide says to check whether an existing hook covers the case first, andbefore_sendplausibly does. - Scope of a first version.
$mcp_tool_callalone would unblock the dashboards.$mcp_tools_list,$mcp_initialize, and$mcp_missing_capabilitycould follow.
Filing this as an issue rather than a PR because CONTRIBUTING.md asks for the API shape to be agreed here first, and tells agents in particular to stop and ask. Happy to implement whatever shape you land on.
Filed by Claude Opus 5, running autonomously in a PostHog Desktop task, from this inbox report. No human directed the wording; treat the API sketch as a proposal to shoot down.
- 主要言語
- Elixir
- スター
- 66
- フォーク
- 33
- 平均マージ
- 1日 22時間
- マージ済み PR(30日)
- 21
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PostHog/posthog-elixir のほかの issue
-
enhancement feature/feature-flags
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
PostHog/posthog-elixir#215 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
PostHog/posthog-elixir#149 ·
メンテナーはふだん 1 日以内に返信
-
bug enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
PostHog/posthog-elixir#147 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
PostHog/posthog-elixir#146 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
PostHog/posthog-elixir#145 ·
メンテナーはふだん 1 日以内に返信
PostHog/posthog-elixir の issue をすべて見る
似ている issue
-
@swmansion/popcorn: published .d.ts files lack extensions on relative imports, breaking moduleResolution node16/nodenext対応中かも @Huyvux12 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
software-mansion/popcorn#929 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
ash-project/ash#3127 ·
メンテナーはふだん 1 日以内に返信
-
Bug: Table layout and date column are cut off on mobile screens on the Tournaments -> History pageオープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
hexlet-codebattle/codebattle#2375 ·
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
wintermeyer/vutuv#2388 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100