Dev.to Security πŸ” Cybersecurity πŸ‘ 0 πŸ“– 3 min read

VPC-Private PDF, DOCX & Excel PII Redaction for Amazon Bedrock and RAG via MCP (

Enterprise teams adopting Amazon Bedrock, LangGraph, or internal RAG pipelines run into the same compliance wall on day one: most valuable company knowledge lives inside messy PDFs, Word contracts (.docx), and Excel spre

Enterprise teams adopting Amazon Bedrock, LangGraph, or internal RAG pipelines run into the same compliance wall on day one: most valuable company knowledge lives inside messy PDFs, Word contracts (.docx), and Excel spreadsheets (.xlsx) packed with customer PII, SSNs, credit cards, emails, and leaked cloud secrets.

Sending raw internal documents to a third-party cloud DLP SaaS API solves one risk by creating anotherβ€”your regulated files just left your AWS VPC. On the other hand, rolling your own ad-hoc regex scripts leads to false positives (flagging 16-digit order numbers as credit cards without Luhn verification) and zero native support for Model Context Protocol (MCP) or Amazon Bedrock AgentCore.

In this walkthrough, we'll show how to run a 100% VPC-private, zero-egress Document Extraction + Deterministic PII Redaction MCP Server on Amazon EKS, ECS Fargate, or Amazon Bedrock AgentCore Runtime.

Architecture: Zero-Egress Document Sanitization Inside Your VPC

PDF / DOCX / XLSX / Raw Text
            β”‚
            β–Ό  (Private VPC Subnet β€” Zero Outbound Internet)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  CoreNova Private Document & PII Redaction MCP Server     β”‚
β”‚  1. Offline Extraction (PDF, DOCX, XLSX, TXT)             β”‚
β”‚  2. Deterministic <15ms PII & Cloud Secret Redaction      β”‚
β”‚     (Luhn CC, SSN, IBAN, AWS/GitHub/API keys, PEM, JWT)   β”‚
β”‚  3. Configurable RAG Chunking (size + overlap)            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
            β”‚  POST /mcp (JSON-RPC 2.0)  |  POST /invocations
            β–Ό
  Sanitized RAG Chunks ──▢ Amazon Bedrock / OpenSearch / Vector DB

Why Deterministic Redaction Beats LLM-Based Scrubbing for Compliance

  • Sub-15ms latency & zero GPU required: Runs comfortably on 0.5–1 vCPU / 512 MB–1 GB RAM (both linux/amd64 and AWS Graviton linux/arm64).
  • Three redaction modes:
    • mask β€” irreversible masking ([REDACTED_SSN_1]) for embeddings & public analytics
    • hash β€” deterministic cryptographic replacement for cross-document entity correlation without exposing raw PII
    • tokenize β€” reversible token map inside your trusted VPC boundary so downstream workflows can safely re-hydrate authorized responses
  • Luhn-validated card detection: Eliminates false positives on 16-digit invoice/tracking IDs while reliably redacting real payment card numbers.

Deploying on Amazon ECS Fargate, EKS, or Bedrock AgentCore

The container is packaged as a multi-architecture (linux/amd64 + linux/arm64), non-root slim image available directly on AWS Marketplace (consolidated AWS billing, zero external vendor onboarding).

1. Pull from AWS Marketplace ECR

aws ecr get-login-password --region us-east-1 \
  | docker login --username AWS --password-stdin 709825985650.dkr.ecr.us-east-1.amazonaws.com

docker pull 709825985650.dkr.ecr.us-east-1.amazonaws.com/corenova-intelligence/corenova/doc-pii-mcp:1.0.0

2. Verify Readiness (/ping)

curl -s http://doc-pii-mcp.internal:8080/ping
# {"status":"Healthy","service":"corenova-doc-pii-mcp"}

3. Call via Streamable HTTP MCP (POST /mcp)

List tools via standard MCP JSON-RPC 2.0:

curl -s http://doc-pii-mcp.internal:8080/mcp \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

Extract and redact a document or text payload into clean RAG chunks:

curl -s http://doc-pii-mcp.internal:8080/mcp \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "id": 2,
    "method": "tools/call",
    "params": {
      "name": "redact_pii_text",
      "arguments": {
        "text": "Contract signed by [email protected] (SSN 123-45-6789) with deployment key AKIAIOSFODNN7EXAMPLE. Order #1234-5678-9012-3456.",
        "mode": "tokenize"
      }
    }
  }'

Result:

  • [email protected] β†’ [EMAIL_1]
  • 123-45-6789 β†’ [SSN_1]
  • AKIAIOSFODNN7EXAMPLE β†’ [AWS_ACCESS_KEY_1]
  • 1234-5678-9012-3456 β†’ preserved untouched (fails Luhn check, zero false positive!)

4. Native Amazon Bedrock AgentCore Runtime Support (POST /invocations)

Because the container implements both GET /ping and POST /invocations on port 8080, it drops straight into Amazon Bedrock AgentCore Runtime as well as standard Kubernetes/EKS Services and ECS Fargate tasksβ€”with zero outbound internet access required.

Available Now on AWS Marketplace

CoreNova Private Document & PII Redaction MCP Server is live publicly on AWS Marketplace with predictable monthly and annual VPC deployment licensing (billed on your existing AWS invoice):

If you're building private RAG pipelines on Amazon Bedrock, EKS, or ECS and have questions on air-gapped document parsing or custom PII rules, drop a comment below!

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.