Redaction & Compliance MCP Server
Allows real-time shipping of audit logs to Datadog for SIEM integration, with buffered shipping to minimize overhead.
Supports real-time shipping of audit logs to Elasticsearch for SIEM integration, with buffered shipping.
Supports local model integration for claim verification and LLM proxy, enabling privacy-preserving hallucination detection without API fees.
Provides transparent proxy integration with OpenAI, enabling automatic redaction, detokenization, and optional claim verification for LLM calls.
Allows real-time shipping of audit logs to Splunk for SIEM integration, with buffered shipping.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Redaction & Compliance MCP ServerRedact this text before sending to LLM: 'My credit card is 4111-1111-1111-1111'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Redaction & Compliance MCP Server
Production-Ready Edition | Version 2.0
This repository contains a production-grade implementation of a Redaction & Compliance Model Context Protocol (MCP) server. It provides a pre-flight / post-flight firewall for LLM calls with comprehensive detection, classification, policy enforcement, reversible redaction, selective detokenization, output safety, and immutable audit logging.
β¨ Features
π― Core Capabilities
π Streaming Support: Real-time streaming for OpenAI, Claude, and Gemini with chunk-by-chunk detokenization
π‘οΈ Claim Verification: Research-based hallucination detection with inline warnings (supports local models)
π Transparent Proxy: Zero-code integration - just change your API base URL
π Production-Grade: NGINX, HTTPS, SIEM integration, Redis backend, systemd service
π Advanced Detection
Multi-cloud credentials: AWS (AKID, secrets), Azure (Storage Keys, SAS tokens, Connection Strings), GCP (API keys, OAuth)
OAuth & Bearer tokens: JWT detection, OAuth access tokens
Crypto keys: PEM (RSA, DSA, EC), PKCS#12, Kubernetes config/tokens
PII with validation:
Credit cards with Luhn checksum validation
SSN with format validation (rejects invalid area codes 000, 666, 900-999)
Email addresses and phone numbers
Internal infrastructure: Joby Aviation domains (
*.na.joby.aero,*.az.joby.aero), IP addresses, hostnamesExport control: Aviation keywords (eVTOL, ITAR, FAA certification, flight control systems, propulsion)
π‘οΈ Policy Engine
Geo/region constraints: US, EU, APAC, restricted regions (CN, RU, IR, KP, SY)
Caller-based routing: Trusted caller lists, per-caller detokenization permissions
Data residency: EU GDPR compliance, region-specific model routing
Category actions:
block,redact,internal_only,allowVersion tracking: Policy version embedded in all decisions
π Token Store
In-memory: Fast, stateless, for dev/test
Redis with AES-GCM: Production-grade with encryption at rest
AES-256-GCM encryption
PBKDF2 key derivation
Automatic TTL management
Deterministic placeholders:
Β«token:TYPE:HASH4Β»stable within conversation scope
β οΈ Output Safety
50+ dangerous command patterns: Filesystem destruction, system control, K8s/Docker, databases, cloud infra, network/firewall
External config support: JSON-based custom pattern loading
3 modes:
warning(annotate),block(redact),silent(pass-through)
π Audit & Compliance
Append-only JSONL: Immutable audit trail
Full context capture: Caller, region, categories, decisions, redaction counts
Query API: Search and retrieve audit records
SIEM integration: Real-time shipping to Splunk, Elasticsearch, Datadog, Syslog
Buffered shipping: <5% overhead, batch mode for production
Related MCP server: Shrike Security MCP Server
π Production Installation (5 Minutes)
Automated installer with NGINX, HTTPS, and Client SDK:
# On your Linux server (Ubuntu 20.04+ or RHEL 8+)
wget https://raw.githubusercontent.com/sunkencity999/redaction-compliance-MCP/main/install.sh
chmod +x install.sh
sudo ./install.shWhat it does:
β Installs all dependencies (Python 3.11, Redis, NGINX)
β Generates cryptographic secrets (you backup them)
β Configures SIEM integration (Splunk/Elasticsearch/Datadog)
β Sets up NGINX reverse proxy with HTTPS (Let's Encrypt or self-signed)
β Creates systemd service (auto-start on boot)
β Installs Python Client SDK
β Creates integration examples
β Runs full test suite (186+ tests)
Manual installation: See QUICKSTART.md
π¦ Client SDKs
Python SDK
Seamless integration for Python/backend applications:
# Install SDK (included in automated installer)
pip install -e .Usage:
from mcp_client import MCPClient, MCPConfig
# Configure once
mcp = MCPClient(MCPConfig(
server_url="https://mcp.yourcompany.com",
caller="your-app-name"
))
# Protect LLM calls automatically
user_input = "My AWS key is AKIAIOSFODNN7EXAMPLE, help me debug"
# Redact before sending to LLM
sanitized, handle = mcp.redact(user_input)
# sanitized: "My AWS key is Β«token:SECRET:a3f9Β», help me debug"
# Send sanitized version to OpenAI/Claude/etc
llm_response = your_llm_function(sanitized)
# Restore non-secret tokens
final = mcp.detokenize(llm_response, handle)
# Secrets stay tokenized, PII/ops_sensitive restored!Or use the convenience wrapper:
from mcp_client import MCPClient, MCPConfig
mcp = MCPClient(MCPConfig.from_env())
# One-line protection
response = mcp.safe_llm_call(
user_input,
lambda text: openai.ChatCompletion.create(
model="gpt-4",
messages=[{"role": "user", "content": text}]
).choices[0].message.content
)Examples: See examples/ directory after installation
JavaScript/Browser SDK
For web applications, React, Vue, Angular:
<!-- Include SDK -->
<script src="mcp_client_js/mcp-client.js"></script>
<script>
// Initialize client
const mcp = new MCPClient({
serverUrl: 'https://mcp.yourcompany.com',
caller: 'web-app'
});
// Protect browser-based LLM calls
async function safeChatCompletion(userInput) {
const response = await mcp.safeLLMCall(
userInput,
async (sanitized) => {
// Call OpenAI/Claude from browser
return await callYourLLM(sanitized);
}
);
return response;
}
</script>React Example:
import { MCPClient } from './mcp-client.js';
const mcp = new MCPClient({
serverUrl: process.env.REACT_APP_MCP_SERVER,
caller: 'react-app'
});
function ChatComponent() {
const handleSubmit = async (input) => {
try {
const response = await mcp.safeLLMCall(input, callOpenAI);
setMessages(prev => [...prev, response]);
} catch (error) {
if (error instanceof MCPBlockedError) {
alert('Request blocked: contains sensitive data');
}
}
};
// ... rest of component
}TypeScript supported: See mcp_client_js/mcp-client.d.ts
Examples: See mcp_client_js/examples/ for browser and React demos
π Transparent Proxy Mode (NEW!)
Zero-code integration for existing OpenAI/Claude/Gemini apps:
Just change your API base URL and MCP automatically protects all calls!
import openai
# Change this one line:
openai.api_base = "https://mcp.yourcompany.com/v1"
# Your existing code works unchanged!
response = openai.ChatCompletion.create(
model="gpt-4",
messages=[{"role": "user", "content": "My AWS key is AKIA..."}]
)
# MCP automatically redacts before OpenAI sees it!Supported Providers:
β OpenAI (
/v1/chat/completions) - Streaming supportedβ Claude (
/v1/messages) - Streaming supportedβ Gemini (
/v1/models/{model}:generateContent) - Streaming supported
Features:
β Real-time streaming with chunk-by-chunk detokenization
β Optional claim verification (hallucination detection)
β Local model support (vLLM, Ollama, FastAPI)
β Automatic redaction + detokenization
β Full audit trail in SIEM
Setup:
# In .env file
PROXY_MODE_ENABLED=true
CLAIM_VERIFICATION_ENABLED=false # Optional
DETOKENIZE_TRUSTED_CALLERS=openai-proxy,claude-proxy,gemini-proxyFull Guides:
TRANSPARENT_PROXY.md- Proxy mode documentationCLAIM_VERIFICATION.md- Hallucination detection guide
π‘οΈ Claim Verification (Hallucination Detection)
Optional post-processing layer to verify factual accuracy of LLM responses:
Using a research-based approach, this feature analyzes LLM responses through a 4-stage pipeline to detect and flag potential hallucinations and false claims.
# Enable in .env
CLAIM_VERIFICATION_ENABLED=true
CLAIM_VERIFICATION_MODEL=gpt-4o-mini # Or local model
# Use any LLM normally via transparent proxy
response = openai.ChatCompletion.create(
model="gpt-4",
messages=[{"role": "user", "content": "What was Argentina's inflation in 2023?"}]
)
# If LLM hallucinates a wrong number, you'll see:
print(response.choices[0].message.content)
# "Argentina's inflation reached 300% in 2023."
# β οΈ **[CLAIM FLAGGED - HIGH CONFIDENCE]**: This claim is likely false.
# Evidence suggests Argentina's inflation was approximately 211% in 2023.4-Stage Verification Pipeline:
Sentence Splitting - Break response into sentences with context
Selection - Filter to verifiable factual claims
Disambiguation - Resolve or flag ambiguous statements
Decomposition - Extract atomic, standalone claims
Verification - Fact-check each claim with confidence scores
Output Modes:
Inline Warnings: π¨ High, β οΈ Medium, βΉοΈ Low confidence flags added to text
Metadata: Full verification details in
mcp_verificationresponse fieldNo Blocking: Users always see full response + warnings (inform, don't censor)
Local Model Support:
# Use vLLM, Ollama, or FastAPI locally (no API fees, full privacy)
CLAIM_VERIFICATION_BASE_URL=http://localhost:8000/v1
CLAIM_VERIFICATION_MODEL=meta-llama/Meta-Llama-3.1-8B-Instruct
CLAIM_VERIFICATION_REQUIRE_AUTH=false # No authentication neededUse Cases:
β Technical/Engineering - Verify calculations, formulas, specifications
β Scientific - Fact-check research claims, data, constants
β Financial - Validate statistics, market data, economic claims
β Medical - Verify dosages, symptoms, treatments (strict mode)
Performance:
Latency: ~500-1000ms per response (cloud) or ~300ms (local)
Cost: ~$0.0003/response with gpt-4o-mini, $0 with local models
Caching: ~80% hit rate reduces both latency and cost
Full Guide: See CLAIM_VERIFICATION.md for complete setup, configuration, and examples.
π API Endpoints (REST)
Core MCP Endpoints:
GET /healthβ server health checkPOST /classifyβ classify payload sensitivityPOST /redactβ sanitize payload, return token_map_handlePOST /detokenizeβ reinject allowed tokens (trusted clients only)POST /routeβ produce an execution plan (internal/external, redaction steps)POST /audit/queryβ simple audit search
Transparent Proxy Endpoints (when PROXY_MODE_ENABLED=true):
POST /v1/chat/completionsβ OpenAI-compatible proxyPOST /v1/messagesβ Claude-compatible proxyPOST /v1/models/{model}:generateContentβ Gemini-compatible proxy
Full API documentation: See mcp_redaction/models.py for request/response schemas.
Policy
Edit mcp_redaction/sample_policies/default.yaml. Hot-reload on change is supported (watcher optional).
Stdio / JSON-RPC (MCP) Adapter
See mcp_redaction/stdio_adapter.py for a minimal adapter skeleton you can mount under an agent runtime.
Testing
pytest -qProduction Hardening
Run behind mTLS and identity-aware proxy
Use Redis (or KV with envelope encryption) for token maps
Ship audit logs to SIEM (Splunk/ELK); rotate JSONL files
Add OPA/Gatekeeper check on detokenize categories
Extend detectors (NER, export-control classifier), add OCR for attachments
Enforce geo-routing and model-allow lists in
policy.yaml
This server cannot be deployed
Maintenance
Related MCP Connectors
The WAF for agents. Pattern-based + heuristic firewall scans prompts, RAG documents, tool argume...
Deterministic runtime safety for AI agents: scan PII, gate tool actions, verify LLM output.
Deterministic trust gate for AI output: leaked-secret, prompt-injection & PII in one call.
Pre-spend firewall for AI agents. Approves, blocks, flags transactions against policy rules.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides real-time content security for large language models by identifying and intercepting risks across compliance, ethics, and safety dimensions. It enables secure input and output monitoring through a customizable policy engine using an SSE-based interface.1MIT
- AlicenseAqualityBmaintenanceProtects AI agents from threats like prompt injection, jailbreaks, and SQL injection through a multi-layer scanning pipeline. It also enables PII redaction and rehydration to ensure data privacy during LLM interactions.1262 npm2Apache 2.0
- FlicenseNot gradedqualityDmaintenanceSecurity middleware for LLM apps and AI agent pipelines. Detects prompt injection attacks (22 signatures, 7 languages) and anonymizes PII (17 entity types). Deterministic, sub-25ms, GDPR Art.30 compliant.-
- AlicenseNot gradedqualityBmaintenanceEnables content inspection, sanitization, containment, and quarantine for LLM security, preventing prompt injection and credential leaks.MIT