Add a PostHog.MCP capture helper for MCP Analytics
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia da CONTRIBUTING.md, quindi confronta l’API PostHog.MCP proposta con il modulo PostHog.LLMAnalytics esistente e il comportamento di PostHog.set_context/1. Risolvi innanzitutto con un maintainer le questioni relative a modulo/pacchetto, stile delle opzioni, sessione, redaction e scope; il lavoro è completato quando sono stati concordati un’API e uno scope di implementazione per gli helper MCP Analytics iniziali.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Elixir
- Stelle
- 66
- Fork
- 33
- Merge medio
- 1g 22h
- PR unite (30g)
- 21
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di PostHog/posthog-elixir
-
enhancement feature/feature-flags
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
PostHog/posthog-elixir#215 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
PostHog/posthog-elixir#149 ·
I maintainer di solito rispondono entro 1 giorno
-
bug enhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
PostHog/posthog-elixir#147 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
PostHog/posthog-elixir#146 ·
I maintainer di solito rispondono entro 1 giorno
-
Add public bounded flush APIApertaenhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 45/100
PostHog/posthog-elixir#145 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di PostHog/posthog-elixir
Issue simili
-
@swmansion/popcorn: published .d.ts files lack extensions on relative imports, breaking moduleResolution node16/nodenextForse già presa @Huyvux12 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
software-mansion/popcorn#929 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
ash-project/ash#3127 ·
I maintainer di solito rispondono entro 1 giorno
-
Bug: Table layout and date column are cut off on mobile screens on the Tournaments -> History pageApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
hexlet-codebattle/codebattle#2375 ·
-
Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
wintermeyer/vutuv#2388 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100