feat(contrib/modelcontextprotocol/go-sdk): support per-request intent capture predicate#4976
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Config Audit |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 1c71aaf | Docs | Datadog PR Page | Give us feedback! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e1b8652377
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if !enabled(ctx) { | ||
| return next(ctx, method, req) | ||
| } |
There was a problem hiding this comment.
Restrict predicate evaluation to tool requests
WithIntentCapturePredicate is documented as being consulted for tools/list and tools/call, but this check runs before the method switch, so it also invokes user code for initialize and any other server method where intent capture cannot apply. In servers whose predicate expects tool/list request context or performs an expensive/fragile feature-flag lookup, ordinary session initialization can now pay for or fail inside that callback; move the predicate check into the tools/list and tools/call cases.
Useful? React with 👍 / 👎.
e1b8652 to
b5190ee
Compare
e8264c6 to
054deb3
Compare
BenchmarksBenchmark execution time: 2026-07-06 16:09:56 Comparing candidate commit 1c71aaf in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 326 metrics, 0 unstable metrics, 1 flaky benchmarks without significant changes.
|
|
/stack merge --delay monday 7am EDT |
|
View all feedbacks in Devflow UI.
Progress updates will be sent here directly.
Pull Request scheduled to be added to the queue on Mon, 06 Jul 2026 11:00:00 UTC
The expected merge time in
The expected merge time in
This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
The expected merge time in
This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
The expected merge time in
This stack was merged successfully. |
… capture predicate
…pture predicate test Race detector caught `enabled` being written by the test goroutine and read by the server's callback goroutine. Switched to atomic.Bool. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
f8b41fe to
1c71aaf
Compare
054deb3 to
90174ac
Compare
afdd917
into
main

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