Repository navigation
fix(ai-mcp-sanitizer): Verify and update docs #8355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tomek-labuk
wants to merge
8
commits into
release/ai-gateway-2.4
Choose a base branch
from
fix.mcp-sanitizer
base: release/ai-gateway-2.4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+670
−43
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
db6df90
Updates based on testing
tomek-labuk 33d9fc7
updates
tomek-labuk 2c20e77
Update documentation
tomek-labuk 70ddc62
docs updates
tomek-labuk 301079d
updates
tomek-labuk 29b6c4d
fixes
tomek-labuk 7c8895c
Apply suggestion from @kong-ksai[bot]
fabianrbz 9df244c
Fixes
tomek-labuk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
app/_ai_gateway_policies/ai-mcp-sanitizer/examples/block-tool-calls-that-contain-pii.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| description: | | ||
| Configure the AI MCP Sanitizer Policy to reject a tool call, or replace a tool result with an error, when the PII service detects Social Security numbers or email addresses, instead of redacting them. | ||
| title: Block tool calls that contain PII | ||
|
|
||
| weight: 870 | ||
|
|
||
| scopes: | ||
| - ai-mcp-server | ||
| - global | ||
|
|
||
| requirements: | ||
| - An existing [AI MCP Server](/ai-gateway/entities/ai-mcp-server/). | ||
| - An [AI PII Anonymizer service image](/ai-gateway/policies/ai-mcp-sanitizer/#ai-pii-anonymizer-service), pulled and running. | ||
|
|
||
| variables: | ||
| host: | ||
| description: The sanitizer service's host | ||
| value: $SANITIZER_SERVICE_HOST | ||
|
|
||
| name: block-tool-calls-that-contain-pii | ||
| display_name: Block tool calls that contain PII | ||
| type: ai-mcp-sanitizer | ||
|
|
||
| config: | ||
| anonymize: | ||
| - ssn | ||
| sanitize_targets: | ||
| - tool_arguments | ||
| - tool_results | ||
| port: 8080 | ||
| host: ${host} | ||
| recover_redacted: false | ||
| block_if_detected: true | ||
| rejection_mode: none | ||
| stop_on_error: true | ||
|
|
||
| tools: | ||
| - konnect-api | ||
| - terraform | ||
| - kongctl | ||
42 changes: 42 additions & 0 deletions
42
app/_ai_gateway_policies/ai-mcp-sanitizer/examples/custom-employee-id-pattern.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| description: | | ||
| Configure the AI MCP Sanitizer Policy to redact a custom identifier, such as an employee ID in the format `EMP-123456`, in tool call arguments. | ||
|
|
||
| title: Redact employee IDs with a custom pattern | ||
|
|
||
| weight: 860 | ||
|
|
||
| scopes: | ||
| - ai-mcp-server | ||
| - global | ||
|
|
||
| requirements: | ||
| - An existing [AI MCP Server](/ai-gateway/entities/ai-mcp-server/). | ||
| - An [AI PII Anonymizer service image](/ai-gateway/policies/ai-mcp-sanitizer/#ai-pii-anonymizer-service), pulled and running. | ||
|
|
||
| variables: | ||
| host: | ||
| description: The sanitizer service's host | ||
| value: $SANITIZER_SERVICE_HOST | ||
|
|
||
| name: custom-employee-id-pattern | ||
| display_name: Redact employee IDs with a custom pattern | ||
| type: ai-mcp-sanitizer | ||
|
|
||
| config: | ||
| anonymize: | ||
| - custom | ||
| custom_patterns: | ||
| - name: employee_id | ||
| regex: "EMP-[0-9]{6}" | ||
| score: 0.9 | ||
| sanitize_targets: | ||
| - tool_arguments | ||
| port: 8080 | ||
| host: ${host} | ||
| recover_redacted: false | ||
| stop_on_error: true | ||
|
|
||
| tools: | ||
| - konnect-api | ||
| - terraform | ||
| - kongctl |
41 changes: 41 additions & 0 deletions
41
app/_ai_gateway_policies/ai-mcp-sanitizer/examples/hide-sanitized-items-from-logs.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| description: | | ||
| Configure the AI MCP Sanitizer Policy to redact PII in tool call arguments and keep the sanitized items out of your logs. Use this when the logs themselves must not hold sensitive data. | ||
|
|
||
| title: Hide sanitized items from logs | ||
|
|
||
| weight: 840 | ||
|
|
||
| scopes: | ||
| - ai-mcp-server | ||
| - global | ||
|
|
||
| requirements: | ||
| - An existing [AI MCP Server](/ai-gateway/entities/ai-mcp-server/). | ||
| - An [AI PII Anonymizer service image](/ai-gateway/policies/ai-mcp-sanitizer/#ai-pii-anonymizer-service), pulled and running. | ||
|
|
||
| variables: | ||
| host: | ||
| description: The sanitizer service's host | ||
| value: $SANITIZER_SERVICE_HOST | ||
|
|
||
| name: hide-sanitized-items-from-logs | ||
| display_name: Hide sanitized items from logs | ||
| type: ai-mcp-sanitizer | ||
|
|
||
| config: | ||
| anonymize: | ||
| - ssn | ||
| - phone | ||
| sanitize_targets: | ||
| - tool_arguments | ||
| port: 8080 | ||
| host: ${host} | ||
| recover_redacted: false | ||
| skip_logging_sanitized_items: true | ||
| stop_on_error: true | ||
|
|
||
| tools: | ||
| - konnect-api | ||
| - terraform | ||
| - kongctl |
39 changes: 39 additions & 0 deletions
39
app/_ai_gateway_policies/ai-mcp-sanitizer/examples/recover-redacted-values.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| description: | | ||
| Configure the AI MCP Sanitizer Policy to send placeholders to the tool server and restore the original values when the tool returns them in its result. Recovery applies only to values redacted in tool call arguments. | ||
|
|
||
| title: Restore redacted values in tool results | ||
|
|
||
| weight: 850 | ||
|
|
||
| scopes: | ||
| - ai-mcp-server | ||
| - global | ||
|
|
||
| requirements: | ||
| - An existing [AI MCP Server](/ai-gateway/entities/ai-mcp-server/). | ||
| - An [AI PII Anonymizer service image](/ai-gateway/policies/ai-mcp-sanitizer/#ai-pii-anonymizer-service), pulled and running. | ||
|
|
||
| variables: | ||
| host: | ||
| description: The sanitizer service's host | ||
| value: $SANITIZER_SERVICE_HOST | ||
|
|
||
| name: recover-redacted-values | ||
| display_name: Restore redacted values in tool results | ||
| type: ai-mcp-sanitizer | ||
|
|
||
| config: | ||
| anonymize: | ||
| - ssn | ||
| sanitize_targets: | ||
| - tool_arguments | ||
| port: 8080 | ||
| host: ${host} | ||
| recover_redacted: true | ||
| stop_on_error: true | ||
|
|
||
| tools: | ||
| - konnect-api | ||
| - terraform | ||
| - kongctl |
41 changes: 41 additions & 0 deletions
41
app/_ai_gateway_policies/ai-mcp-sanitizer/examples/sanitize-arguments-and-results.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| description: | | ||
| Configure the AI MCP Sanitizer Policy to redact PII in both the arguments sent to a tool and the result the tool returns. You must set `recover_redacted` to `false` when you target tool results. | ||
|
|
||
| title: Sanitize tool call arguments and results | ||
|
|
||
| weight: 880 | ||
|
|
||
| scopes: | ||
| - ai-mcp-server | ||
| - global | ||
|
|
||
| requirements: | ||
| - An existing [AI MCP Server](/ai-gateway/entities/ai-mcp-server/). | ||
| - An [AI PII Anonymizer service image](/ai-gateway/policies/ai-mcp-sanitizer/#ai-pii-anonymizer-service), pulled and running. | ||
|
|
||
| variables: | ||
| host: | ||
| description: The sanitizer service's host | ||
| value: $SANITIZER_SERVICE_HOST | ||
|
|
||
| name: sanitize-arguments-and-results | ||
| display_name: Sanitize tool call arguments and results | ||
| type: ai-mcp-sanitizer | ||
|
|
||
| config: | ||
| anonymize: | ||
| - ssn | ||
| - phone | ||
| sanitize_targets: | ||
| - tool_arguments | ||
| - tool_results | ||
| port: 8080 | ||
| host: ${host} | ||
| recover_redacted: false | ||
| stop_on_error: true | ||
|
|
||
| tools: | ||
| - konnect-api | ||
| - terraform | ||
| - kongctl |
40 changes: 40 additions & 0 deletions
40
app/_ai_gateway_policies/ai-mcp-sanitizer/examples/sanitize-tool-arguments.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| description: | | ||
| Configure the AI MCP Sanitizer Policy to redact Social Security numbers, email addresses, and phone numbers in the arguments an agent sends to a tool. The tool server receives placeholders instead of the original values. | ||
|
|
||
| title: Sanitize tool call arguments | ||
|
|
||
| weight: 900 | ||
|
|
||
| scopes: | ||
| - ai-mcp-server | ||
| - global | ||
|
|
||
| requirements: | ||
| - An existing [AI MCP Server](/ai-gateway/entities/ai-mcp-server/). | ||
| - An [AI PII Anonymizer service image](/ai-gateway/policies/ai-mcp-sanitizer/#ai-pii-anonymizer-service), pulled and running. | ||
|
|
||
| variables: | ||
| host: | ||
| description: The sanitizer service's host | ||
| value: $SANITIZER_SERVICE_HOST | ||
|
|
||
| name: sanitize-tool-arguments | ||
| display_name: Sanitize tool call arguments | ||
| type: ai-mcp-sanitizer | ||
|
|
||
| config: | ||
| anonymize: | ||
| - ssn | ||
| - phone | ||
| sanitize_targets: | ||
| - tool_arguments | ||
| port: 8080 | ||
| host: ${host} | ||
| recover_redacted: false | ||
| stop_on_error: true | ||
|
|
||
| tools: | ||
| - konnect-api | ||
| - terraform | ||
| - kongctl |
40 changes: 40 additions & 0 deletions
40
app/_ai_gateway_policies/ai-mcp-sanitizer/examples/sanitize-tool-results.yml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| description: | | ||
| Configure the AI MCP Sanitizer Policy to redact PII in the results that a tool returns, so the agent and the LLM context never receive the original values. The Policy forwards the arguments to the tool server unchanged. | ||
|
|
||
| title: Sanitize tool call results | ||
|
|
||
| weight: 890 | ||
|
|
||
| scopes: | ||
| - ai-mcp-server | ||
| - global | ||
|
|
||
| requirements: | ||
| - An existing [AI MCP Server](/ai-gateway/entities/ai-mcp-server/). | ||
| - An [AI PII Anonymizer service image](/ai-gateway/policies/ai-mcp-sanitizer/#ai-pii-anonymizer-service), pulled and running. | ||
|
|
||
| variables: | ||
| host: | ||
| description: The sanitizer service's host | ||
| value: $SANITIZER_SERVICE_HOST | ||
|
|
||
| name: sanitize-tool-results | ||
| display_name: Sanitize tool call results | ||
| type: ai-mcp-sanitizer | ||
|
|
||
| config: | ||
| anonymize: | ||
| - ssn | ||
| - phone | ||
| sanitize_targets: | ||
| - tool_results | ||
| port: 8080 | ||
| host: ${host} | ||
| recover_redacted: false | ||
| stop_on_error: true | ||
|
|
||
| tools: | ||
| - konnect-api | ||
| - terraform | ||
| - kongctl |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use a variable for the host too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to using ${host} in that example,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I meant port 🤦