MCP Security Sanitizer

io.github.saurabhdrh由 GitHub 帳號 saurabhdrh 發布v1.0.0更新於 Oct 27, 2026

Redacts common secrets, email addresses, and phone numbers.

已驗證SSE可網頁執行開發者工具安全與監控

概覽

AI 產生的概覽

以正規表示式為基礎的脫敏工具,讓助理遮蔽文字中的 API 金鑰、權杖、電子郵件與電話號碼,並統計偵測到的風險數量。

可以做什麼
  • 遮蔽機密:將 OpenAI 風格金鑰、Bearer 權杖以及常見的 key/password/token 指派內容替換為脫敏佔位符。
  • 遮蔽個資:將電子郵件地址與常見北美電話號碼格式替換為佔位符。
  • 稽核文字:回傳辨識到的機密、電子郵件與電話號碼數量,不改動原文。
適用情境
適合在把貼上的文字送給模型或寫入筆記前,做一次快速、不消耗 token 的預檢或清洗。適用於示範與本機開發,而非合規等級的脫敏。
執行需求
清單登錄為遠端 SSE 端點,未宣告驗證或標頭。README 的自架方式需在本機執行伺服器,要求 Python 3.11+ 與 uv;其範例用戶端另需在 .env 中設定 Groq API 金鑰,並可選擇性設定模型。
安裝前請注意
正規表示式只能比對已實作的樣式,無法保證找出所有機密或個資;README 提醒不要在未加入額外控管並驗證偵測涵蓋範圍前傳送受監管或高度敏感的資料。README 也指出 SSE 傳輸屬於網路邊界,正式環境應設定驗證、TLS 與網路限制。範例用戶端會把脫敏後的文字送往第三方 Groq。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 MCP Security Sanitizer,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Web executable,透過 SSE。 遠端服務在工作區中設定後即可從網頁執行環境執行。

交給代理程式安裝

把這段提示詞貼上到 Claude Code、Codex、Cursor 等代理程式,或 SourceWeft 對話中。代理程式會讀取該伺服器的安裝指南,先向你展示發布者、端點和登入方式,經你同意後再把它新增到你的客戶端。金鑰不會寫進任何命令。

閱讀 https://sourceweft.com/mcp/io.github.saurabhdrh%2Fmcp-security-sanitizer/install.md,並按其中說明把這個 MCP 伺服器接入我的客戶端。修改任何設定之前,先告訴我它的發布者、端點和登入方式,等我確認。不要把 API 金鑰寫進命令或我會提交的檔案;問我金鑰應從哪裡取得。

檢視代理程式所依據的安裝指南

其他 MCP 客戶端

把它新增到你客戶端的 mcpServers 設定中。

{
  "mcpServers": {
    "security-sanitizer": {
      "type": "sse",
      "url": "https://mcp-security-sanitizer-server.onrender.com/sse"
    }
  }
}

README

MCP Security Sanitizer

A small MCP server and interactive LangChain/Groq chatbot. The server exposes local regex-based tools for redacting common secrets and personally identifiable information (PII), and the client sanitizes each message before sending it to the language model.

Important limitation: Regex matching only recognizes the patterns implemented here. It cannot guarantee detection of every secret or PII value. The client guarantees that both configured sanitizer tools are called before each non-empty user message is passed to Groq; the system prompt is defense-in-depth, not the enforcement mechanism. Do not send regulated or highly sensitive data without adding appropriate controls and validating detection coverage for your environment.

Architecture

text
User input   |   vPython client --MCP/SSE--> local regex scrubbers   |                         1. mask_api_keys_and_secrets   |                         2. mask_pii_data   vSanitized text --> LangChain agent --> Groq

Sanitization uses local Python regular expressions in the MCP server and consumes 0 LLM tokens. The client makes the sanitizer calls synchronously before invoking the agent, so raw input is not sent to Groq by this chat flow. An MCP transport is still a network boundary; this configuration binds the server to loopback (127.0.0.1) and is intended for local development.

The logging interceptor prints tool names and argument field names but withholds all argument and result contents, so it does not log unsanitized input or potentially sensitive sanitizer output.

Tools

ToolBehavior
mask_api_keys_and_secrets(text)Redacts OpenAI-style sk-... keys, Bearer tokens, and common named key/secret/password/token assignments as [REDACTED_SECRET].
mask_pii_data(text)Redacts email addresses as [REDACTED_EMAIL] and common North American phone formats as [REDACTED_PHONE].
audit_text_for_risks(text)Returns counts of recognized secrets, email addresses, and phone numbers.

Requirements

  • Python 3.11+
  • uv
  • A Groq API key

Setup

From the project directory, resolve dependencies, create the project-local .venv, and write or update uv.lock:

bash
uv sync

You do not need to activate .venv when using uv run; it selects the project environment automatically.

Create a .env file in the project directory (beside pyproject.toml):

dotenv
GROQ_API_KEY=your_groq_api_keyGROQ_MODEL=openai/gpt-oss-120b

Keep .env out of version control. The client loads this file at startup and checks that GROQ_API_KEY is set before connecting to Groq. A .env placed inside .venv is also recognized as a fallback, but the project directory is the recommended location because .venv is generated and can be deleted and recreated. GROQ_MODEL is optional; if omitted, the client uses openai/gpt-oss-120b. If Groq reports that a model is unavailable, set GROQ_MODEL to a model ID enabled for your account. The API key is used by ChatGroq; it is not sent to the MCP server.

Run

Start the MCP server in one terminal:

bash
uv run server.py

It listens on http://127.0.0.1:8000 using the SSE transport, with the MCP endpoint at /sse.

Server startup screenshot

The image below illustrates the expected server terminal after startup. It is a generated example rather than a direct screenshot from your machine; process IDs and log formatting can differ by FastMCP/Uvicorn version.

[Illustrative MCP server startup terminal]

In a second terminal, start the interactive chatbot:

bash
uv run client.py

Alternatively, activate the project environment in each terminal and run Python directly. For example, in Windows PowerShell:

bash
.\.venv\Scripts\Activate.ps1python server.py

In a second activated terminal:

bash
.\.venv\Scripts\Activate.ps1python client.py

Type exit or quit to end the chat.

Sample prompts to try

With both the server and client running, paste one of these prompts into the client. Every value below is synthetic test data; do not use real credentials or personal information for testing.

Email and phone

text
Write a friendly appointment reminder for [email protected] and ask them tocall (415) 555-0134 if they need to reschedule.

The text passed to the agent should replace those values with:

text
[email protected]  -> [REDACTED_EMAIL](415) 555-0134    -> [REDACTED_PHONE]

API key and named password

text
Explain why this demo credential should not be shared: sk-1234567890abcdef.The test password is password=hunter2.

Both credential values should be replaced with [REDACTED_SECRET] before the message is sent to Groq.

Bearer token and mixed data

text
Help me write a support note for [email protected]. The test phone is212-555-0199 and the example authorization header is Bearerabc123.def456.ghi789.

The email, phone number, and Bearer token should be masked by the applicable tool. The interactive client intentionally does not print sanitized text to the terminal; it logs which tools ran while withholding their arguments and results. The expected replacements above describe what is passed onward, not what is displayed in the console.

What you see in the terminals

Run the server and client in separate terminals. The server stays running while the client connects to it.

Terminal 1 — MCP server (timestamps and process IDs vary):

text
INFO Starting MCP server 'MCP Security Sanitizer' with transport 'sse'     on http://127.0.0.1:8000/sseINFO:     Started server process [process-id]INFO:     Waiting for application startup.INFO:     Application startup complete.

Terminal 2 — client (example sanitizer call; the fake values below are for testing only):

text
Secure assistant ready. Type 'exit' or 'quit' to stop.
You: Contact [email protected] at (415) 555-0134; test key sk-1234567890abcdef.
[MCP] Calling mask_api_keys_and_secrets (arguments: text)[MCP] mask_api_keys_and_secrets completed; result content withheld.
[MCP] Calling mask_pii_data (arguments: text)[MCP] mask_pii_data completed; result content withheld.
Assistant: [The assistant's reply appears here after the sanitized message is            sent to the configured Groq model.]

The interceptor intentionally withholds tool arguments and results from the terminal, so the unsanitized input is not printed by the MCP logs. The message passed to the agent has these substitutions:

text
Contact [REDACTED_EMAIL] at [REDACTED_PHONE]; test key [REDACTED_SECRET].

The assistant reply depends on the Groq model and is not a fixed output. The illustration below shows the server startup and the local sanitizer calls. It is an example terminal view, not a raw desktop screenshot; the sanitizer check does not make a Groq request. Startup timestamps and process IDs vary by run.

[Illustrative MCP server and sanitizer client terminal output]

Configuration and production considerations

  • The client requires both sanitizer tools. If either is unavailable or returns an unsupported result, the request fails instead of being sent unsanitized.
  • The server uses SSE as requested. For production deployments, configure authentication, TLS, network restrictions, monitoring, and lifecycle management appropriate to your environment.
  • Update the regexes and add tests against your organization's actual secret and PII formats before relying on the service for compliance.
  • uv run manages and uses the project environment without requiring manual activation. To run python server.py or python client.py directly, first activate .venv in that terminal.

來源:README.md,提交 1710258

工具

3

mask_api_keys_and_secrets

Redact OpenAI-style API keys, bearer tokens, and common named secrets.

輸入參數text必填

mask_pii_data

Redact email addresses and common North American phone numbers.

輸入參數text必填

audit_text_for_risks

Count recognizable secrets, email addresses, and phone numbers.

輸入參數text必填

版本歷史

1
  1. v1.0.0最新Oct 23, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通必需25 分
  • 已宣告認證方式必需10 分
  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分

    請在儲存庫或註冊中心條目中宣告授權條款。