Skip to content

fix(ai-mcp-sanitizer): Verify and update docs - #8355

Open
tomek-labuk wants to merge 8 commits into
release/ai-gateway-2.4from
fix.mcp-sanitizer
Open

tomek-labuk wants to merge 8 commits into
release/ai-gateway-2.4from
fix.mcp-sanitizer

Conversation

@tomek-labuk

@tomek-labuk tomek-labuk commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes #8305

Open items

  • Unverified claims: error code 1004 and its message, "never sanitizes authentication tools", and the hard-coded PLACEHOLDER1/PLACEHOLDER2 numbering in the how-to.
  • Logging condition: whether the sanitizer log object depends on a logging setting. Needs a live test.
  • payloads warning: reword once kong-ee PR 25720 merges.
  • Scopes: app/_data/policies/ai-gateway/scopes.json needs the ai-mcp-sanitizer entry (added here) so the examples render.
  • How-to: redact-pii-in-mcp-tool-calls still has to be tested.

Testing

For testing, use Konnect API instead of kongctl (it isn't ready yet)

Step 1: Create an AI MCP Sanitizer Policy

curl -X POST "https://us.api.konghq.tech/v1/ai-gateways/$AI_GATEWAY_ID/policies" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN"\
     -H "Content-Type: application/json" \
     --json '{
       "name": "mcp-sanitizer",
       "display_name": "MCP sanitizer",
       "type": "ai-mcp-sanitizer",
       "config": {
         "anonymize": [
           "email",
           "phone"
         ],
         "sanitize_targets": [
           "tool_arguments",
           "tool_results"
         ],
         "host": "ai-pii-service",
         "port": 8080,
         "recover_redacted": false,
         "stop_on_error": true
       }
     }'

Step 2: Crerate an AI MCP Server

curl -X POST "https://us.api.konghq.tech/v1/ai-gateways/$AI_GATEWAY_ID/mcp-servers" \
     --no-progress-meter --fail-with-body  \
     -H "Authorization: Bearer $KONNECT_TOKEN"\
     -H "Content-Type: application/json" \
     --json '{
       "name": "petstore-mcp",
       "display_name": "Petstore API",
       "type": "conversion-listener",
       "enabled": true,
       "policies": [
         "mcp-sanitizer"
       ],
       "config": {
         "url": "http://host.docker.internal:8080/api/v3",
         "route": {
           "paths": [
             "/petstore"
           ]
         }
       },
       "tools": [
         {
           "name": "add-pet",
           "description": "Add a pet",
           "method": "POST",
           "path": "/petstore/pet",
           "request_body": {
             "content": {
               "application/json": {
                 "schema": {
                   "type": "object",
                   "properties": {
                     "id": {
                       "type": "integer"
                     },
                     "name": {
                       "type": "string"
                     },
                     "photoUrls": {
                       "type": "array",
                       "items": {
                         "type": "string"
                       }
                     },
                     "status": {
                       "type": "string"
                     }
                   }
                 }
               }
             }
           }
         },
         {
           "name": "get-pet-by-id",
           "description": "Get a pet by ID",
           "method": "GET",
           "path": "/petstore/pet/{petId}",
           "parameters": [
             {
               "name": "petId",
               "in": "path",
               "required": true,
               "schema": {
                 "type": "integer"
               },
               "description": "ID of the pet to retrieve"
             }
           ]
         }
       ]
     }'

Preview Links

Pages with changes:

Examples:

Checklist

  • Tested how-to docs. If not, note why here.
  • Any new docs link to existing docs.
  • All autogenerated instructions render correctly.
  • Add new pages to the product documentation index (if applicable).

@netlify

netlify Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for kongdeveloper ready!

Name Link
🔨 Latest commit 9df244c
🔍 Latest deploy log https://app.netlify.com/projects/kongdeveloper/deploys/6b0ff1b465af33453836faba
😎 Deploy Preview https://deploy-preview-8355--kongdeveloper.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@tomek-labuk tomek-labuk changed the title fix(ai-mcp-sanitizer): Update documnetations fix(ai-mcp-sanitizer): Update documnetation Nov 27, 2026
@tomek-labuk
tomek-labuk marked this pull request as ready for review November 27, 2026 17:12
@tomek-labuk
tomek-labuk requested a review from a team as a code owner November 27, 2026 17:12
@kong-ksai
kong-ksai Bot requested a review from a team November 27, 2026 17:12
@kong-ksai

kong-ksai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ KSAI Review: Finished


Run report (federated) · 1 paid run · $0.5722 total
# Engine Result Model Turns Cost
1 opencode2 success deepseek-ai/deepseek-v4.1-flash/high 115 $0.5722

Reviewing cost $0.5722

@tomek-labuk tomek-labuk changed the title fix(ai-mcp-sanitizer): Update documnetation fix(ai-mcp-sanitizer): Verify and update docs Nov 27, 2026

@kong-ksai kong-ksai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check Result
Scope Complete frozen scope: the seven policy examples, the policy page, the AI Gateway scope data, the new how-to, the sanitizer log and PII service includes, and the audit log reference.
Mandate Default adversarial code review, plus the AI Gateway, core, how-to, output block, prose, plugin reference, related resources, schema restate and UI inventory rules on the files each covers.
Findings 2 Medium, 3 Low
Findings audit Independent audit completed: 5 kept, 0 removed, 0 with insufficient evidence, 0 added.

All five candidate findings survive the audit. The rewritten error-handling bullets contradict the schema that renders the reference the page links to, the how-to's first placeholder output is reversed against its own second check and the sibling pages, and the image bump leaves stale v0.3.1 copies in sibling files.

One disagreement is the only behavioral risk, at Medium; the reversed sample output is the other Medium. The remaining three are Low: two stale version copies, a missing output-block marker and a conditional opener. No additional defect met the evidence bar, so the added list is empty.

Coverage was complete over the frozen scope: the seven examples, the policy page, the scope data, the how-to, the log and service includes and the audit log reference were read against the pinned schema, sibling how-tos, the cookbook and the entity docs.

@kong-ksai
kong-ksai Bot removed the request for review from a team November 27, 2026 17:24
render_output: false
{% endvalidation %}
<!--vale on-->

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we mention something here about the email and phone being redacted too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, added. The validation output now shows both email and phone as placeholders, and the text says so.

sanitize_targets:
- tool_arguments
- tool_results
port: 8080

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I meant port 🤦

paths:
- /petstore
tools:
- name: add-pet

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use a different endpoint for the how-to? /user actually has email and phone number and makes more sense than setting a phone number and email to a pet's name

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to /user (create-user and get-user-by-name), so the email and phone are real fields now. I ran it and the output in the doc matches.

@tomek-labuk
tomek-labuk requested a review from fabianrbz December 2, 2026 09:52
@tomek-labuk tomek-labuk linked an issue Dec 2, 2026 that may be closed by this pull request
4 tasks
docker run -d \
--name ai-pii-service \
--network kong-ai-quickstart-net \
kong/ai-pii-service:v0.3.1-en

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
kong/ai-pii-service:v0.3.1-en
kong/ai-pii-service:latest-en

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test AI MCP PII Sanitizer

2 participants