Skip to content

feat(mcp): add canonical MCP tool-call events - #265

Draft
wolfeidau wants to merge 1 commit into
PostHog:mainfrom
wolfeidau:mcp-tool-events
Draft

feat(mcp): add canonical MCP tool-call events#265
wolfeidau wants to merge 1 commit into
PostHog:mainfrom
wolfeidau:mcp-tool-events

Conversation

@wolfeidau

@wolfeidau wolfeidau commented Aug 2, 2026

Copy link
Copy Markdown

Verified with go test ./..., MCP race tests, go vet, and the public API check.

💡 Motivation and Context

  • 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, fixtures, and tests

I have left the original specification in the mcp_support_spec.md happy to remove it.

Screenshot 2026-08-02 at 11 50 14 am

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

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to 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

- 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.
@marandaneto

Copy link
Copy Markdown
Member

@PostHog/mcp-analytics pls take a look!

@github-actions

Copy link
Copy Markdown
Contributor

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 stale label – otherwise this will be closed in another week.

@github-actions github-actions Bot added the stale label Aug 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.

@github-actions github-actions Bot closed this Aug 24, 2026
@lucasheriques lucasheriques reopened this Sep 9, 2026
Comment thread mcp/event.go
func removeIdentityControlProperties(properties posthog.Properties) {
delete(properties, propertyGroups)
delete(properties, propertySet)
delete(properties, propertyProcessProfile)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread mcp/event.go

intent := strings.TrimSpace(call.Intent)
if intent != "" {
prepared.intent = truncateUTF8(sanitizeString(intent), maxIntentBytes)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot removed the stale label Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants