@maskera/mcp 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Joel Hägvall
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,73 @@
1
- # Temporary Holding Version
1
+ # @maskera/mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Local Swedish PII redaction for any AI agent or LLM client:
4
+
5
+ 1. **Harness-agnostic LLM proxy (`maskera-mcp proxy`)**: sits between any agent/SDK (Claude Code, Codex, Cursor, OpenCode, Python/JS SDKs) and Anthropic/OpenAI, redacts outgoing prompts and tool results locally on-device, and transparently restores placeholders in both JSON and SSE streaming responses. Zero trust in the agent required.
6
+ 2. **MCP stdio server (`maskera-mcp`)**: exposes `maskera_read_file`, `maskera_write_file`, `maskera_redact`, `maskera_restore`, and session management tools over JSON-RPC 2.0 stdio.
7
+ 3. **Hook / pipe guard (`maskera-mcp guard`)**: blocks PII in Claude Code / Cursor hooks or Unix pipelines (`exit 2`, never echoes raw PII) or redacts streams via `--redact`.
8
+
9
+ All redaction runs 100% locally using `maskera` (deterministic Swedish rules + the 43 MB open Swedish ONNX NER model `joelhagvall/maskera-sv-ner`).
10
+
11
+ ## 1. Harness-agnostic local LLM proxy (enforced for every agent)
12
+
13
+ Start the proxy on loopback (`127.0.0.1:8787`):
14
+
15
+ ```bash
16
+ npx -y @maskera/mcp proxy
17
+ ```
18
+
19
+ Point any harness at it:
20
+
21
+ ```bash
22
+ # Claude Code / Anthropic SDK
23
+ ANTHROPIC_BASE_URL=http://127.0.0.1:8787 claude
24
+
25
+ # Codex / OpenAI SDK / Cursor custom OpenAI base URL
26
+ OPENAI_BASE_URL=http://127.0.0.1:8787/v1 codex
27
+
28
+ # Inspect local redaction counts (never raw PII)
29
+ curl http://127.0.0.1:8787/_maskera/status
30
+ ```
31
+
32
+ - Routes Anthropic (`/v1/messages`, `/anthropic/*`) and OpenAI (`/v1/chat/completions`, `/v1/responses`, `/openai/*`) automatically, or use `--upstream <url>` for any OpenAI/Anthropic-compatible gateway (Azure, OpenRouter, LiteLLM).
33
+ - Restores placeholders even when split across SSE stream chunks, including JSON `tool_use` / `tool_calls` arguments.
34
+ - Fails closed (`502`) if local redaction fails: raw PII is never forwarded upstream.
35
+
36
+ ## 2. MCP stdio server (Claude Desktop / Cursor / Claude Code / Codex / T3 Code)
37
+
38
+ ```json
39
+ {
40
+ "mcpServers": {
41
+ "maskera": {
42
+ "command": "npx",
43
+ "args": ["-y", "@maskera/mcp", "--root", "/path/to/your/workspace"]
44
+ }
45
+ }
46
+ }
47
+ ```
48
+
49
+ Tools:
50
+ - `maskera_read_file`: Read a local UTF-8 file already redacted, storing the restore map locally under `session_id`.
51
+ - `maskera_write_file`: Restore placeholders from `session_id` and write directly to disk without exposing raw PII back to the LLM.
52
+ - `maskera_redact`: Redact text locally (`mode: "auto"` or `"rules"`, `profile: "general" | "clinical"`, `custom_terms`).
53
+ - `maskera_restore`: Restore placeholders using `session_id` or an explicit map.
54
+ - `maskera_list_sessions` / `maskera_clear_session` / `maskera_status`: Inspect counts (never raw PII), clear memory, or check model status.
55
+
56
+ ## 3. Harness-agnostic guard / hook
57
+
58
+ ```bash
59
+ # Block prompts or hook JSON containing PII (exits 2 on match, 0 if clean)
60
+ echo '{"prompt":"Ring 070-174 06 58"}' | npx -y @maskera/mcp guard
61
+
62
+ # Redact any pipe locally
63
+ cat klient.txt | npx -y @maskera/mcp guard --redact
64
+ ```
65
+
66
+ ## Options and environment
67
+
68
+ - `--rules-only` or `MASKERA_MCP_MODE=rules`: Deterministic rules only without loading the ONNX model.
69
+ - `--profile general|clinical`: Built-in precision profile.
70
+ - `--custom-term <word>` (repeatable): Extra protected words (client names, codenames, case IDs).
71
+ - `--port <n>` / `--host <addr>` / `--upstream <url>` / `--no-restore`: Proxy options.
72
+ - `--root <dir>` (repeatable) or `MASKERA_MCP_ROOTS`: Allowed file roots for MCP file tools.
73
+ - `MASKERA_MODEL_PATH` + `MASKERA_MODEL_ID` + `MASKERA_ALLOW_REMOTE_MODELS=0`: Load a local ONNX model directory offline.