-
Notifications
You must be signed in to change notification settings - Fork 489
feat(contrib/mcp-go): Initial mcp-go tracer implementation
#4100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # MCP-Go Integration | ||
|
|
||
| This integration provides Datadog tracing for the [mark3labs/mcp-go](https://github.com/mark3labs/mcp-go) library. | ||
|
|
||
| ## Usage | ||
|
|
||
| ```go | ||
| import ( | ||
| mcpgotrace "github.com/DataDog/dd-trace-go/contrib/mark3labs/mcp-go/v2" | ||
| "github.com/DataDog/dd-trace-go/v2/ddtrace/tracer" | ||
| "github.com/mark3labs/mcp-go/server" | ||
| ) | ||
|
|
||
| func main() { | ||
| tracer.Start() | ||
| defer tracer.Stop() | ||
|
|
||
| srv := server.NewMCPServer("my-server", "1.0.0", | ||
| server.WithToolHandlerMiddleware(mcpgotrace.NewToolHandlerMiddleware())) | ||
| _ = srv | ||
| } | ||
| ``` | ||
|
|
||
| ## Features | ||
|
|
||
| The integration automatically traces: | ||
| - **Tool calls**: Creates LLMObs tool spans with input/output annotation for all tool invocations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Unless explicitly stated otherwise all files in this repository are licensed | ||
| // under the Apache License Version 2.0. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
| // Copyright 2016 Datadog, Inc. | ||
|
|
||
| package mcpgo_test | ||
|
|
||
| import ( | ||
| mcpgotrace "github.com/DataDog/dd-trace-go/contrib/mark3labs/mcp-go/v2" | ||
| "github.com/DataDog/dd-trace-go/v2/ddtrace/tracer" | ||
| "github.com/mark3labs/mcp-go/server" | ||
| ) | ||
|
|
||
| func Example() { | ||
| tracer.Start() | ||
| defer tracer.Stop() | ||
|
|
||
| srv := server.NewMCPServer("my-server", "1.0.0", | ||
| server.WithToolHandlerMiddleware(mcpgotrace.NewToolHandlerMiddleware())) | ||
| _ = srv | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| module github.com/DataDog/dd-trace-go/contrib/mark3labs/mcp-go/v2 | ||
|
|
||
| go 1.24.0 | ||
|
|
||
| require ( | ||
| github.com/DataDog/dd-trace-go/v2 v2.4.0-dev | ||
| github.com/mark3labs/mcp-go v0.42.0 | ||
| github.com/stretchr/testify v1.11.1 | ||
| ) | ||
|
|
||
| require ( | ||
| github.com/DataDog/datadog-agent/comp/core/tagger/origindetection v0.71.0 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/obfuscate v0.71.0 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/opentelemetry-mapping-go/otlp/attributes v0.71.0 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/proto v0.71.0 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/remoteconfig/state v0.73.0-rc.1 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/trace v0.71.0 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/util/log v0.71.0 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/util/scrubber v0.71.0 // indirect | ||
| github.com/DataDog/datadog-agent/pkg/version v0.71.0 // indirect | ||
| github.com/DataDog/datadog-go/v5 v5.6.0 // indirect | ||
| github.com/DataDog/go-libddwaf/v4 v4.6.1 // indirect | ||
| github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20250721125240-fdf1ef85b633 // indirect | ||
| github.com/DataDog/go-sqllexer v0.1.8 // indirect | ||
| github.com/DataDog/go-tuf v1.1.1-0.5.2 // indirect | ||
| github.com/DataDog/sketches-go v1.4.7 // indirect | ||
| github.com/Masterminds/semver/v3 v3.3.1 // indirect | ||
| github.com/Microsoft/go-winio v0.6.2 // indirect | ||
| github.com/bahlo/generic-list-go v0.2.0 // indirect | ||
| github.com/buger/jsonparser v1.1.1 // indirect | ||
| github.com/cenkalti/backoff/v5 v5.0.3 // indirect | ||
| github.com/cespare/xxhash/v2 v2.3.0 // indirect | ||
| github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 // indirect | ||
| github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | ||
| github.com/dustin/go-humanize v1.0.1 // indirect | ||
| github.com/ebitengine/purego v0.8.4 // indirect | ||
| github.com/go-logr/logr v1.4.3 // indirect | ||
| github.com/go-logr/stdr v1.2.2 // indirect | ||
| github.com/go-ole/go-ole v1.3.0 // indirect | ||
| github.com/go-viper/mapstructure/v2 v2.4.0 // indirect | ||
| github.com/gogo/protobuf v1.3.2 // indirect | ||
| github.com/golang/protobuf v1.5.4 // indirect | ||
| github.com/google/uuid v1.6.0 // indirect | ||
| github.com/hashicorp/go-version v1.7.0 // indirect | ||
| github.com/invopop/jsonschema v0.13.0 // indirect | ||
| github.com/json-iterator/go v1.1.12 // indirect | ||
| github.com/klauspost/compress v1.18.0 // indirect | ||
| github.com/klauspost/cpuid/v2 v2.2.3 // indirect | ||
| github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 // indirect | ||
| github.com/mailru/easyjson v0.7.7 // indirect | ||
| github.com/minio/simdjson-go v0.4.5 // indirect | ||
| github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
| github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect | ||
| github.com/outcaste-io/ristretto v0.2.3 // indirect | ||
| github.com/philhofer/fwd v1.2.0 // indirect | ||
| github.com/pkg/errors v0.9.1 // indirect | ||
| github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect | ||
| github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect | ||
| github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect | ||
| github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect | ||
| github.com/secure-systems-lab/go-securesystemslib v0.9.0 // indirect | ||
| github.com/shirou/gopsutil/v4 v4.25.8-0.20250809033336-ffcdc2b7662f // indirect | ||
| github.com/spf13/cast v1.7.1 // indirect | ||
| github.com/theckman/httpforwarded v0.4.0 // indirect | ||
| github.com/tinylib/msgp v1.3.0 // indirect | ||
| github.com/tklauser/go-sysconf v0.3.15 // indirect | ||
| github.com/tklauser/numcpus v0.10.0 // indirect | ||
| github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect | ||
| github.com/yosida95/uritemplate/v3 v3.0.2 // indirect | ||
| github.com/yusufpapurcu/wmi v1.2.4 // indirect | ||
| go.opentelemetry.io/auto/sdk v1.1.0 // indirect | ||
| go.opentelemetry.io/collector/component v1.39.0 // indirect | ||
| go.opentelemetry.io/collector/featuregate v1.39.0 // indirect | ||
| go.opentelemetry.io/collector/internal/telemetry v0.133.0 // indirect | ||
| go.opentelemetry.io/collector/pdata v1.39.0 // indirect | ||
| go.opentelemetry.io/contrib/bridges/otelzap v0.12.0 // indirect | ||
| go.opentelemetry.io/otel v1.37.0 // indirect | ||
| go.opentelemetry.io/otel/log v0.13.0 // indirect | ||
| go.opentelemetry.io/otel/metric v1.37.0 // indirect | ||
| go.opentelemetry.io/otel/sdk v1.37.0 // indirect | ||
| go.opentelemetry.io/otel/trace v1.37.0 // indirect | ||
| go.uber.org/atomic v1.11.0 // indirect | ||
| go.uber.org/multierr v1.11.0 // indirect | ||
| go.uber.org/zap v1.27.0 // indirect | ||
| go.yaml.in/yaml/v3 v3.0.4 // indirect | ||
| golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect | ||
| golang.org/x/mod v0.29.0 // indirect | ||
| golang.org/x/net v0.46.0 // indirect | ||
| golang.org/x/sys v0.37.0 // indirect | ||
| golang.org/x/text v0.30.0 // indirect | ||
| golang.org/x/time v0.12.0 // indirect | ||
| golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect | ||
| google.golang.org/genproto/googleapis/rpc v0.0.0-20250707201910-8d1bb00bc6a7 // indirect | ||
| google.golang.org/grpc v1.75.0 // indirect | ||
| google.golang.org/protobuf v1.36.7 // indirect | ||
| gopkg.in/ini.v1 v1.67.0 // indirect | ||
| gopkg.in/yaml.v3 v3.0.1 // indirect | ||
| ) | ||
|
|
||
| replace github.com/DataDog/dd-trace-go/v2 => ../../.. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.