feat(mcp): add canonical MCP tool-call events - #265
Conversation
- add a framework-independent MCP analytics API with identity mapping and optional exception fanout - sanitize and bound captured parameters, responses, properties, and errors - add API documentation, provenance, golden fixtures, and comprehensive tests Verified with go test ./..., MCP race tests, go vet, and the public API check.
|
@PostHog/mcp-analytics pls take a look! |
|
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
|
This PR was closed due to lack of activity. Feel free to reopen if it's still relevant. |
| func removeIdentityControlProperties(properties posthog.Properties) { | ||
| delete(properties, propertyGroups) | ||
| delete(properties, propertySet) | ||
| delete(properties, propertyProcessProfile) |
There was a problem hiding this comment.
Preserve explicit person-profile opt-out
Passing DistinctID: "user_1" with Properties{"$process_person_profile": false} drops the opt-out from both $mcp_tool_call and $exception. Python and TypeScript preserve it. I reproduced the missing flag in both serialized payloads.
Please preserve an explicitly supplied false for identified calls, while continuing to force false when identity is absent. Add serialized-payload tests for both events, including an anonymous call attempting to override the flag to true.
|
|
||
| intent := strings.TrimSpace(call.Intent) | ||
| if intent != "" { | ||
| prepared.intent = truncateUTF8(sanitizeString(intent), maxIntentBytes) |
There was a problem hiding this comment.
Bring intent redaction up to current SDK parity
Both Python and TypeScript now redact structured personal identifiers from $mcp_intent. This implementation still captures emails and IP addresses unchanged: Find orders for alice@example.com from 192.0.2.1 is emitted verbatim, while both current SDKs produce Find orders for [redacted] from [redacted]. This behavior landed after the PR's August baseline.
Please port the intent-specific redaction for emails, phone numbers, IPv4/IPv6 addresses, Luhn-valid cards, and US SSNs. Run it before truncation and reuse the cross-language test cases, including Unicode separators and false positives. Keep this additional redaction scoped to intent; parameters and responses should retain their existing behavior.
References: TypeScript sanitizer, Python sanitizer.
Verified with go test ./..., MCP race tests, go vet, and the public API check.
💡 Motivation and Context
I have left the original specification in the mcp_support_spec.md happy to remove it.
This is half of the solution to #262
💚 How did you test it?
This is been verified on my personal side project https://github.com/wolfeidau/starlogz
📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
This code was initially scaffolded by OpenAI Codex, and most of the test code was written with help from this agent harness.
Autonomy: Human-driven (agent-assisted) — or — Fully autonomous