Repository navigation
Conversation
The /ai_guard/evaluate weblog endpoint also accepts an object body with the messages and the MCP servers they reference, passed to the SDK (mcp_servers in Python, mcpServers in Node.js). Test_MCP_ToolCalls sends a tool call with mcp.server_id and its server list, and checks that the evaluation matches its body-hashed cassette and that the ai_guard span reports mcp_servers and the mcp reference. The cassette was recorded and scrubbed. Enabled for Python from v4.18.0-rc1; missing_feature for Node.js until DataDog/dd-trace-js#11384 ships. APPSEC-71867 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
|
❌ ErrorsYour PR has failed checks. Please review the issues below and take necessary action before merging. 🚦 2 Pipeline jobs failed
ℹ️ InfoNo other issues found (see more)🧪 All tests passed Useful? React with 👍 / 👎 This comment will be updated automatically if new data arrives.🔗 Commit SHA: e5bad10 | Docs | View more details | Give us feedback! |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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:ALLOWresponse, which only a match of the body-hashed evaluate cassette returns, so a tracer that dropsmcp_serversormcp.server_idfails;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.flask-poc:v4.18.0-rc1. The SDKmcp_serversargument is not in 4.17.x.express5:missing_featureuntil feat(aiguard): accept MCP server metadata in the SDK evaluate call dd-trace-js#11384 ships.incomplete_test_app, because their weblog does not accept the new body.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 feat(aiguard): accept MCP server metadata in the SDK evaluate call dd-trace-js#11384 commit: XPASS, with the same cassette, so both tracers send the identical body../format.shpasses.Workflow
system-tests-reviewers: ask to one of youre co-worker familiar with the tested feature.system-tests-core(slack)🚀 Once your PR is reviewed and the CI green, you can merge it!
🛟 #apm-shared-testing 🛟
🤖 Generated with Claude Code