Skip to content

Add MCP workflow telemetry for AI plugins#2979

Open
glendaviesnz wants to merge 4 commits intotrunkfrom
add-agent-plugin-telemetry
Open

Add MCP workflow telemetry for AI plugins#2979
glendaviesnz wants to merge 4 commits intotrunkfrom
add-agent-plugin-telemetry

Conversation

@glendaviesnz
Copy link
Copy Markdown

@glendaviesnz glendaviesnz commented Apr 6, 2026

Fixes: https://linear.app/a8c/issue/STU-1530/add-telemetry-for-external-agents

Summary

This adds plugin-aware MCP workflow telemetry for Studio's AI integrations. This is needed so we can track usage of the Studio MCP by external agents, eg. https://github.com/Automattic/build-with-wordpress

Changes include:

  • adding a hidden studio mcp --telemetry-group <group> option so different AI plugin integrations can identify themselves when they launch the Studio MCP server
  • extending the Studio CLI bump-stat types to allow plugin telemetry groups and workflow-stage stats
  • adding a new record_workflow_event MCP tool that records workflow milestones like theme-build-started, theme-build-completed, and theme-build-failed
  • threading the configured telemetry group through the MCP startup path so the tool can record events without the caller having to pass the plugin identity every time
  • updating the Studio AI UI/system prompt metadata so the new tool is surfaced cleanly in the built-in assistant
  • adding targeted MCP tool tests for configured and unconfigured telemetry behavior

This is designed to support plugin-grouped telemetry such as:

  • codex-plugin + theme-build-started
  • claude-code-plugin + theme-build-completed

Testing

Automated

  • npm test -- apps/cli/ai/tests/tools.test.ts

Manual

  1. Launch Studio MCP with a telemetry group, for example:
    • studio mcp --telemetry-group codex-plugin
  2. Connect an MCP client and confirm the record_workflow_event tool is available.
  3. Call the tool with:
    • workflow: theme-build
    • stage: started
  4. Confirm the tool returns a success message showing the plugin group and stat name.
  5. Repeat with completed and failed stages and with another workflow such as site-build.
  6. Launch studio mcp without --telemetry-group and confirm the tool reports that workflow telemetry was skipped because no plugin group was configured.

Notes

  • I also ran npx tsc -p apps/cli/tsconfig.json --noEmit, but it still reports an existing unrelated memfs test typing issue in apps/cli/lib/tests/snapshots.test.ts.

@glendaviesnz glendaviesnz self-assigned this Apr 6, 2026
@wpmobilebot
Copy link
Copy Markdown
Collaborator

wpmobilebot commented Apr 6, 2026

📊 Performance Test Results

Comparing 85e2639 vs trunk

app-size

Metric trunk 85e2639 Diff Change
App Size (Mac) 1252.07 MB 1252.00 MB 0.08 MB ⚪ 0.0%

site-editor

Metric trunk 85e2639 Diff Change
load 1945 ms 1944 ms 1 ms ⚪ 0.0%

site-startup

Metric trunk 85e2639 Diff Change
siteCreation 9108 ms 8180 ms 928 ms 🟢 -10.2%
siteStartup 4175 ms 4840 ms +665 ms 🔴 15.9%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@sejas
Copy link
Copy Markdown
Member

sejas commented Apr 7, 2026

Hi @glendaviesnz , does this PR relate to any Linear issue? is necessary for Telex? Thank you!
When ready feel free to assign me or YOLO team as reviewer. If it's still in progress it would be great to move it as a draft.

@glendaviesnz
Copy link
Copy Markdown
Author

Hi @glendaviesnz , does this PR relate to any Linear issue? is necessary for Telex? Thank you! When ready feel free to assign me or YOLO team as reviewer. If it's still in progress it would be great to move it as a draft.

Sorry @sejas, meant to add more detail, done now with a link to Linear issue. I am very open to alternative approaches to this, just let me know if you see a better way to handle it.

@glendaviesnz glendaviesnz requested a review from a team April 8, 2026 03:09
Copy link
Copy Markdown
Member

@sejas sejas left a comment

Choose a reason for hiding this comment

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

Code wise, it works as described. It add these new MCP tool mcp__studio__record_workflow_event that can be called externally from any MCP client that passes the --telemetry-group argument.

I saw the comment in Linear and I wonder if Studio MCP should be aware of the workflows that are external to Studio CLI and Studio Code, such as auditing, theme-build etc. https://github.com/Automattic/studio/pull/2979/changes#diff-293dca55bfcd55dab52ea4082275ad8b9093c06127027f1d1aaef2659450f82dR10-R16

So, I believe the best place to add this telemetry would be were they are invoked, inside the codex and claude plugins. Using PreTool and PostTool hooks inside the skills could be a good approach. What do you think?

I’ll defer to the PED trio, @Poliuk, @wojtekn and @shaunandrews , to decide whether to include this Telemetry MCP tool.

.option( 'help', { type: 'boolean' } )
.option( 'telemetry-group', {
type: 'string',
hidden: true,
Copy link
Copy Markdown
Member

@sejas sejas Apr 9, 2026

Choose a reason for hiding this comment

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

I see that this telemetry group is a hidden option, so users won’t get confused about it 👍 .

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