Skip to content

feat: Add IResponseSanitizer seam for pluggable MCP response sanitization - #3777

Open
Garrett Beatty (GarrettBeatty) wants to merge 1 commit into
microsoft:mainfrom
GarrettBeatty:iresponsesanitizer-seam
Open

feat: Add IResponseSanitizer seam for pluggable MCP response sanitization#3777
Garrett Beatty (GarrettBeatty) wants to merge 1 commit into
microsoft:mainfrom
GarrettBeatty:iresponsesanitizer-seam

Conversation

@GarrettBeatty

Copy link
Copy Markdown

Draft implementation for #3776.

Problem

McpResponseSanitizer is sealed with no interface and McpGovernanceRuntime depends on the concrete type, so response sanitization can't be replaced or extended.

Change

  • Add IResponseSanitizer (ScanText) in AgentGovernance.Mcp; McpResponseSanitizer implements it (no behavior change).
  • McpGovernanceRuntime depends on IResponseSanitizer.
  • WithGovernance registers the default behind the interface via TryAddSingleton, so a consumer can register their own IResponseSanitizer before WithGovernance and it wins.

Tests

Adds coverage for default resolution and custom replacement. All existing MCP tests pass (82 total).

Draft: opening to align on the API shape (interface surface, optional composition of multiple sanitizers) before finalizing. Happy to iterate.

McpResponseSanitizer is sealed with no interface and McpGovernanceRuntime depends
on the concrete type, so response sanitization cannot be replaced or extended.

- Add IResponseSanitizer (ScanText) in AgentGovernance.Mcp; McpResponseSanitizer
  implements it (no behavior change).
- McpGovernanceRuntime now depends on IResponseSanitizer.
- WithGovernance registers the default behind the interface via TryAddSingleton,
  so a consumer can register their own IResponseSanitizer before WithGovernance
  and it wins.

Adds tests for default resolution and custom replacement.

Refs microsoft#3776
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions

Copy link
Copy Markdown

PR Review Summary

Check Status Details
🔍 Code Review ⚠️ Missing No current-run comment
🛡️ Security Scan ⚠️ Missing No current-run comment
🔄 Breaking Changes ⚠️ Missing No current-run comment
📝 Docs Sync ⚠️ Missing No current-run comment
🧪 Test Coverage ⚠️ Missing No current-run comment

Verdict: ⚠️ AI review incomplete; ready for human review

AI review comments are untrusted advisory output. The summary reports workflow-generated completion status only, not model-authored pass/fail claims.

@github-actions github-actions Bot added tests size/M Medium PR (< 200 lines) labels Aug 18, 2026
@GarrettBeatty

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Amazon"

@GarrettBeatty Garrett Beatty (GarrettBeatty) changed the title Add IResponseSanitizer seam for pluggable MCP response sanitization feat: Add IResponseSanitizer seam for pluggable MCP response sanitization Aug 18, 2026
@GarrettBeatty
Garrett Beatty (GarrettBeatty) marked this pull request as ready for review August 18, 2026 23:32
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR (< 200 lines) tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant