feat(@modelcontextprotocol/sdk): add server-side LLMObs plugins#8921
feat(@modelcontextprotocol/sdk): add server-side LLMObs plugins#8921wconti27 wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #8921 +/- ##
==========================================
- Coverage 96.61% 96.50% -0.11%
==========================================
Files 920 923 +3
Lines 122266 122831 +565
Branches 21008 21259 +251
==========================================
+ Hits 118128 118544 +416
- Misses 4138 4287 +149 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Overall package sizeSelf size: 6.76 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.1 | 122.62 kB | 438.86 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
🎉 All green!🧪 All tests passed 🔄 Datadog auto-retried 1 job - 1 passed on retry 🎯 Code Coverage (details) 🔗 Commit SHA: 96d69a3 | Docs | Datadog PR Page | Give us feedback! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 452656b815
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
BenchmarksBenchmark execution time: 2026-07-14 19:46:38 Comparing candidate commit 96d69a3 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2309 metrics, 49 unstable metrics.
|
60d69ee to
934cced
Compare
934cced to
02d9102
Compare
What does this PR do?
Adds server-side LLMObs support for
@modelcontextprotocol/sdkon top of the base MCP tracing work from #8916, and aligns the MCP LLMObs shape with the Python tracer where the SDKs overlap.McpServerRequestLLMObsPluginfor MCP server request LLMObs spans.MCP Client Initialize) and server initialize LLMObs spans (mcp.initialize).tools/callserver requests as LLMObstoolspans on the base APMmcp.request/server_tool_callspan.mcp_method,mcp_tool, andmcp_tool_kind:server.mcp_session_idwhen the MCP transport exposes one.mcp_method,client_name, and Python-styleclient_version.mcp_tool_kind,mcp_server_name).MCP Client list Tools, cursor input).Motivation
MCP servers are a key AI infrastructure boundary. This captures server request/tool activity in LLMObs while keeping internal trace propagation metadata out of LLMObs input payloads and avoiding duplicate LLMObs events for the JS-only internal
mcp.server.tool.callAPM span.Additional Notes
master.96d69a31f.Local verification:
env -u OTEL_TRACES_EXPORTER -u OTEL_LOGS_EXPORTER -u OTEL_METRICS_EXPORTER PATH=/Users/william.conti/.nvm/versions/node/v22.17.0/bin:$PATH ./node_modules/.bin/nyc --reporter=text --include 'packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/**/*.js' /Users/william.conti/.nvm/versions/node/v22.17.0/bin/node ./node_modules/mocha/bin/mocha.js --timeout 60000 packages/dd-trace/test/llmobs/plugins/modelcontextprotocol-sdk/index.spec.js packages/dd-trace/test/llmobs/plugins/modelcontextprotocol-sdk/utils.spec.js- passed, 45 passing; lines/functions 100%, statements 96.52%, branches 86.84%.env -u OTEL_TRACES_EXPORTER -u OTEL_LOGS_EXPORTER -u OTEL_METRICS_EXPORTER /Users/william.conti/.nvm/versions/node/v22.17.0/bin/node ./node_modules/mocha/bin/mocha.js --reporter dot --timeout 60000 packages/datadog-plugin-modelcontextprotocol-sdk/test/index.spec.js- passed, 51 passing./Users/william.conti/.nvm/versions/node/v22.17.0/bin/node ./node_modules/eslint/bin/eslint.js packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js packages/datadog-plugin-modelcontextprotocol-sdk/test/index.spec.js packages/datadog-plugin-modelcontextprotocol-sdk/test/test-setup.js packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js packages/dd-trace/test/llmobs/plugins/modelcontextprotocol-sdk/index.spec.js packages/dd-trace/test/llmobs/plugins/modelcontextprotocol-sdk/utils.spec.js packages/dd-trace/test/llmobs/util.js --max-warnings 0- passed.git diff --check- passed.