Skip to main content
Glama
RedactAI MCP Server

RedactAI MCP Server

by Jyoti429

RedactAI MCP Server

A standalone, production-ready Model Context Protocol (MCP) server built in TypeScript for sensitive data detection, sanitization, and PII redaction before downstream AI agent processing.

Supports both Local STDIO MCP and Remote Streamable HTTP MCP (compatible with Render, cloud hosts, and remote agent workflows).


1. What the Project Does

RedactAI MCP Server exposes a high-performance MCP tool named sanitize_text. It inspects text for sensitive personal identifiable information (PII) including Names, Email Addresses, Phone Numbers, ID Numbers (Employee IDs, Tax IDs, National IDs), and Locations, redacting them using configurable strategies:

  • MASK (default): Replaces sensitive entities with semantic tokens (e.g. [NAME], [EMAIL], [PHONE], [ID_NUMBER], [LOCATION]).

  • HASH: Computes deterministic SHA-256 hash placeholders (e.g. [HASH:a1b2c3d4]) to preserve referential consistency across documents without exposing raw plaintext.

  • REMOVE: Strips the sensitive entity completely ("").


Related MCP server: PII Redaction MCP Server

2. Why MCP (Model Context Protocol)?

AI agents and LLMs frequently ingest raw user prompts, support transcripts, logs, and sensitive internal records. Sending unredacted PII to external model APIs introduces critical privacy, security, and regulatory compliance risks (GDPR, HIPAA, DPDP).

By exposing the RedactAI engine as a native MCP tool, any MCP-compatible agent workflow, IDE, or client (Claude Desktop, Antigravity, Cursor, LangChain, LlamaIndex, or custom agent runtimes) can automatically call sanitize_text directly within the agent loop to scrub sensitive context before executing external prompts.


3. Architecture & Transports

Both local and remote transports share the exact same redaction and detection pipeline:

                    MCP CLIENT / AI AGENT
                   /                     \
                  /                       \
             STDIO                         HTTPS
          (Local CLI)                 (Remote Server)
               |                              |
               v                              v
          src/index.ts                   src/http.ts
               \                              /
                \                            /
                 v                          v
                  Tool: sanitize_text (/mcp)
                               |
                               v
                        Redaction Service
                               |
                               v
                       DetectionProvider
                               |
                               v
                    Teammate's Core Engine
                       (future adapter)
  • Local STDIO Transport (src/index.ts): Communicates over stdin/stdout.

  • Remote Streamable HTTP Transport (src/http.ts): Exposes standard MCP over HTTP at /mcp with full SSE/streaming and CORS support.

  • TemporaryDetectionProvider: High-accuracy deterministic regex and context-based provider for standalone demonstration.

  • Teammate Core Adapter: Drop-in replacement via the DetectionProvider interface.


4. Installation & Build

Ensure Node.js (v20+ or v22+) is installed:

# Clone or navigate into project directory
cd redactai-mcp

# Install dependencies
npm install

# Typecheck TypeScript
npm run typecheck

# Build both STDIO and HTTP entry points to dist/
npm run build

# Run all 21 unit, STDIO, and HTTP tests
npm run test

5. Running the MCP Server

A. Local STDIO MCP Server

Used for local CLI tools, Claude Desktop, Cursor, or local Antigravity setups.

# Production start
npm run start
# Or directly: node dist/index.js

# Development mode
npm run dev

B. Remote Streamable HTTP MCP Server

Used for remote web clients, cloud-hosted agents, or teammate web applications connecting over HTTPS.

# Production start (listens on PORT or 10000, binds to 0.0.0.0)
npm run start:http
# Or directly: node dist/http.js

# Development mode
npm run dev:http

Default endpoints when running locally:

  • MCP Endpoint: http://localhost:10000/mcp

  • Health Check: http://localhost:10000/health

  • Info: http://localhost:10000/


6. Testing with MCP Inspector

The official MCP Inspector provides an interactive web UI to test tools and schema definitions.

Testing Local STDIO Server:

npx @modelcontextprotocol/inspector node dist/index.js

Testing Remote Streamable HTTP Server:

  1. Start the HTTP server in one terminal:

    npm run start:http
  2. Launch MCP Inspector in another terminal connecting via HTTP transport:

    npx @modelcontextprotocol/inspector http://localhost:10000/mcp

7. Render Deployment Guide

A pre-configured render.yaml blueprint is included in the project.

Automatic Blueprint Deployment

  1. Push this repository to GitHub/GitLab.

  2. In the Render Dashboard, click New > Blueprint.

  3. Connect your repository. Render will automatically read render.yaml:

    • Environment: Node

    • Build Command: npm install && npm run build

    • Start Command: npm run start:http

    • Health Check Path: /health

    • Port: Auto-assigned by Render (process.env.PORT)

  4. Once deployed, your public MCP URL will be:

    https://YOUR-SERVICE-NAME.onrender.com/mcp

Health Check Verification

curl https://YOUR-SERVICE-NAME.onrender.com/health
# Returns: {"status":"ok"}

8. Example sanitize_text Invocation

Tool Name

sanitize_text

Description

Detect and redact sensitive personal information from text before downstream processing.

Input Schema

{
  "text": "Contact John Mehta at john.mehta@example.com or 9876543210.",
  "rules": {
    "NAME": "MASK",
    "EMAIL": "MASK",
    "PHONE": "MASK",
    "ID_NUMBER": "MASK",
    "LOCATION": "MASK"
  }
}

(Note: The rules object is optional. If omitted, all entity types default to MASK.)

Custom Rules Example (e.g. Hashing email & Removing phone)

{
  "text": "Contact John Mehta at john.mehta@example.com or 9876543210.",
  "rules": {
    "NAME": "MASK",
    "EMAIL": "HASH",
    "PHONE": "REMOVE"
  }
}

Example Structured Response

{
  "redactedText": "Contact [NAME] at [EMAIL] or [PHONE].",
  "detections": [
    {
      "type": "NAME",
      "value": "John Mehta",
      "start": 8,
      "end": 18,
      "confidence": 98,
      "redaction": "[NAME]"
    },
    {
      "type": "EMAIL",
      "value": "john.mehta@example.com",
      "start": 22,
      "end": 44,
      "confidence": 99,
      "redaction": "[EMAIL]"
    },
    {
      "type": "PHONE",
      "value": "9876543210",
      "start": 48,
      "end": 58,
      "confidence": 95,
      "redaction": "[PHONE]"
    }
  ],
  "summary": {
    "totalDetections": 3,
    "byType": {
      "NAME": 1,
      "EMAIL": 1,
      "PHONE": 1,
      "ID_NUMBER": 0,
      "LOCATION": 0
    }
  }
}

9. Connecting Teammate's Core Engine

When your teammate completes the core redaction engine or an ML/NER model, integrate it in 3 simple steps:

Step 1: Implement DetectionProvider

Create an adapter class implementing the DetectionProvider interface:

// src/teammate-adapter.ts
import { Detection, DetectionProvider } from "./types.js";
import { realTeammateEngine } from "teammate-core-engine";

export class CoreEngineAdapter implements DetectionProvider {
  async detect(text: string): Promise<Detection[]> {
    const coreResults = await realTeammateEngine.scan(text);

    return coreResults.map((item) => ({
      type: item.category as any, // "NAME" | "EMAIL" | "PHONE" | "ID_NUMBER" | "LOCATION"
      value: item.rawText,
      start: item.startIndex,
      end: item.endIndex,
      confidence: item.score,
    }));
  }
}

Step 2: Inject the Adapter

In src/index.ts and src/http.ts:

import { CoreEngineAdapter } from "./teammate-adapter.js";
import { RedactionService } from "./redaction.js";
import { runStdioServer } from "./index.js";
import { createHttpServer } from "./http.js";

// Initialize with teammate's adapter
const customProvider = new CoreEngineAdapter();
const redactionService = new RedactionService(customProvider);

// For STDIO:
// runStdioServer(redactionService);

// For HTTP:
// createHttpServer(undefined, undefined, redactionService);

Step 3: Run Tests

npm run test

10. Security & Privacy Guarantees

  • Zero Persistence: No input text or processed output is logged or written to storage.

  • Protocol Separation: All operational logs are directed strictly to stderr.

  • Deterministic Privacy: HASH mode computes one-way SHA-256 tokens preserving referential linkability without exposing raw cleartext.

  • Hackathon Note: The public HTTP endpoint is designed for hackathon demonstration and agent workflow integration.

Available Tools

1 tool
sanitize_textB

Detect and redact sensitive personal information from text before downstream processing.

Inputs: text (required), rules.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.7/5.0

    Scored across 1 tool

    Disambiguation5/5

    With only one tool, there is no possibility of an agent confusing it with another operation. sanitize_text has a clear, singular purpose that is easy to identify.

    Naming Consistency5/5

    The single tool name follows a clean verb_noun convention and is descriptive of its function. Since there are no other tool names, there are no inconsistencies to introduce confusion.

    Tool Count4/5

    One tool is on the low end of typical MCP server scopes, but for a focused RedactAI service it is reasonable and not trivial. The tool directly addresses the server's intended operation without unnecessary bloat.

    Completeness5/5

    The tool fully covers the stated purpose of detecting and redacting sensitive personal information before downstream processing. No additional lifecycle or auxiliary operations are needed for this narrow, stateless transformation task.

    Maintenance

    ActivityStale
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Redacts PII from LLM traces and tool payloads before they leave review, enabling PII scanning, payload redaction, sensitive field classification, privacy receipts, and trace audit exports.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Strips personal data and credentials from text before it reaches a model, log, or ticket, using checksum-verified detection for cards, IBANs, routing numbers, SSNs, contact details, and API keys. Placeholders such as <EMAIL_1> can later be swapped back in so the model's response is restored with the original values.
      MIT