securedact-mcp
SecuRedact MCP
SecuRedact は、AIエージェントおよびAIワークフローのためのローカルファーストのプライバシー・セキュリティレイヤーです。個人データ / PII、GDPR関連の機密情報、認証情報、APIキー、トークン、シークレット、機密ファイルなど、モデル、ツール、ファイル、外部送信先にデータが到達する前に、機密データを検出して保護します。
SecuRedact MCP は、Apache-2.0 のオープンソースMCPサーバーであり、再利用可能なPythonプライバシーエンジンです。機密テキストを検出し、バージョン管理されたポリシーを適用し、ローカルで編集(redact)し、残存出力を検証してから、サニタイズ済みコンテンツを承認済みとしてマークします。
MCPモードはすべてのプロンプトを自動的にインターセプトするわけではありません。ホストはツールを呼び出し、
status == "ok"の場合にのみsanitized_textを送信する必要があります。設定が誤っている、または悪意のあるMCPホストは、通常のMCPワークフローをバイパスできます。プロバイダー固有の強制フックは別の統合アセットです。サポートされているプロバイダーがプロンプトライフサイクル境界でそのようなフックを呼び出す場合、通常のモデル処理の前に同じ決定論的判定を適用できます。SecuRedact Enforced を参照してください。
SecuRedact の利点
AIエージェントはますますファイルを読み取り、ツールを呼び出し、外部モデルにプロンプトを送信しています。そのため、データを事前にチェックする仕組みがなければ、PII、認証情報、機密文書が露出するリスクがあります。SecuRedact はAIワークフローのためのプライバシー・セキュリティ制御です。
ローカルファースト — すべての検出、編集、ポリシー評価はお使いのマシン上で実行されます。デフォルトではネットワークリスナーなし、テレメトリなし、プロバイダー呼び出しなし。
PII / GDPR 検出 — 氏名、メールアドレス、IBAN、識別子、特別カテゴリのデータを検出し、仮名化または編集します。
シークレット・認証情報の保護 — APIキー、トークン、パスワードを検出し、環境外への送信をブロックします。
ファイルシステム保護 — 読み取りはトラバーサル/シンボリックリンクエスケープから防御され、
.envなどの保護されたパスへのアクセスをブロックします。AIエージェントプライバシーファイアウォール — Claude Code および Gemini CLI 用の強制フックが、プロンプト、モデル呼び出し、ツールアクションの前に同じローカル判定を実行します。
ネットワーク / エグレス認識 — 外部ツール呼び出しを分類(内部/外部/不明)し、ポリシーで承認を要求したり、エグレスをブロックしたりできます。
SecuRedact は機密データの露出を減らすのに役立ちますが、コンプライアンスを保証するものではなく、すべての漏洩を防ぐことを主張するものではありません。制限事項 を参照してください。
Related MCP server: phi-redact-mcp
クイックスタート
PyPI からインストールし、ガイド付きセットアップを実行します(Windows):
py -3.12 -m pip install "securedact-mcp[ml]"
securedact-mcp setupLinux / macOS:
python3.12 -m pip install "securedact-mcp[ml]"
securedact-mcp setup数秒でテキストを保護します(決定論のみのデモ、モデル不要):
import os
os.environ["SECUREDACT_REQUIRE_FLAIR"] = "0" # deterministic detectors only
from securedact_core import RedactionRequest, SecuredactEngine
engine = SecuredactEngine.from_environment()
result = engine.prepare(
RedactionRequest(
text="Contact alex@example.test, IBAN NL91ABNA0417164300",
policy="strict_external_ai",
)
)
print(result.status) # "ok"
print(result.sanitized_text) # "Contact [EMAIL_1], IBAN [IBAN_1]"再現可能な合成セキュリティデモ:docs/distribution/security-demo.md。
安全なデフォルトワークフロー
通常の外部AI準備には prepare_for_external_ai を使用します:
{
"text": "Contact alex@example.test",
"policy": "strict_external_ai",
"language": "auto",
"response_mode": "minimal"
}承認済みレスポンス:
{
"schema_version": "1",
"status": "ok",
"sanitized_text": "Contact [EMAIL_1]",
"counts": {"email": 1},
"policy": "strict_external_ai",
"policy_version": 1,
"policy_digest": "...",
"reason_codes": []
}review_required および blocked レスポンスには、承認済みの sanitized_text は含まれません。最小限のレスポンスには、restore_capable が明示的に選択されていない限り、元のテキスト、生のエンティティ値、マッピング、例外本文、スタックトレース、モデルパス、復元ハンドルは含まれません。
アーキテクチャと信頼境界
flowchart LR
H["MCP host"] --> M["Securedact MCP"]
M --> D["deterministic detectors"]
M --> C["contextual detectors"]
D --> P["policy engine"]
C --> P
P --> R["redactor"]
R --> V["residual validator"]
V --> O["approved sanitized output"]
O --> W["host-controlled downstream workflow"]
H -. "host may bypass MCP" .-> Wサーバーには、プロバイダークライアント、OpenAI互換プロキシ、リバースプロキシ、ウェブサイト、デスクトップチャットボット、プロバイダー認証情報、プロバイダー固有の転送機能はありません。ADR 0001 と脅威モデルを参照してください。
ツール
ツール | 想定される用途 | 機密レスポンスの動作 |
| 推奨される完全な安全ワークフロー | デフォルトで最小限 |
| 低レベルのローカル分析/レビュー | 最小限。 |
| 低レベルの互換性操作 | デフォルトで最小限。明示的な |
| ローカルの不透明セッションを消費する | デフォルトで単回使用。直接マッピングには明示的な信頼済みレガシーモードが必要 |
| 承認済みの | マッピングや絶対パスを返さない |
| ローカルファイルを安全に読み取り、サニタイズ済みテキストのみを返す | 読み取り前に保護パスをブロック。トラバーサル/シンボリックリンク/バイナリを拒否。デフォルトで |
レスポンスモードは minimal、review、debug、restore_capable です。デバッグは、プロセスが SECUREDACT_ENABLE_DEBUG_RESPONSES=1 で起動された場合を除き無効です。MCPリクエストで有効にすることはできません。インメモリ復元セッションは、暗号学的ランダムハンドル、容量制限、有効期限、並行性保護、単回使用消費を使用します。プロセス終了時にすべてのセッションが破棄されます。
MCPツール、レスポンスプライバシー、復元セッションを参照してください。
インストール
Python >=3.12,<3.13 がサポートされています。
PyPI からの通常インストール:
py -3.12 -m pip install "securedact-mcp[ml]"
securedact-mcp setupLinux または macOS では、python3.12 -m pip install "securedact-mcp[ml]" を使用します。python がサポートされている 3.12 環境をすでに選択している場合は、python -m pip install "securedact-mcp[ml]" も適切です。
setup は、パッケージ、Python、ML依存関係をチェックし、ローカルモデルの状態を検査し、既存の同意ベースのモデルインストーラーを提供し、既存のオフラインベリファイアを実行し、それらのホストが検出された場合にパッケージ化された Claude Code および Gemini CLI 統合を提供します。プロバイダーの公式プラグイン/拡張コマンドを使用し、再実行しても安全です。プロバイダーモデルAPIを呼び出したり、プロバイダーの信頼を自動的に受け入れたり、ユーザーが明示的にモデルセットアップを選択して既存のアップストリームプロンプトを受け入れない限り、コンテキストモデルをダウンロードしたりしません。
手動モデルコマンドは、高度な操作や無人操作のために引き続き利用できます:
securedact-mcp install
securedact-mcp models verify
securedact-mcp最後のコマンドはローカル stdio サーバーを起動します。標準出力はMCPプロトコルメッセージ用に予約されています。securedact-mcp setup --non-interactive は、アップストリームの受け入れを意味することなく状態を報告し、新しいプロバイダーを設定しません。対象を絞った対話型プロバイダーセットアップには --host claude、--host gemini、または --host all を使用します。
開発者/ソースインストール
レビュー済みのソースチェックアウトから作業する場合:
git clone https://github.com/GigantesHJI/securedact-mcp.git
cd securedact-mcp
python -m pip install ".[ml]"
securedact-mcp setupモデルチェックポイントはリポジトリやホイールに含まれておらず、起動時にダウンロードされることもありません。Securedact はこれらのモデル重みを再配布しません。アップストリームのモデル重みは独自のライセンスを保持し、Apache-2.0 によって再ライセンスされることはありません。モデルインストール とサードパーティライセンスを参照してください。
決定論のみのローカル開発は明示的に選択する必要があります:
$env:SECUREDACT_REQUIRE_FLAIR = "0"
securedact-mcp本番環境ではデフォルトでコンテキスト機能が必要であり、設定されたモデルが欠落、ロード中、破損、または利用不能な場合はフェイルクローズします。
ホストパッケージ
テスト済みの設定アセットと安全なワークフロー手順は、Codex、Cursor、Windsurf 用に integrations/ の下にあります。自動化されたMCPクライアントハーネスは、サーバー起動、ツール一覧、呼び出し、最小レスポンス形状、stdout整合性、シャットダウンを検証します。実際のホストがすべてのプロンプトに対してツールを呼び出すことを証明するものではありません。互換性エビデンスを参照してください。
リポジトリは Gemini CLI 拡張ルートでもあります:gemini extensions install https://github.com/GigantesHJI/securedact-mcp でフックをインストールできます。gemini-cli-extension トピックと、タグツリーにルートマニフェストを含むリリースが、そのパスが解決するために必要です。pip install "securedact-mcp[ml]" とローカルモデルがなければ、インストールされたフックは何も強制しません。SecuRedact Enforced を参照してください。
ポリシーとPython API
組み込みには default、strict_external_ai、gdpr、identifiers_only、review_all_contextual が含まれます。互換性ポリシーも引き続き利用できます。ローカル組織ポリシーファイルは、管理されたポリシーディレクトリからのみロードされ、厳密な宣言型スキーマを使用し、フェイルクローズの不変条件を無効にできません。不明、重複、過大、不正な形式、またはシンボリックリンクされたポリシーはフェイルクローズします。
from securedact_core import RedactionRequest, SecuredactEngine
engine = SecuredactEngine.from_environment()
result = engine.prepare(
RedactionRequest(
text="Contact alex@example.test",
policy="strict_external_ai",
)
)from_environment() はコンテキストモデルの要件を保持します。スタンドアロンの決定論的開発には SECUREDACT_REQUIRE_FLAIR=0 が必要です。アプリケーションはテスト済みの検出器実装を注入することもできます。公開API とポリシーを参照してください。
再現可能な開発
コミットされた uv.lock は、Python 3.12 のランタイム、ML、開発、ベンチマーク、セキュリティのエクストラを解決します。
uv sync --frozen --extra dev --extra benchmark
uv run python scripts\verify.pyテスト、問題、スクリーンショット、フィクスチャ、プルリクエストで実際の個人情報、プライベート文書、認証情報、顧客ログ、モデル重みを使用しないでください。CONTRIBUTING.md を参照してください。
評価とパフォーマンス
uv run python -m securedact_eval quality --mode deterministic --gate `
--thresholds benchmarks\thresholds.json `
--baseline benchmarks\baselines\quality-deterministic.json
uv run python -m securedact_eval performance --mode deterministicバージョン管理された合成コーパスは、正確および緩和されたスパンの適合率、再現率、F1、偽陽性率、偽陰性率、エンティティ/言語/ドメイン/分割ごとの結果、アクション/カテゴリの精度、ブートストラップ再現率区間を報告します。真陰性はドキュメントレベルのネガティブ例であり、トークンレベルの安全性ではありません。GDPR関連スイートは検出評価であり、法的コンプライアンス認証ではありません。実際の Flair および GPU ベンチマークには、明示的に設定されたローカルモデルが必要であり、通常のCIではありません。ベンチマークを参照してください。 ベンチマークフレームワークは、ローカルデータ層と大規模プロファイルを文書化しています。移行計画は、将来の抽出境界を定義します。GitHubがリポジトリステップを実行する前に失敗した場合は、CIトラブルシューティングの決定木を使用してください。ローカルの成功は、必要なGitHubチェックの代わりにはなりません。
セキュリティと制限事項
プロンプト、検出結果、マッピング、復元ハンドル、シークレット、モデル入力、復元された出力は、アプリケーションコードによってログに記録されません。
決定論的およびコンテキスト検出は、新規、曖昧、または敵対的な開示を見逃す可能性があります。共参照や普遍的な難読化耐性は主張されません。
レビューオフセットにより、元の入力を持つ信頼できるローカルクライアントが値を再構築できます。レビューレスポンスはローカルに保持してください。
ホストの動作とダウンストリームプロバイダーの動作は信頼境界の外にあります。
ファイルに文書化されたリポジトリのセキュリティ設定は、管理者による検証が依然として必要です。
脆弱性は SECURITY.md を使用して非公開で報告してください。脆弱性の詳細や実際のデータを公開の issue に記載しないでください。
ライセンス
元のリポジトリのソースとドキュメントは Apache License 2.0 の下でライセンスされています。著作権表示は NOTICE に記録されています。サードパーティの依存関係とモデル重みは独自のライセンスを保持します。
Available Tools
6 toolsanalyze_textARead-onlyIdempotent
Inspect text locally and report detected sensitive content without producing sanitized output.
Use this when you need to understand what PII, secrets, or credentials are present (counts, entity types, and, with review/debug modes, positions) but do not need redacted text for transmission. The original text is not modified and no sanitized representation is returned. For a policy-approved, ready-to-send result use prepare_for_external_ai; for a sanitized file use create_safe_copy; for reversing a prior local session use restore_text.
Returns a JSON object with 'status' ('ok', 'review_required', or 'blocked'), 'policy', 'policy_version', 'policy_digest', 'counts' (entity-type tallies), and, when response_mode is 'review' or 'debug', a 'findings' list. 'debug' additionally returns 'debug_details'.
Inputs: text (required), policy, response_mode. Returns: object
create_safe_copyA
Sanitize text locally and write the approved result to a new file in the Safe Copies directory.
Use this when you need a sanitized on-disk copy (for storage, handoff, or archival) rather than an in-memory sanitized string. For the sanitized text only, use prepare_for_external_ai; for inspection-only use analyze_text; for reversing a prior session use restore_text.
Side effects: a new file is written to the directory set by SECUREDACT_SAFE_COPY_DIR. The supplied 'content' is not modified and no existing file is overwritten. The filename must be a bare '.txt' or '.md' basename (no path separators or directory traversal). The operation blocks and reports 'blocked' if the directory is unconfigured, the filename is invalid, or policy blocks the content.
Returns a JSON object with 'status' ('ok' or 'blocked'), 'filename', and 'counts'.
Inputs: content (required), filename (required), policy. Returns: object
prepare_for_external_aiARead-onlyIdempotent
Use this before sending user-supplied or potentially sensitive text to an external AI service.
SecuRedact inspects and sanitizes the text locally and returns the policy-approved representation; this tool does not transmit the text externally. It is the recommended default for outbound AI workflows. Use analyze_text for inspection-only classifications, redact_text for the lower-level compatibility path, create_safe_copy when a sanitized file is required, and restore_text only to reverse a prior local session in a trusted context.
Returns a JSON object with 'status' ('ok', 'review_required', or 'blocked'), 'sanitized_text' (present only when approved), 'counts', 'policy', and optionally 'restoration_session' (when response_mode is 'restore_capable').
Inputs: text (required), policy, language, response_mode. Returns: object
redact_textARead-onlyIdempotent
Direct/lower-level redaction entry point; prefer prepare_for_external_ai for normal outbound workflows.
In its normal modes this performs the same local sanitization as prepare_for_external_ai and returns the approved result, so most agents should call prepare_for_external_ai instead. Use redact_text when you specifically need this lower-level compatibility path, or the 'legacy' mode for local review of raw redaction internals. The 'legacy' mode returns potentially sensitive local-review details and is never selected by default.
Returns, for normal modes, the same approved result as prepare_for_external_ai (status, sanitized_text, counts). For 'legacy' mode it returns a result with deprecation_code 'legacy_sensitive_response' containing local-review redaction data.
Inputs: text (required), policy, response_mode. Returns: object
restore_textA
Reverse a prior SecuRedact protection step in a trusted, local-only context.
Use this ONLY after you previously received a restoration_session from SecuRedact (for example from prepare_for_external_ai with response_mode 'restore_capable') and now need to reconstruct the original text locally for trusted review. Restoration can reveal the original sensitive values (PII, secrets, credentials); it is a trusted-local operation, not a step to prepare data for external transmission. Never call it to sanitize or prepare text for an external AI; for that use prepare_for_external_ai. Never call it on text you did not previously protect with SecuRedact.
Security boundary: all processing is local and nothing leaves the machine. The 'mapping' form requires trusted_local_review=true and exposes raw originals, so its output must never be transmitted. Returns a JSON object with 'status' ('ok' or 'blocked'), 'restored_text' (present only on success), and 'reason_codes' describing any failure.
Inputs: text (required), mapping, restoration_session, trusted_local_review. Returns: object
securedact_read_fileARead-onlyIdempotent
Safely read a local file and return only its sanitized (PII/secrets removed) text.
Use this when you must ingest a local file's contents for use with an external AI but want path-traversal, size, and binary defenses plus sanitization applied first. If the content is already in memory, use prepare_for_external_ai; for a sanitized file on disk, use create_safe_copy.
Side effects: reads a file from local disk and never transmits it. Sensitive paths and escapes are blocked before any file content is read. The returned 'sanitized_text' is safe to forward.
Returns a JSON object with 'status' ('ok' or 'blocked'), 'path', and 'sanitized_text' (present only when approved).
Inputs: path (required), policy, max_bytes. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Most tools have clearly distinct outputs (in-memory text, file write, file read, inspection, restoration), but prepare_for_external_ai and redact_text perform identical sanitization in normal modes, with redact_text explicitly deferring to prepare_for_external_ai. This creates a potential misselection point despite the helpful cross-references.
The majority of tools follow a clean verb_noun pattern (analyze_text, redact_text, restore_text, create_safe_copy). prepare_for_external_ai and securedact_read_file deviate with a prepositional phrase and a brand prefix, but the overall naming remains readable and predictable.
Six tools is well within the ideal scope for a focused sanitization server. Each tool maps to a distinct workflow step, and none feel extraneous enough to bloat the surface.
The set covers the core lifecycle: inspection, in-memory sanitization, safe file output, safe file input, and session restoration. Minor gaps exist around policy management and the redundant redact_text path, but there are no critical dead ends for the stated purpose.
Maintenance
Related MCP Connectors
MCP gateway: one connection for your AI apps, with tool policies, PII redaction and audit logs.
MCP server for detecting and redacting PII (Personally Identifiable Information) in PDF documents.
Zero-secret MCP gateway for AI agents: risk-scored, audited calls with human-in-the-loop approval.
Scan prompts for injection attacks, redact PII, and audit LLM SDK usage from any MCP client
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA local, containerized MCP server that uses a local LLM to sanitize documents by removing or transforming PII before content is sent to public LLM services.MIT
- AlicenseAqualityCmaintenanceAn MCP server that redacts PII/PHI from text before it ever reaches an LLM — self-hosted, fail-closed, and HIPAA-aware.3MIT
- AlicenseAqualityDmaintenanceMCP server providing on-prem PII detection and anonymization tools (scan and is_sensitive) for AI agents, ensuring data stays local.4MIT

omitly-mcpofficial
FlicenseAqualityBmaintenanceMCP server for local, verifiable PDF redaction. Enables AI agents to find sensitive regions, locate text, redact PDFs on-device, verify redaction and tamper-evidence seals, and generate PDFs—without uploading confidential documents.8629 npm-