feat(contrib/modelcontextprotocol/go-sdk): support per-request intent capture predicate#4950
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
6b1d0b4 to
ccb716c
Compare
8c01bd1 to
6e4c4b7
Compare
BenchmarksBenchmark execution time: 2026-07-01 14:41:51 Comparing candidate commit d770b68 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 321 metrics, 2 unstable metrics, 1 flaky benchmarks without significant changes.
|
ccb716c to
e8264c6
Compare
6e4c4b7 to
e1b8652
Compare
Config Audit |
d770b68 to
ccb716c
Compare
ccb716c
into
jb/gosdk-skip-ui-only-tools
e8264c6 to
ccb716c
Compare
…4944) ## Summary One of the reasons we make a clone of this mcp-go contrib in dd-source was for feature flagging. Originally this was supposed to be temporary, but it continues to be used for org opt-outs and compliance. So in order to remove the clone, we now need to build this per-request optionality as a feature of the SDK. ## What this enables in dd-source The internal dd-source copy of this contrib ships its own `isIntentCaptureEnabled(ctx)` predicate in [`mcp-go/flags.go`](https://github.com/DataDog/dd-source/blob/d10d624c374b69aa02168983be725532a38562b1/domains/mcp_services/libs/go/mcp/pre-release-external/dd-trace-go/contrib/mark3labs/mcp-go/flags.go) and calls it directly inside the hook and middleware (no public knob to override the static boolean). With this PR, dd-source can pass that same predicate through `TracingConfig.IntentCaptureEnabledFunc` and delete the local fork of the hook/middleware. ## Test plan - [x] `TestIntentCaptureEnabledFunc` — same config, two contexts: predicate `false` skips schema injection AND leaves the telemetry argument intact in the handler args; predicate `true` injects and strips. - [x] `TestIntentCaptureEnabledFuncOverridesBool` — when both the static `bool` and the predicate are set, the predicate wins. - [x] All existing intent-capture and tracing tests still pass. Stacked on #4943. --- Parallel port in the modelcontextprotocol/go-sdk contrib: #4950 Co-authored-by: jboolean <julian.boilen@datadoghq.com>

This PR stack ports functionality added in the clone of this contrib in dd-source back to dd-trace-go (Rapid clone at
domains/api_platform/libs/go/mcp/tracing).Summary
The SDK contribs, both for mcp-go and go-sdk, were cloned into dd-source in order to feature flag them. This was intended to be temporary. In order to remove the clones, we must port back divergent functionality to the SDK contribs. We also want the contribs to match.
This adds
WithIntentCapturePredicate(func(context.Context) bool) Option. The existingWithIntentCapture()is now a thin wrapper that returnstruefor every request, so existing callers are unaffected. When the predicate returns false, the middleware passes through untouched (no schema injection, no telemetry stripping, no intent annotation).What this enables in dd-source
The Rapid clone ships its own
isIntentCaptureEnabled(ctx)predicate inline in the middleware. With this PR, dd-source can callWithIntentCapturePredicate(isIntentCaptureEnabled)and delete the local fork. Source PR (initial clone with the predicate signature): https://github.com/DataDog/dd-source/pull/414005This mirrors the design of #4944 for the mark3labs contrib so both libraries match.
Test plan
TestIntentCapturePredicate— same option, two states: predicatefalseskips schema injection AND leaves the telemetry argument intact in the handler args; predicatetrueinjects and strips.Stacked on #4949.
Parallel port in the mark3labs/mcp-go contrib: #4944