You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature]: apply output_sanitisation (redact / block / spotlight / strip) to direct routing mode #1683
output_sanitisation is the only inline control that removes secrets from, or marks, untrusted tool output before it reaches the agent. The docs list direct routing mode (/mcp/all, server__tool names) as not covered: applyOutputSanitisation is called from the two call_tool_* handlers and from code_execution, but not from makeDirectModeHandler in internal/server/mcp_routing.go.
A deployment that exposes direct mode to agents (the natural interface for clients like Claude Code and Cursor: real tool names, no retrieve_tools round trip) therefore gets detection in the activity log but no inline protection.
Reproduction with the v0.71.1 release binary: config output_sanitisation: {"spotlight_untrusted": true, "response_action": "redact", "strip_control_chars": true} and a stdio server whose read-only tool returns debug: AWS_ACCESS_KEY_ID=AKIAJ5Z7Q3N8W2X4Y6LP (a non-example key shape).
The activity record for the second call is flagged (sensitive_data_detection, critical), but the agent still received the secret.
Proposed solution
In the direct handler, call p.applyOutputSanitisation(ctx, serverName, toolName, requestID, directContentTrust, result) on the raw result before the forward/truncate step, and return its block result when non-nil. This mirrors the two "Spec 054 Track B (pre-forward)" sites in internal/server/mcp.go. Keep the behavior where the activity record and read_cache hold the sanitised copy. Update the "Scope and limits" section of the Output Sanitisation docs.
I am happy to send the PR with tests (a direct-mode counterpart to the existing e2e/stubs/sanitisation coverage) once you confirm the approach and whether it needs a new spec number.
Alternatives considered
Pointing agents at /mcp (call_tool_*) works, but changes the tool-calling interface for every client and hides real tool names from the model.
A path-filtering reverse proxy cannot rewrite response bodies safely.
response_action: block does not help either, since it is also skipped in direct mode.
Which edition?
Both / not sure (tested on Personal)
Pre-submission checklist
I searched existing issues and discussions for a similar request
Activity
docs(output-sanitisation): direct routing mode is now covered
feat(server): apply output_sanitisation to direct routing mode (#1685)