← Back to Pull requests

feat(@modelcontextprotocol/sdk): capture MCP tool call intent #11319

Closed
unknown closed this pull request without merging on Nov 24, 2026 13:50 UTC
View on GitHub
unknown unknown commented on Nov 18, 2026 20:44 UTC
Author

What does this PR do?

Adds MCP intent capture for SDK 1.x and 2.x servers, off by default (DD_MCP_CAPTURE_INTENT=true), matching dd-trace-py and dd-trace-go.

  • tools/list: each model-callable tool gets a required telemetry argument with an intent string. The result is a copy, so the SDK's registered tools (used for validation) do not change. UI-only tools are skipped.

  • tools/call: the intent is recorded as meta.intent on the server LLM Obs tool span, and the tool runs with a copy of the request without telemetry.

  • Adds intent to the LLM Obs tagger and span event.
  • Motivation

    Parity with dd-trace-py (DD_MCP_CAPTURE_INTENT) and dd-trace-go (WithIntentCapture).

    Additional Notes

  • required gets telemetry (as in Go). dd-trace-py adds intent to the top-level required list instead.

  • Tools that declare their own telemetry argument are left unchanged, and tools/call only removes a telemetry value of the injected { intent } shape.

  • The intent is cut to 1024 characters, because the client writes it. dd-trace-py and dd-trace-go have no limit.

  • The instrumentation now passes ctx.request to the handler and applies ctx.transformResult before the SDK sends the result. In 1.x the request span ends after the response is sent, so the result cannot be changed at asyncEnd.

  • Datadog check (org 2, ml_app:mcp-intent-js-sandbox, server 2.4.0, stateless HTTP): before has no telemetry schema or intent; after has the intent on the server get_weather span and its input without telemetry.
  • 🤖 Generated with Claude Code

    Diff: 237 lines (+177 / -60) across 2 files Reviewer: wconti27 Review duration: 8225m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 237 lines diff across 2 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.327
    Shallow Review Depth shallow_review_depth
    0.289
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #11319"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.2% (MEDIUM) · Higher = larger blast radius
    42.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.7% · Safe to merge
    16.7%