
Pseudonym Mcp
io.github.woladi由 GitHub 账号 woladi 发布v0.9.0更新于 Oct 24, 2026
Locally pseudonymizes sensitive text before cloud LLM work and restores the tokens afterward.
概览
本地 MCP 服务器,在交给云端 LLM 之前把检测到的个人数据替换为不透明令牌,之后再把原文还原。
- 可以做什么
- 遮蔽文本:把检测到的个人数据替换为 [PERSON:1] 之类的令牌,并返回 session_id
- 还原文本:凭 session_id 把令牌换回原始值
- 识别标识符:十二种语言区域共 46 条识别规则,部分带校验位验证,可选本地 Ollama 识别姓名与机构
- 调整检测:选择 regex、llm 或 hybrid 引擎、语言包、灵敏度与自定义字面量
- 使用内置流程:提供遮蔽、任务、还原的提示模板,含仅限 macOS 的文件与 PDF 扫描
- 适用场景
- 当你需要把文档、笔记或客户文本发给云端 LLM,又不希望提示中出现检测到的姓名、证件号、IBAN、银行卡、邮箱和电话时使用。适合能在调用模型前显式执行遮蔽步骤、并在本地还原回复的隐私敏感流程。
- 运行要求
- 通过 npx 在本地运行(需要 Node.js)。姓名与机构识别可选依赖可配置地址的 Ollama 实例及已拉取的模型;仅用 regex 模式则不需要 Ollama。可通过命令行参数或工作目录下的 mcp-config.json 配置。PDF 与图片提示模板还需在 macOS 上另装 macos-vision-mcp 服务器。
安装
在 SourceWeft 中
- 打开 控制台中的 Pseudonym Mcp,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
pseudonym-mcp
[pseudonym-mcp — mask PII locally, send safely to a cloud LLM, restore instantly]
Local pseudonymisation tools for LLM workflows — replace detected PII with opaque tokens before you hand text to a cloud LLM, then restore those tokens afterward.
[npm version] [License: MIT] [Node 18+] [GDPR-aligned] [Local detection] [Offline NER]
Expose MCP tools (mask_text and unmask_text) that your client or agent can call as an explicit privacy step. The server detects PII locally, replaces it with opaque tokens, and keeps the token mapping in memory for later restoration.
It is a defense-in-depth measure, not a compliance silver bullet. Read the Limitations and GDPR & AI Compliance sections before assuming this stack does more than it does.
What you get
- 46 recognizers across twelve locales, all of them live by default: Poland (PESEL, NIP, REGON, dowód, paszport, księga wieczysta), the EU (IBAN with mod-97, VAT for all 27 member states, plus DE, IT, ES, FR, NL, CZ/SK, SE, FI and UK national IDs) and the US (SSN, ITIN, EIN, ABA routing, cards). 24 of them verify a real check digit.
--langnarrows that set when you want fewer false positives — see Locale coverage is fail-closed. Heuristic language detection (detectLanguage()) infers the language from text content —--langremains the authoritative override. - Hybrid NER engine: Regex for structured PII (SSN, credit cards, IBAN, email, phone) + local Ollama LLM for unstructured entities (names, organisations).
- Local-detection architecture: Detection and substitution happen on your machine when the MCP tool is called. The cloud LLM call still happens (that's the point) — but it can see tokens instead of detected PII when your workflow uses the masked output.
- Session-keyed mapping store: Tokens like
[PERSON:1]map back to originals in an isolated, per-request session. Multiple round-trips preserve token coherence. - Unmask workflow support:
mask_textreturnsauto_unmaskfor clients that want to honor that preference, but this server does not intercept arbitrary LLM responses automatically. - Flexible engines: Run
regexonly (no Ollama required),llmonly, orhybrid(default). - Strict validation: SSN area-number validation, credit card Luhn checksum, PESEL checksum — all configurable.
- Graceful degradation: If Ollama is unavailable, the regex phase still runs and no exception is thrown.
- MCP-native: Works with Claude Code, Claude Desktop, Cursor — any MCP-compatible client.
❌ Without / ✅ With
❌ Without pseudonym-mcp:
- Prompt:
"John Smith, SSN 123-45-6789, card 4111 1111 1111 1111"→ sent verbatim to the LLM provider - Every name, ID number, and credit card in your prompt is processed and potentially logged by the provider
- A breach at the provider's end exposes those values in cleartext
- Sending personal data to a non-EU LLM provider without further safeguards raises GDPR Article 44 questions you'll need to answer
✅ With pseudonym-mcp used before the cloud call:
- The same prompt can become
"[PERSON:1], SSN [SSN:1], card [CREDIT_CARD:1]"when you callmask_textfirst - The LLM reasons about structure and content without seeing those detected values in cleartext
- The response can be locally de-tokenised with
unmask_textbefore reaching the user - Detected direct identifiers are no longer shipped upstream — though structure, dates, indirect references, and any missed PII still are
This is a meaningful reduction in cleartext PII exposure. It is not "no personal data leaves your machine" — see Limitations.
GDPR & AI Compliance
pseudonym-mcp is relevant to compliance work, but it is a technical control, not a compliance product. Whether you are compliant with any specific regulation depends on your full stack, your role (controller/processor), your contracts, your DPIA, and your jurisdiction.
Why this matters
The EU General Data Protection Regulation (GDPR) classifies names, national ID numbers (like SSN or PESEL), bank account numbers (IBAN), email addresses, credit card numbers, and phone numbers as personal data under Article 4(1). Sending this data to a cloud LLM provider constitutes processing under Article 4(2). Pseudonymisation is explicitly recognised under Art. 4(5) as a risk-reduction measure — but, critically, pseudonymised data is still personal data (Recital 26).
The honest bottom line: pseudonymisation under GDPR Art. 4(5) is not anonymisation. The data remains personal data in your system, and Art. 44 transfer obligations are not switched off just because you tokenised the name field.
AI Act alignment
The EU AI Act places additional requirements on high-risk AI systems that process personal data. Using pseudonym-mcp as an intermediary layer can:
- Support data minimisation in your AI system's data flows.
- Help document a technical control for transparency and human-oversight requirements.
- Align with the principle of technical robustness and safety (Art. 15) by limiting cleartext PII exposure.
It does not change your AI Act risk classification on its own — classification is a function of use-case and deployment context, not of the masking step in front of the model.
US & international applicability
The tool is also relevant outside the EU, with the same caveats:
- CCPA / CPRA (California) — reduces personal information sent to third-party processors; doesn't change controller/business obligations or consumer rights.
- HIPAA (US healthcare) — pseudonymised PHI is still PHI under HIPAA. Using this tool does not eliminate the need for a BAA with your cloud LLM provider if you're a covered entity or business associate. It can be part of a defensible safeguard posture; it cannot substitute for one.
- PCI DSS (payment industry) — Luhn-validated detection reduces the chance card numbers ride in cleartext to an LLM. It is one control; PCI scope, segmentation, and storage rules are separate concerns.
- SOC 2 — useful evidence of a technical control limiting PII exposure. Auditors will look at the full picture, not just this layer.
- PIPEDA (Canada), LGPD (Brazil), POPIA (South Africa) — all require appropriate safeguards for cross-border personal data transfers. This tool is a relevant safeguard, not a substitute for the legal basis of the transfer.
Sector-specific applicability
In every row of this table, pseudonym-mcp is a useful building block. None of those regimes can be satisfied by a masking tool alone.
How it works
Token format
The mapping is stored in a session-scoped in-memory store. Each mask_text call returns a session_id; pass it back to unmask_text to restore originals.
Real-world example
Meeting note in Claude Code / Obsidian
You have a note:
In Claude Code you type:
First, call mask_text; pseudonym-mcp replaces detected PII locally:
Then ask Claude to work from the masked text. Claude responds with tokens:
pseudonym-mcp restores originals locally:
If the masked text is what you send upstream, the cloud provider sees the structure of the meeting and the amount — but not the detected name, PESEL, organisation, or email in cleartext. The swap happens on your machine.
Obsidian vault with session_id
The session_id keeps the token map alive for the session — the same [PERSON:1] always refers to the same person across notes. That consistency is what makes cross-note reasoning possible; it is also what makes a masked corpus potentially re-identifiable to anyone with side knowledge of your work. Use long-lived sessions deliberately.
MCP Prompt Templates
pseudonym-mcp ships two built-in prompt templates that describe a mask → task → unmask workflow.
Important: MCP prompt templates are convenience helpers, not a privacy boundary. Inline prompt arguments may be visible to the host client or model before tool masking happens. For strongest privacy, call mask_text directly first, then use the returned masked_text in your LLM prompt.
pseudonymize_task — inline text
Intended workflow:
- pseudonym-mcp masks detected PII locally →
[PERSON:1],[PESEL:1] - Claude processes the masked text
- pseudonym-mcp restores originals in the response
Optional lang argument: en or pl. It only annotates the generated prompt text; the packs the server actually runs come from its own --lang.
privacy_scan_file — file / PDF (macOS only)
Requires macos-vision-mcp — a separate MCP server that uses Apple's Vision framework to extract text from PDFs and images on-device. macOS only.
Intended workflow:
- macos-vision-mcp extracts text from the file on-device
- pseudonym-mcp masks detected PII locally
- Claude processes the masked content
- pseudonym-mcp restores originals before the response is shown
Optional arguments: task (default: summarise the key points), lang (en or pl — annotates the prompt text only).
Quick Start
Step 1 — Add to your MCP client (example for Claude Code — no install needed):
Step 2 — (Optional) Pull an Ollama model for full hybrid NER:
Skip this step if you only need regex-based masking (--engines regex). Without Ollama, you'll catch structured identifiers (SSN, IBAN, cards, email, phone, PESEL) but not free-form names and organisations.
Global install — if you prefer
npm install -g pseudonym-mcp, replacenpx -y pseudonym-mcpwithpseudonym-mcpin all snippets below.
Restart your client. The mask_text and unmask_text tools appear automatically.
Available Tools
mask_text input
mask_text output
active_locales lists the packs that ran. If the server was narrowed with
--lang, the response also carries disabled_locales and a locale_warning
naming the identifiers it cannot see:
unmask_text input
Configuration
mcp-config.json (project root)
Locale coverage is fail-closed
Every locale pack runs unless you name one. lang defaults to all, so a
fresh server recognises Polish, US, German, Italian, Spanish, French, Dutch,
Czech/Slovak, Swedish, Finnish and UK identifiers at once.
This is deliberate. A server narrowed to one pack is indistinguishable from a complete one at the call site: it returns clean-looking text and reports success while every identifier from every other country passes through untouched. A pack that fires on an order number costs an unnecessary token; a pack that stays dormant over a PESEL costs an incident.
Anything that does not name a real pack — a typo, an empty string, all —
turns every pack on. Narrowing only ever happens because you asked for it, and
when it does the server says so on stderr at startup and in every
mask_text response (disabled_locales, locale_warning).
What it costs. Running twelve packs at once means testing twelve national hypotheses against every number, so shapes that are unremarkable in one country get masked in another:
If your documents are single-jurisdiction and those tokens are noise, narrow
the server on purpose — --lang en, --lang pl --extra-locales de,it — and
accept that identifiers from the packs you dropped will not be detected.
Where the config file is read from
mcp-config.json is looked up in the server's working directory, which for
an MCP-spawned process is the client's working directory, not the installed
package. The copy shipped inside the npm package is an example; it is never
loaded. Pass --config /path/to/mcp-config.json when you need a specific file.
Settings layer highest-to-lowest: CLI flags → mcp-config.json → built-in
defaults. Only flags you actually type count as CLI input, so a config file
still decides everything you left off the command line.
CLI flags
All config keys can be overridden at startup (highest priority):
Claude Code
Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
Cursor
Add to ~/.cursor/mcp.json:
Supported PII types
[46 recognizers across Poland, Europe and the United States, 24 of them checksum-verified]
Detection is best-effort. The patterns below are what the tool looks for — not a guarantee of what it will always catch. See Limitations for known gaps.
Every table below is active on the default configuration. --lang switches packs off; see Locale coverage is fail-closed.
Custom literals
Custom literals are applied after the regex phase and before LLM NER, regardless of engine mode. Longest literals are matched first to prevent partial substitution.
How a match is decided
Every pattern carries a confidence score. A checksum that validates raises it, and a context word near the match — "PESEL:", "NIP", "Steuer-ID", "date of birth" — raises it too, enough on its own to reach the default threshold. What gets masked is whatever clears the sensitivity bar:
Where a failing checksum means "not this entity at all" (a card number failing Luhn), the candidate is dropped. Where it means a typo (a PESEL), the candidate survives at lower confidence — a mistyped identifier reaching the cloud is worse than a number masked for nothing.
Rules marked ✓ below verify a real check digit.
Global — active in every language
Polish (pl pack)
United States (en pack)
Other European locales
These run by default like every other pack. Narrow to a subset with --lang,
or pair a chosen language with its neighbours using --extra-locales de,it —
a Polish invoice carries German and Italian identifiers too.
Detected by the LLM, not by pattern
Language Detection
pseudonym-mcp includes a lightweight heuristic language detector based on franc.
It infers the language from text content and returns a structured result:
Texts shorter than 20 characters or with low confidence return detected: 'unknown'.
The detector does not affect the current pseudonymisation pipeline — --lang config remains authoritative.
It is a building block for future multi-language and auto-select modes.
Engine modes
In hybrid mode, Ollama runs after the regex pass, so the local NER model receives already-tokenised structured identifiers. If Ollama is unreachable, the server logs a warning to stderr and returns the regex-only masked text — no crash, no hang.
Privacy & Security notes
Calibrated claims:
- No telemetry from the tool itself. pseudonym-mcp makes no network requests except to your local Ollama instance and (optionally) the MCP stdio transport.
- In-memory mapping by default. The mapping store is not written to disk. Sessions are scoped to the server process lifetime.
- Idempotent tokens within a session. The same original value always maps to the same token (
[PERSON:1]will not become[PERSON:2]for the same name on a second occurrence), preserving semantic coherence in LLM reasoning. - No model training. The local Ollama model operates offline. Your data is not used to train any model by this tool.
- Strict validation by default. Invalid SSNs (area 000/666/900+), failed-Luhn credit card numbers, and invalid-checksum PESELs are not masked, preventing false positives from OCR errors or random digit sequences.
What this does not guarantee:
- That all PII in your input is detected.
- That tokenised text is unlinkable to real people — re-identification from context is possible.
- That the cloud provider can't learn sensitive things from structure, timing, or content.
- Compliance with any specific regulation — that's a system-level property, not a tool-level one.
Limitations
pseudonym-mcp is a technical privacy control, not a legal guarantee of compliance.
- Detection is best-effort. False negatives and false positives are both possible. Indirect references (e.g. "the tall guy from accounting", "my landlord", "the place near the bridge") are not detected. Nicknames, initials, and partial names are typically missed.
- Structure still travels. Amounts, relationships between tokens, narrative content, and any PII the detector missed all reach the cloud LLM. Dates are masked only when they read as a date of birth, or at higher
--sensitivity; the rest of the calendar goes through. Tokenisation hides who, not what kind of situation. - Narrowing
--langnarrows detection, silently at the source. With a locale pack switched off, its identifiers are not looked for at all — the output looks clean and the call still reports success. The server states which packs are off, on stderr and in everymask_textresponse; nothing downstream forces you to read it. - Pre-mask logging is your problem. If your application logs plaintext before passing it to
mask_text, this tool cannot help you. - Process-local mapping. Restarting the server ends the session and discards mappings. This is intentional.
- Re-identification is possible for anyone with access to the local mapping store, and may be possible from context alone for anyone with side knowledge. This is pseudonymisation under GDPR Art. 4(5), not anonymisation.
- No legal advice. Nothing in this README constitutes legal advice. Compliance is a system-level property — talk to your DPO, your compliance team, and your lawyers about your specific deployment.
Under GDPR Art. 4(5) and Recital 26, pseudonymised data is still personal data. pseudonym-mcp substantially reduces cleartext PII exposure but does not eliminate your legal obligations.
Development
The test suite runs fully offline — Ollama calls are injected via constructor and mocked in all tests. No live LLM required.
Adding a recognizer
- Add a file under
src/patterns/locale/<lang>/(orsrc/patterns/global/if it is language-independent) exporting aPatternRule:
- Register it in the
allPatternsarray insrc/patterns/index.ts. That is the only wiring — rule sets are derived from the registry by locale, so nothing else needs to know the rule exists. - For a brand-new language, add the locale to both
SupportedLocaleandSUPPORTED_LOCALESinsrc/patterns/types.ts— the default selection loads the list, so a pack missing from it never runs — plus the ISO 639-3 → short code mapping insrc/language/language-map.ts.tests/default-coverage.test.tsfails if the two drift apart, and expects one specimen per pack.
Picking a score: start low and let evidence do the work. A shape that only appears as this entity (ABC123456, a codice fiscale) can start near 0.5. A run of digits that could be anything starts at 0.15–0.25 and relies on validate or on context to clear the bar.
Picking a checksumMode: filter when a failed check means it was never this entity (Luhn on a card), boost when it means a typo and a miss would leak data (PESEL, IBAN), gate when the check only rules out impossible values without confirming anything (US SSN ranges).
See src/patterns/locale/pl/ for worked examples of all three.
Contributing
Contributions are welcome. Please follow Conventional Commits for commit messages.
Releases run on changesets. If your change is user-visible, add a changeset to the PR:
Merging to master then opens a "version packages" PR that bumps the version, server.json, src/version.ts and the changelog; merging that PR publishes to npm (Trusted Publishing, with provenance), tags the release, and refreshes the MCP registry entry. A merge with no pending changesets publishes nothing.
Language pack contributions are especially welcome — German (Personalausweis, Steuer-ID), French (NIR, SIRET), Spanish (DNI/NIE) and others would significantly expand the tool's usefulness.
License
MIT — Adrian Wolczuk
来源:README.md,提交 97a8893
工具
0版本历史
1- v0.9.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分