Skip to content

feat: add user agent tracking to MCP telemetry#338

Merged
dcramer merged 1 commit into
mainfrom
agent-stats
Jun 29, 2025
Merged

feat: add user agent tracking to MCP telemetry#338
dcramer merged 1 commit into
mainfrom
agent-stats

Conversation

@dcramer

@dcramer dcramer commented Jun 29, 2025

Copy link
Copy Markdown
Member
  • Add user_agent.original attribute to all MCP operations (tools, prompts, resources)
  • Stdio: Support MCP_USER_AGENT env var with default sentry-mcp-stdio/{version}
  • Cloudflare: Capture user agent from initial SSE/WebSocket request headers
  • Document user agent tracking following OpenTelemetry semantic conventions

🤖 Generated with Claude Code

- Add user_agent.original attribute to all MCP operations (tools, prompts, resources)
- Stdio: Support MCP_USER_AGENT env var with default sentry-mcp-stdio/{version}
- Cloudflare: Capture user agent from initial SSE/WebSocket request headers
- Document user agent tracking following OpenTelemetry semantic conventions

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 29, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 0% with 18 lines in your changes missing coverage. Please review.

Project coverage is 63.45%. Comparing base (15fd50b) to head (c8c1b09).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
packages/mcp-server/src/server.ts 0.00% 9 Missing ⚠️
...ges/mcp-cloudflare/src/server/lib/mcp-transport.ts 0.00% 8 Missing ⚠️
packages/mcp-server/src/index.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #338      +/-   ##
==========================================
- Coverage   63.65%   63.45%   -0.21%     
==========================================
  Files          46       46              
  Lines        5668     5686      +18     
  Branches      471      471              
==========================================
  Hits         3608     3608              
- Misses       2060     2078      +18     
Flag Coverage Δ
unittests 63.45% <0.00%> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

attributes: {
"mcp.resource.name": resource.name,
"mcp.resource.uri": url.toString(),
...(context.userAgent && {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we'll remove this once sentry's core instrumentation does this at the mcp.server level

name: `prompts/get ${prompt.name}`,
attributes: {
"mcp.prompt.name": prompt.name,
...(context.userAgent && {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we'll remove this once sentry's core instrumentation does this at the mcp.server level

name: `tools/call ${tool.name}`,
attributes: {
"mcp.tool.name": tool.name,
...(context.userAgent && {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we'll remove this once sentry's core instrumentation does this at the mcp.server level

@dcramer

dcramer commented Jun 29, 2025

Copy link
Copy Markdown
Member Author

I'm not totally sure this is correct, but low risk so we'll ship and verify.

@dcramer dcramer merged commit 0db12a6 into main Jun 29, 2025
12 checks passed
@dcramer dcramer deleted the agent-stats branch June 29, 2025 20:05
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.

1 participant