Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Adding Opentelemetry to MCP SDK #421

Copy link
Copy link
@fali007

Description

@fali007
Issue body actions

Is your feature request related to a problem? Please describe.

I would like to see Opentelemetry traces and Metrics baked into SDK.
E.g.

  1. Traces emitted on all Requests from client and server side of MCP SDK.
  2. Metrics for tool/prompt/resource calls

Describe the solution you'd like

I am trying to use Opentelemetry sdk to add traces and metrics features.

Steps

  1. Creating session in client and server.
  2. Initialise tracer (Opentelemetry tracer instances) in BaseSession (src/mcp/shared/session.py).
  3. Binding trace context (traceparent) to _meta of RequestParams.Meta before sending request from client (send_request in src/mcp/shared/session.py)
  4. In server use the traceparent from received request to create new span with incoming span as parent span.

Describe alternatives you've considered

I tried to implement the same via traceloop. I was not able to get correct parent - child relationship between spans while doing so.

Additional context

I am able to achieve distributed tracing across my Agentic application and MCP server.

Image
Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

P3Nice to haves, rare edge casesNice to haves, rare edge casesenhancementRequest for a new feature that's not currently supportedRequest for a new feature that's not currently supportedready for workEnough information for someone to start working onEnough information for someone to start working onv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixesIdeas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.