You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It will be great to have official support for OpenTelemetry for the SDK. One of the more important features is the ability to propagate context between server and client to have connected traces, and in the future when semantic conventions for MCP are defined (WIP), the instrumentation could create spans following the definitions to give more visibility into tool calls in agent flows.
The instrumentation itself isn't difficult, but the main question becomes where it should live. opentelemetry-go is quite reluctant to own new instrumentation, with guidance against it, and the reality that no new instrumentation has been added for years. I think it means most practically this would need to live in the modelcontextprotocol org somehow. The three ideas seem to be
Instrument functions directly within this codebase. All users will have OTel support enabled, though by default it is no-op if the user isn't also using the OTel SDK
Add a otel package to this repo with middleware that users register themselves
Add a separate go-sdk-otel repo to this org with middleware that users register themselves
I have seen all three patterns in various libraries in Go.
For context, I have published a module with instrumentation for propagation
@anuraaga I think it's really important that we ensure the SDK admits the extensibility hooks that allow OpenTelemetry to be integrated, and we'd happily consider proposals that add or augment such extensibility, but we shouldn't include explicit OpenTelemetry support as part of the SDK itself. Apart from wanting to keep the SDK minimal, an official project like this needs to be careful to avoid biasing toward certain integrations. See for example the hefty antitrust policy we had to include in CONTRIBUTING.md. Therefore, the third option -- a separate repo -- makes the most sense to me. I think we could probably include examples of using OpenTelemetry, as long as we'd also accept example of using other similar libraries (I'd need to check with our counsel on that).
@jba, who is working on this project, has a lot of experience with instrumentation through his work on the slog package. @jpmcb might also have some advice for how to structure this type of auxiliary library.
Reacted by Anuraag (Rag) Agrawal and Jan Niklas Dittmar
I personally think mcp-go-sdk-otel is a better solution, and I don't think any namebrand integration should be part of the core sdk. Unless that is a best practice that other SDKs are following. Additionally the the MCP spec today does not necessarily dictate sdk-side audit/telemetry. Thus it should not be part of the sdk.
However, it would be completly within the scope of the go-sdk to provide some hooks that allow generic telemery, and technically otel would be the "standard~ish" way of exposing that.
So @anuraaga maybe the best course of action is to put in a proposal on how you would integrate otel into the go-sdk, but keep in mind that what might likely happen is it would have to be a plug-in-style ecosystem.
Thanks all - I think a mcp-go-sdk-otel repo sounds good. There are already the right hooks in this SDK for it, and the motivation for that project is to make sure users needing observability of their MCP servers have an official solution to look to rather than personal projects.
Especially in Go, and an early project, it feels a bit easier to include instrumentation as the api dependency of Otel is pretty light (just don't include the whole tree of things). There are auto-instrumentation projects out there, but it isn't straight forward for go.
@jpmcb might also have some advice for how to structure this type of auxiliary library.
I agree with what others have said: I don't think it makes sense that there's an opinionated instrumentation for telemetry in the core SDK (especially since MCP itself doesn't include anything about telem in the raw protocol and other SDKs wouldn't have this type of instrumentation bundled in).
Also it is not uncommon in genai frameworks to include Otel particularly as it reduces hook/drift dependencies - Here are several but there are many ...
Good context but also important to note that those entities (OpenAI, Microsoft, Vercel) also own the platform where those SDKs typically run so they have a deeply vested interest in integrating a specific telemetry stack adopted by their devops orgs.
MCP is community driven so it would be an anti-pattern to force a operations decision on any SDK consumer.
@jpmcb there is one key thing I think I'll get your answer on, and not sure who are maintainers or represent quorum here.
The minimum and very valid concern isn't span recording it is propagation, which is very much specific to MCP. e.g. use request.params._meta etc, and there have been many discussions on that and it is implemented consistently in several SDKs.
Being consistent in this org is a goal of it, and it isn't forcing an operations pattern as Otel is only one consumer of headers when they exist (e.g. I am the one who opened zipkin which was formerly twitter, and b3 is also a valid header as are others)
We can choose to push this to a downstream drift likely dep, but I hope some maintainer at some point can empathize that patterns discussed and normalized here are fair game to also implement at least optionally
I am not a maintainer, but I agree with @codefromthecrypt_meta partially solves this. But at the same time it would still be extremely valuable for interop with traditional enterprise use cases, such as authentication, tracing, security, and beyond for custom headers. This SDK's primary role is twofold: spec compliance and extensibility.
I suggest we:
Close this issue since we are no longer talking about Otel per se
Someone file a new issue with a specific proposal for custom header implementation, maybe something like a withHeaders mixin/ although technically you can get away with this by making a custom transport.
I honestly think custom headers are fair game, but telemetry platforms would still need to independently investigate utilizing _meta since that is what you can guarantee all mcp servers provide.
so for folks who havent' seen it, this is the discussion about _meta, and also being specific about how it is used. e.g. without specific advice sometimes people encode headers as a sub-field in _meta! the most straightforward path is to treat _meta like headers or in the case of grpc, metadata. With this key integration in, subprojects can in a pretty straightforward way roll their own Otel or re-use a lib and not worry about propagation breaks modelcontextprotocol/modelcontextprotocol#246 (comment)
MCP is community driven so it would be an anti-pattern to force a operations decision on any SDK consumer.
Thanks all - I am going to close this since it sounds like there isn't interest in a separate repo either. Given what OpenTelemetry is (a community framework, not a telemetry platform) this feels the opposite of community driven to me, but this seems like the general consensus so it's fine.
Activity
findleyr commentedon Jun 27, 2025
@anuraaga I think it's really important that we ensure the SDK admits the extensibility hooks that allow OpenTelemetry to be integrated, and we'd happily consider proposals that add or augment such extensibility, but we shouldn't include explicit OpenTelemetry support as part of the SDK itself. Apart from wanting to keep the SDK minimal, an official project like this needs to be careful to avoid biasing toward certain integrations. See for example the hefty antitrust policy we had to include in CONTRIBUTING.md. Therefore, the third option -- a separate repo -- makes the most sense to me. I think we could probably include examples of using OpenTelemetry, as long as we'd also accept example of using other similar libraries (I'd need to check with our counsel on that).
@jba, who is working on this project, has a lot of experience with instrumentation through his work on the
slogpackage.@jpmcb might also have some advice for how to structure this type of auxiliary library.
jba commentedon Jun 27, 2025
An mcp-go-sdk-otel repo sounds ideal. If Anthropic doesn't want to create tons of repos like this, maybe they would be open to a single contrib repo.
RoyceLeonD commentedon Jul 18, 2025
I personally think
mcp-go-sdk-otelis a better solution, and I don't think any namebrand integration should be part of the core sdk. Unless that is a best practice that other SDKs are following. Additionally the the MCP spec today does not necessarily dictate sdk-side audit/telemetry. Thus it should not be part of the sdk.However, it would be completly within the scope of the go-sdk to provide some hooks that allow generic telemery, and technically otel would be the "standard~ish" way of exposing that.
So @anuraaga maybe the best course of action is to put in a proposal on how you would integrate otel into the go-sdk, but keep in mind that what might likely happen is it would have to be a plug-in-style ecosystem.
anuraaga commentedon Jul 18, 2025
Thanks all - I think a
mcp-go-sdk-otelrepo sounds good. There are already the right hooks in this SDK for it, and the motivation for that project is to make sure users needing observability of their MCP servers have an official solution to look to rather than personal projects.The proposal is basically upstreaming https://github.com/anuraaga/mcp-go-sdk-otel - if the idea makes sense, I'd be happy to help maintain such a repo in this org.
codefromthecrypt commentedon Jul 18, 2025
https://github.com/modelcontextprotocol/csharp-sdk does in this org, and was behind a lot of the spec feature requests.
Also it is not uncommon in genai frameworks to include Otel particularly as it reduces hook/drift dependencies
Here are several but there are many:
https://github.com/openai/openai-dotnet
https://github.com/microsoft/semantic-kernel
https://github.com/vercel/ai
Especially in Go, and an early project, it feels a bit easier to include instrumentation as the api dependency of Otel is pretty light (just don't include the whole tree of things). There are auto-instrumentation projects out there, but it isn't straight forward for go.
My 2p
jpmcb commentedon Jul 18, 2025
I agree with what others have said: I don't think it makes sense that there's an opinionated instrumentation for telemetry in the core SDK (especially since MCP itself doesn't include anything about telem in the raw protocol and other SDKs wouldn't have this type of instrumentation bundled in).
Good context but also important to note that those entities (OpenAI, Microsoft, Vercel) also own the platform where those SDKs typically run so they have a deeply vested interest in integrating a specific telemetry stack adopted by their devops orgs.
MCP is community driven so it would be an anti-pattern to force a operations decision on any SDK consumer.
codefromthecrypt commentedon Jul 18, 2025
@jpmcb there is one key thing I think I'll get your answer on, and not sure who are maintainers or represent quorum here.
The minimum and very valid concern isn't span recording it is propagation, which is very much specific to MCP. e.g. use request.params._meta etc, and there have been many discussions on that and it is implemented consistently in several SDKs.
Being consistent in this org is a goal of it, and it isn't forcing an operations pattern as Otel is only one consumer of headers when they exist (e.g. I am the one who opened zipkin which was formerly twitter, and b3 is also a valid header as are others)
We can choose to push this to a downstream drift likely dep, but I hope some maintainer at some point can empathize that patterns discussed and normalized here are fair game to also implement at least optionally
RoyceLeonD commentedon Jul 18, 2025
I am not a maintainer, but I agree with @codefromthecrypt
_metapartially solves this. But at the same time it would still be extremely valuable for interop with traditional enterprise use cases, such as authentication, tracing, security, and beyond for custom headers. This SDK's primary role is twofold: spec compliance and extensibility.I suggest we:
I honestly think custom headers are fair game, but telemetry platforms would still need to independently investigate utilizing
_metasince that is what you can guarantee all mcp servers provide.codefromthecrypt commentedon Jul 19, 2025
so for folks who havent' seen it, this is the discussion about _meta, and also being specific about how it is used. e.g. without specific advice sometimes people encode headers as a sub-field in _meta! the most straightforward path is to treat _meta like headers or in the case of grpc, metadata. With this key integration in, subprojects can in a pretty straightforward way roll their own Otel or re-use a lib and not worry about propagation breaks modelcontextprotocol/modelcontextprotocol#246 (comment)
anuraaga commentedon Jul 19, 2025
Thanks all - I am going to close this since it sounds like there isn't interest in a separate repo either. Given what OpenTelemetry is (a community framework, not a telemetry platform) this feels the opposite of community driven to me, but this seems like the general consensus so it's fine.