opami-protect-mcp
Official# opami-protect-mcp
An MCP server that lets Claude Code, Cursor, Codex and other MCP clients use Opami Protect to hide private and sensitive data in text and local text files. It runs locally over stdio.
## Before you start
- Node.js 22 or newer.
- An API key from the console: https://console.opami.ai
## Add it to your client
### Claude Code
```sh
claude mcp add opami-protect -e OPAMI_API_KEY=YOUR_OPAMI_API_KEY -- npx -y opami-protect-mcp
```
Run it in the project folder; add `--scope user` (before `--`) to use it in every project.
### Cursor
Put this in `.cursor/mcp.json`:
```json
{
"mcpServers": {
"opami-protect": {
"command": "npx",
"args": ["-y", "opami-protect-mcp"],
"env": { "OPAMI_API_KEY": "YOUR_OPAMI_API_KEY" }
}
}
}
```
Put the same block in `~/.cursor/mcp.json` to use it in every project, and never commit a file that holds your key.
### Codex
Put this in `~/.codex/config.toml`:
```toml
[mcp_servers.opami-protect]
command = "npx"
args = ["-y", "opami-protect-mcp"]
env = { OPAMI_API_KEY = "YOUR_OPAMI_API_KEY" }
```
After adding it, the client lists four tools: `protect_text`, `protect_file`, `detect_pii`, `restore_text`.
## Tools
- **`protect_text`**: inputs `text`, optional `exclude` (at most 50), `output` (`"placeholders"` by default, or `"replace"`) and `return_map`. Returns the text with placeholders such as `[PERSON_1]` and a `map_id`. `output: "replace"` puts fake data in instead. It works in 7 languages, costs twice as much and cannot be restored.
- **`protect_file`**: inputs `path` and optional `exclude`. Reads a UTF-8 text file of up to 1 MB inside the workspace folders the client shares. Paths outside them are refused, including through symlinks. PDF, DOCX and other binary files are refused. The file's content never enters the model's context. If the client shares no workspace folders, every path is refused, so use `protect_text`.
- **`detect_pii`**: inputs `text` and optional `exclude`. Returns each detection's `text`, `type`, `start`, `end` (UTF-16 indices) and `entity_id`, plus usage. The detections include the real values.
- **`restore_text`**: inputs `text` and `map_id`. Puts the real values back from the map the server kept. Runs locally, with no network call.
## Privacy
- Text (and file text) is sent to the Opami Protect API, which keeps nothing.
- Placeholders are pseudonymisation, not anonymisation: they can be reversed.
- The placeholder map (the real values) stays in the server's memory for the session and is never written to disk. It is returned to the agent only when `return_map` is true. A restart drops every map.
- The server logs no text, detections, placeholders or keys, and sends no telemetry.
## Errors
Failures come back as tool errors with the API error code, message, request id and, when there is one, the time to wait before retrying.
## Links and licence
- Docs: https://console.opami.ai/docs
- MIT, see [`LICENSE`](LICENSE).
TDQS
Scored across 4 tools
Each tool has a clearly distinct action: protect_text and protect_file differ only by input source and the descriptions make that boundary explicit, while restore_text and detect_pii are unambiguous opposites (reverse vs. read-only inspection). No two tools could be mistaken for one another.
All four names follow the same snake_case verb_noun pattern (protect_text, protect_file, restore_text, detect_pii) with verbs that accurately reflect the action. Consistent throughout.
Four tools form a tight, complete little surface for a pseudonymisation server: detect, protect (text and file variants), and restore. Every tool earns its place and nothing looks like filler.
The core lifecycle (detect, pseudonymise, restore) is fully covered, including a file variant and an irreversible fake-data mode. Minor gaps remain: no way to list or discard live map_ids, no batch/multi-file operation, and protect_file is limited to UTF-8 text, but agents can work around these.