Commit fc8dd00
committed
feat(instrumentation-mcp): add OpenTelemetry instrumentation for MCP SDK
Add automatic OpenTelemetry instrumentation for the Model Context Protocol (MCP) SDK to enable distributed tracing across MCP client–server boundaries.
Features
1. Automatic span creation for client requests and server handlers.
2. OpenTelemetry context propagation via request metadata.
3. Support for MCP semantic conventions.
Reference:
MCP semantic conventions
open-telemetry/semantic-conventions#2083
Tests
1. End-to-end test with HTTP-based MCP client and server
2. End-to-end test with stdio-based MCP client and server
3. All unit tests pass
Implementation Notes
According to the MCP SDK documentation https://github.com/modelcontextprotocol/typescript-sdk/blob/main/README.md, the following modules are used to create the MCP client and server:
Client
Module name: '@modelcontextprotocol/sdk/client/index.js'
basedir: '/Users/someone/http-client-server/client/node_modules/@modelcontextprotocol/sdk'
Server
Module name: '@modelcontextprotocol/sdk/server/mcp.js'
basedir: '/Users/someone/http-client-server/server/node_modules/@modelcontextprotocol/sdk'
The existing InstrumentationBase could not wrap both modules from the @modelcontextprotocol/sdk package. This PR introduces a custom hook within the MCP instrumentation library to support both.1 parent 23c5f4e commit fc8dd00
File tree
18 files changed
+1751
-43
lines changed- packages
- auto-instrumentations-node
- src
- instrumentation-mcp
- src
- test
18 files changed
+1751
-43
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
0 commit comments