AI Guard: test MCP server metadata in SDK evaluations #8646
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 400 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.359
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #8646"
general
weight: 0.35
avara1986
Motivation
Jira: APPSEC-71867
Customers call AI Guard directly from their code with the SDK. The SDK can now send MCP server metadata with an evaluation: tool calls carry
mcp.server_id, and the call passes the referenced servers asmcp_servers(dd-trace-py,AIGuardClient.evaluate(..., mcp_servers=...)) ormcpServers(dd-trace-js, DataDog/dd-trace-js#11384). No AI Guard SDK test covered it: the weblog endpoint only accepted a bare list of messages, somcp_serverscould not be passed.Changes
POST /ai_guard/evaluate(Flask and Express) also accepts an object body,{"messages": [...], "mcp_servers": [...]}, and passes the servers to the SDK. A bare list of messages keeps working. Flask passesmcp_servers=only when it is sent, so older tracers are unaffected.docs/understand/weblogs/end-to-end_weblog.mddocuments the new body, with an example.Test_MCP_ToolCallssends a tool call withmcp.server_idand its server list. It asserts:- an
ALLOWresponse, which only a match of the body-hashed evaluate cassette returns, so a tracer that dropsmcp_serversormcp.server_idfails;- the
ai_guardspan meta-struct reports the sentmcp_serversand keeps the tool call'smcpreference.aiguard_evaluate_post_812be9b8.json, recorded withutils/scripts/generate-ai-guard-cassettes.shagainst the real API and scrubbed (datadog-entity-idremoved, the evaluation ID replaced with a synthetic one). Every weblog sends the samemetain this scenario, so the cassette is shared by all tracers.- Python
flask-poc:v4.18.0-rc1. The SDKmcp_serversargument is not in 4.17.x.- Node.js
express5:missing_featureuntil DataDog/dd-trace-js#11384 ships.- Java and Ruby:
incomplete_test_app, because their weblog does not accept the new body.- Go, .NET, PHP and C++:
missing_feature, like the other SDK tests there.Validation, run locally:
flask-poc(python@4.18.0-rc1, dd-trace-py main): PASSED. Before the cassette existed, the same test failed with anAIGuardClientError(500). The VCR log showed that the tracer sent exactly the expected body hash.express5with the DataDog/dd-trace-js#11384 commit: XPASS, with the same cassette, so both tracers send the identical body../format.shpasses.Workflow
1. ⚠️ Create your PR as draft ⚠️
2. Work on you PR until the CI passes
3. Mark it as ready for review
Tests, manifest, weblog are modified -> you'll need a review from
system-tests-reviewers: ask to one of youre co-worker familiar with the tested feature.Framework is modified, or non obvious usage of it -> get a review from
system-tests-core(slack):rocket: Once your PR is reviewed and the CI green, you can merge it!
🛟 #apm-shared-testing 🛟
🤖 Generated with Claude Code
[APPSEC-71867]: https://datadoghq.atlassian.net/browse/APPSEC-71867?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ