SecureMCP
Enables privacy-preserving use of OpenAI models such as GPT-4o, o1, and o3 by masking sensitive content and entities before sending prompts to the API and restoring original text locally from model responses.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@SecureMCPmask this source code before sending to Claude and restore the identifiers"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐ก๏ธ SecureGateway (formerly SecureMCP)
Same project, new name. See the 1.0.0 rename and clean-install notes.
Local English/Korean Masking ยท Subscription Gateway ยท Trusted Restoration
์์ดยทํ๊ตญ์ดยท์ฝ๋๋ฅผ ๋ก์ปฌ์์ ๋ง์คํนํ๊ณ , ๋๊ตฌ ์คํ๊ณผ ์ฌ์ฉ์ ํ๋ฉด์์ ์๋ฌธ์ ๋ณต์ํ๋ ๊ฐ์ธ์ ๋ณด ๋ณดํธ ๋๊ตฌ
English ยท ํ๊ตญ์ด ์๋ด ยท Supported Versions ยท Quick Start ยท ์ค์นยท์ด์ ๊ฐ์ด๋ ยท Features ยท Architecture ยท Documentation
English Overview
SecureGateway masks English/Korean text and code locally, with session-based restoration.
Version 0.5 adds an experimental local subscription gateway for Claude Code and Codex.
Run secure-gateway gateway install once, then use claude / codex normally. Requests are
masked automatically; responses and local tool arguments are restored automatically. Existing
CLI subscription OAuth is forwarded to the original subscription service; API keys are refused.
No agent hooks are installed. See subscription gateway for setup,
automatic startup, tested versions and the exact protection boundary.
Legacy agent hooks remain optional utilities. They cover selected tool text rather than complete requests; local integration documents their limits.
Other hosts have explicit support levels in the compatibility table. Antigravity provides verified stdio MCP utility integration. SDK 0.1.21 uses a context-owned authenticated bridge to the explicit xAI API gateway; native file reads and restoration are verified offline, with separate API billing. The separate xAI API mode and Grok custom model require opt-in and incur API charges, independently of Claude/Codex or Grok subscriptions.
Mask confidential input before sending it to a provider. Restore responses in your trusted local application and show them to the user there. Model-invoked MCP tool arguments are already visible to the provider; adding this server to Claude Desktop or Cursor does not automatically intercept or protect prompts. Restored originals must not be sent back into the model context. This is heuristic masking, not a proof of anonymity, cryptographic zero knowledge, or regulatory compliance.
Related MCP server: phantomswap
Supported Versions
Component | Supported versions / scope |
SecureGateway | 1.0.0 |
Python | 3.10 ยท 3.11 ยท 3.12 ยท 3.13 ยท 3.14 in CI; package requires Python โฅ 3.10 |
Operating systems | Windows ยท macOS ยท Linux in CI |
Claude Code gateway | 2.1.287 / Sonnet 5.5 native fixtures and live subscription file-read/masking/restoration verified in English and Korean |
Codex gateway | CLI 0.160.0 / gpt-6.1-sol native fixtures and live ChatGPT subscription file-read/masking/restoration verified in English and Korean |
MCP transport | Local stdio; CLI HTTP/SSE transports are disabled |
Natural languages | English ยท ํ๊ตญ์ด ยท mixed input |
Code languages | Python ยท JavaScript ยท TypeScript ยท Go ยท Rust ยท Java ยท C ยท C++ ยท SQL |
The CI matrix covers 15 Python/OS combinations. Code-language support describes lexer modes, not compatibility with every language release or compiler. The gateway is experimental. Native fixture tests verify routing/masking/restoration. Both agents passed live subscription tests: native file reads, masked source transmission, model answers and automatic restoration in English and Korean. Claude's attribution and alias compatibility bugs are fixed. The earlier 429 was not subscription exhaustion. This does not certify all-traffic privacy.
Quick Start
Automatic subscription integration
uv tool install .
secure-gateway gateway install
secure-gateway gateway statusRestart Claude Code/Codex and use their normal commands. Setup preserves login caches and registers a hidden user-login startup task. It changes user-wide provider settings; no agent hooks are added. Subscription limits still apply. This is text/code inference protection; images, remote attachments and unsupported payloads are blocked. See gateway guide. For the complete lifecycle, including the local dashboard and login, see ์ค์นยท์ด์ ๊ฐ์ด๋.
์ค์นยท์คํยท๊ด๋ฆฌ์ ํ์ด์งยท์ข ๋ฃยท์ญ์
์๋๋ Claude Code / Codex ๊ตฌ๋
๊ฒ์ดํธ์จ์ด์ ์ ์ฒด ์ฌ์ฉ ์์์
๋๋ค.
Python 3.10 ์ด์, uv, Git์ ์ค๋นํ๊ณ ์ฌ์ฉํ ์์ด์ ํธ์์ ๊ธฐ์กด ๊ตฌ๋
๋ก๊ทธ์ธ์ ์๋ฃํ์ธ์.
๊ด๋ฆฌ์ ์นํ์ด์ง๋ ๊ฒ์ดํธ์จ์ด์ ํฌํจ๋์ด ์์ผ๋ฉฐ ๋ณ๋ ์น์๋ฒ๋ฅผ ์ค์นํ ํ์๊ฐ ์์ต๋๋ค.
1. ํจํค์ง ์ค์น์ ์ต์ด ์ค์
git clone https://github.com/mj10612/SecureGateway.git
cd SecureGateway
uv tool install .
secure-gateway gateway install
secure-gateway gateway status์ด๋ฏธ ์ ์ฅ์๋ฅผ ๋ด๋ ค๋ฐ์๋ค๋ฉด ํด๋น ํด๋์์ uv tool install .๋ถํฐ ์คํํ์ธ์.
gateway install์ ๊ธฐ๋ณธ์ ์ผ๋ก Claude Code์ Codex์ ์ฌ์ฉ์ ์ค์ ์ ๋ฐฑ์
ยท๋ณ๊ฒฝํ๊ณ ,
๊ฒ์ดํธ์จ์ด๋ฅผ ์ฆ์ ๋ฐฑ๊ทธ๋ผ์ด๋๋ก ์คํํ๋ฉฐ ์ด์์ฒด์ ์ฌ์ฉ์ ๋ก๊ทธ์ธ ์ ์๋ ์์์ ๋ฑ๋กํฉ๋๋ค.
๊ธฐ์กด Claude/ChatGPT ๋ก๊ทธ์ธ ํ์ผ์ ๋ณ๊ฒฝํ์ง ์์ต๋๋ค. ์ค์น ํ ์คํ ์ค์ด๋ ์์ด์ ํธ๋ฅผ
์ข
๋ฃํ๊ณ ๋ค์ ์คํํด์ผ ์ ๊ฒฝ๋ก๊ฐ ์ ์ฉ๋ฉ๋๋ค.
ํ ์์ด์ ํธ๋ง ์ค์ ํ๊ฑฐ๋ ํฌํธ๋ฅผ ๋ฐ๊พธ๋ ค๋ฉด ์ต์ด ์ค์น ๋ ์ต์ ์ ์ง์ ํ์ธ์.
secure-gateway gateway install --agent codex
# ๋๋ Claude Code๋ง ์ค์
secure-gateway gateway install --agent claude
# ๊ธฐ๋ณธ ํฌํธ 38117 ๋์ ๋ค๋ฅธ ํฌํธ ์ฌ์ฉ
secure-gateway gateway install --port 38119์ ์์๋ ์ ํ์ง์ด๋ฉฐ ์ ๋ถ ์คํํ ํ์๋ ์์ต๋๋ค. ๊ธฐ์กด ์ค์น์ ํฌํธ๋ฅผ ๋ณ๊ฒฝํ๋ ค๋ฉด
๋จผ์ gateway uninstall๋ก ์ค์ ์ ๋ณต์ํ ๋ค ์ํ๋ ํฌํธ๋ก ๋ค์ ์ค์นํ์ธ์.
secure-gateway ๋ช
๋ น์ ์ฐพ์ง ๋ชปํ๋ค๋ฉด uv tool update-shell์ ์คํํ๊ณ ํฐ๋ฏธ๋์ ๋ค์ ์ฌ์ธ์.
2. ์คํยท์ํ ํ์ธยท์ฌ์์
์ต์ด ์ค์น ํ์๋ ํ์์ฒ๋ผ claude / codex๋ฅผ ์คํํ๋ฉด ๋ฉ๋๋ค. ๋ก๊ทธ์ธ ์ ์๋ ์์๋
๊ฒ์ดํธ์จ์ด๊ฐ ๋ง์คํนยท์ค๊ณยท๋ณต์์ ์ฒ๋ฆฌํฉ๋๋ค. ์ํ๋ ๋ค์ ๋ช
๋ น์ผ๋ก ํ์ธํฉ๋๋ค.
secure-gateway gateway status์ด ๋ช ๋ น์ ์๋ฒ ์ํ์ ์ค์น ํ์ผ ๋ณ๊ฒฝ ์ฌ๋ถ๋ฅผ ํ์ธํฉ๋๋ค. ์ค์ ์ถ๋ก ์์ฒญ์ด ๊ฒ์ดํธ์จ์ด๋ฅผ ํต๊ณผํ๋์ง๋ ์์ด์ ํธ์์ ์์ฒญ์ ๋ณด๋ธ ๋ค ๊ด๋ฆฌ์ ํ์ด์ง์ ์ฒ๋ฆฌ ๋ก๊ทธ๋ก ํ์ธํ์ธ์.
์๋ ์คํ ๋๋ ์ง๋จ์ด ํ์ํ๋ฉด ๊ธฐ์กด ๋ฐฑ๊ทธ๋ผ์ด๋ ํ๋ก์ธ์ค๋ฅผ ๋จผ์ ์ข ๋ฃํ ๋ค ์คํํฉ๋๋ค.
secure-gateway gateway stop
secure-gateway gateway rungateway run์ ํ์ฌ ํฐ๋ฏธ๋์์ ๊ณ์ ์คํ๋๋ฉฐ Ctrl+C๋ก ์ข
๋ฃํฉ๋๋ค.
์ด ์ํ์์ ๊ด๋ฆฌ์ ํ์ด์ง๋ฅผ ์ด๋ ค๋ฉด ๋ค๋ฅธ ํฐ๋ฏธ๋์ ์ฌ์ฉํ์ธ์.
์ข
๋ฃํ ๊ฒ์ดํธ์จ์ด๋ฅผ ๋ค์ ๋ฐฑ๊ทธ๋ผ์ด๋๋ก ์คํํ๋ ค๋ฉด ์ค์น ์ค์ ์ด ๋ณ๊ฒฝ๋์ง ์์ ์ํ์์
secure-gateway gateway install์ ๋ค์ ์คํํ ์ ์์ต๋๋ค.
์ ์ฅ์์ ์ต์ ์ฝ๋๋ก ๊ธฐ์กด ํจํค์ง๋ฅผ ์ ๋ฐ์ดํธํ ๋๋ ๋ค์ ์์๋ฅผ ์ฌ์ฉํ์ธ์.
secure-gateway gateway stop
uv tool install --force .
secure-gateway gateway install์ดํ ์์ด์ ํธ๋ฅผ ์ฌ์์ํ์ธ์. ์ค์น ๋ค ํธ์คํธ ์ค์ ์ด ์์ ๋๋ค๋ฉด ์ฌ์ค์นยท์ ๊ฑฐ๊ฐ ๊ฑฐ๋ถ๋ ์
์์ต๋๋ค. ์ค๋ฅ๊ฐ ๊ฐ๋ฆฌํค๋ ์ค์ ๊ณผ installation.json์ ๋ฐฑ์
์ ๊ฒํ ยท๋ณํฉํ ๋ค ์ฌ์๋ํ์ธ์.
3. ๊ด๋ฆฌ์ ํ์ด์ง ์คํ
๊ฒ์ดํธ์จ์ด๊ฐ ์คํ ์ค์ผ ๋ ๋ค์ ๋ช ๋ น์ผ๋ก ๊ธฐ๋ณธ ๋ธ๋ผ์ฐ์ ๋ฅผ ์ฝ๋๋ค.
secure-gateway gateway admin๊ธฐ๋ณธ ์ฃผ์๋ http://127.0.0.1:38117/admin์
๋๋ค. ์ค์น ์ ํฌํธ๋ฅผ ๋ณ๊ฒฝํ๋ค๋ฉด ํด๋น ํฌํธ๋ฅผ
์ฌ์ฉํ์ธ์. gateway admin์ ์ค์ ํ์ผ์์ ํฌํธ๋ฅผ ์ฝ์ด ์ฌ๋ฐ๋ฅธ ์ฃผ์๋ฅผ ์๋ดํฉ๋๋ค.
๋ธ๋ผ์ฐ์ ๋ฅผ ์๋์ผ๋ก ์ด์ง ์๊ณ ์ฃผ์๋ง ํ์ธํ๋ ค๋ฉด ๋ค์ ๋ช
๋ น์ ์ฌ์ฉํ์ธ์.
secure-gateway gateway admin --no-open์ด ๋ช ๋ น์ ๊ฒ์ดํธ์จ์ด๋ฅผ ์๋ก ์์ํ์ง ์์ต๋๋ค. ์๋ฒ๊ฐ ์ค์ง๋๋ค๋ฉด ๋จผ์ ์คํํ์ธ์.
4. ๊ด๋ฆฌ์ ๋ก๊ทธ์ธ๊ณผ ๋ก๊ทธ ์กฐํ
์ค์ ํ์ผ์ ํ ํฐ์ด ์๋ค๊ณ ์๋ ๋ก๊ทธ์ธ๋๋ ๊ฒ์ ์๋๋๋ค. ๋ธ๋ผ์ฐ์ ๋ ๋ก์ปฌ ์ค์ ํ์ผ์ ์ฝ์ง ์์ต๋๋ค. ๋ค์ ์์๋ก ๋ก๊ทธ์ธํ์ธ์.
์ฌ์ฉ ์ค์ธ ๊ฒ์ดํธ์จ์ด์
config.json์ ๋ก์ปฌ ํธ์ง๊ธฐ๋ก ์ฝ๋๋ค.JSON์
tokenํญ๋ชฉ ๊ฐ์ ๋ณต์ฌํฉ๋๋ค. ๊ฐ ์ฃผ๋ณ์ ํฐ๋ฐ์ดํ๋ ์ ์ธํฉ๋๋ค.๊ด๋ฆฌ์ ํ์ด์ง์ ๊ด๋ฆฌ์ ์ธ์ฆ ํ ํฐ ์ ๋ ฅ๋์ ๋ถ์ฌ ๋ฃ์ต๋๋ค.
๊ด๋ฆฌ์ ํ์ด์ง ์ด๊ธฐ ๋ฒํผ์ ๋๋ฆ ๋๋ค.
์ด์์ฒด์ | ๊ธฐ๋ณธ ์ค์ ํ์ผ |
Windows |
|
macOS / Linux |
|
์ด ํ ํฐ์ ์ค์นํ ๋ ์์ฑ๋๋ ๋ก์ปฌ ๊ฒ์ดํธ์จ์ด ์ ๊ทผ ํ ํฐ์ ๋๋ค. Claude/ChatGPT์ ๊ตฌ๋ ๋ก๊ทธ์ธ ํ ํฐ์ด๋ API ํค๋ฅผ ์ ๋ ฅํ๋ ๊ฒ์ด ์๋๋๋ค. ๋ณ๋์ ๊ด๋ฆฌ์ ๊ณ์ ยท๋น๋ฐ๋ฒํธ๋ ์์ผ๋ฉฐ, ์ค์ ํ์ผ์ ํ ํฐ๊ณผ ์ผ์นํ๋ฉด ๊ด๋ฆฌ์ ๋ก๊ทธ๋ฅผ ์กฐํํ ์ ์์ต๋๋ค. ํ ํฐ์ URL์ ๋ฃ๊ฑฐ๋ ๋ค๋ฅธ ์ฌ๋์๊ฒ ๊ณต์ ํ์ง ๋ง์ธ์.
ํ ํฐ์ ํ์ฌ ๋ธ๋ผ์ฐ์ ํญ์ ๋ฉ๋ชจ๋ฆฌ์๋ง ๋ณด๊ดํฉ๋๋ค. ๋ธ๋ผ์ฐ์ ํ์ด์ง๋ฅผ ์๋ก๊ณ ์นจ(F5)ํ๊ฑฐ๋ ํญ์ ๋ซ์ผ๋ฉด ๋ค์ ์ ๋ ฅํด์ผ ํ๋ฉฐ, ํ๋ฉด์ ๋ก๊ทธ์์ ๋ฒํผ์ ๋๋ฅด๋ฉด ํ ํฐ๊ณผ ํ์๋ ๋ด์ญ์ด ์ง์์ง๋๋ค. ํ๋ฉด ์์ ์๋ก๊ณ ์นจ ๋ฒํผ์ ๋ก๊ทธ์ธ ์ํ๋ฅผ ์ ์งํ๋ฉด์ ๋ก๊ทธ๋ง ๋ค์ ์กฐํํฉ๋๋ค. ๋ก๊ทธ์์์ ๊ฒ์ดํธ์จ์ด ์ข ๋ฃ๋ SQLite ๋ก๊ทธ ์ญ์ ๋ฅผ ์๋ฏธํ์ง ์์ต๋๋ค.
๊ด๋ฆฌ์ ํ๋ฉด์์๋ ์์ด์ ํธยท์ ๊ณต์ยท๊ตฌ๋ /API ์ธ์ฆยท๊ฒฐ๊ณผยท์์ ์ผ์ยท์ต๋ช ๊ณ์ ID๋ก ๋ก๊ทธ๋ฅผ ํํฐ๋งํ๊ณ , ๊ฐ ์์ฒญ์ ๋ชจ๋ธยท๋ชฉ์ ์งยทHTTP ์ํยท์ ์ก ์๋ยท์ฒ๋ฆฌ ์๊ฐยท๋ฐ์ดํธ ์๋ฅผ ํ์ธํ ์ ์์ต๋๋ค. Claude ๊ตฌ๋ , ChatGPT ๊ตฌ๋ , xAI API ํค ๊ฒฝ๋ก๋ ๊ตฌ๋ถ๋ฉ๋๋ค. ์ ๋ฌ๋ ๊ณ์ ์๋ณ์๋ ์ต๋ช ํํ๋ฉฐ, ๊ตฌ๋ ์๊ธ์ ๋ ๊ฒฐ์ ๊ณ์ ์ ํ์ธํ ์ ์๋ ๊ฒฝ์ฐ์๋ ํ์ธ ๋ถ๊ฐ๋ก ํ์ํฉ๋๋ค.
์ฒ๋ฆฌ ๋ด์ญ์ config.json ์์ **logs.sqlite3**์ ์ ์ฅํ๋ฉฐ ์ต๊ทผ 100,000๊ฑด์ ๋ณด๊ดํฉ๋๋ค.
์์ฒญยท์๋ต ์๋ฌธ, OAuth ํ ํฐ, API ํค๋ ๊ธฐ๋กํ์ง ์์ต๋๋ค. ์ฌ์์ ํ์๋ ๋ก๊ทธ๋ ์ ์ง๋ฉ๋๋ค.
SQLite ๋ก๊ทธ๋ ๊ฒ์ดํธ์จ์ด๋ฅผ ์ข
๋ฃํ ๋ค ๋ฐฑ์
ํ๊ฑฐ๋ SQLite ์จ๋ผ์ธ ๋ฐฑ์
๊ธฐ๋ฅ์ ์ฌ์ฉํ์ธ์.
5. ์ฌ์ฉ์ ์ง์ ์ค์ ํ์ผ๊ณผ xAI API ๋ชจ๋
--config๋ก ์ค์นํ๋ค๋ฉด ์ดํ ๋ช
๋ น์์๋ ๊ฐ์ ์ค์ ํ์ผ์ ์ง์ ํด์ผ ํฉ๋๋ค.
์๋ ๊ฒฝ๋ก๋ ์ค์ ์ฌ์ฉ ์ค์ธ ๊ฒฝ๋ก๋ก ๋ฐ๊พธ์ธ์.
secure-gateway gateway install --config ./gateway-state/config.json
secure-gateway gateway status --config ./gateway-state/config.json
secure-gateway gateway admin --config ./gateway-state/config.json
secure-gateway gateway stop --config ./gateway-state/config.json
secure-gateway gateway uninstall --config ./gateway-state/config.json์๋ ์คํ๋ gateway run --config ./gateway-state/config.json์ ์ฌ์ฉํฉ๋๋ค.
๊ด๋ฆฌ์ ๋ก๊ทธ์ธ์๋ ์ด ํ์ผ์ token์ ์ฌ์ฉํ๊ณ , ๋ก๊ทธ DB๋ ๊ฐ์ ํด๋์ ์ ์ฅ๋ฉ๋๋ค.
xAI API ๋ชจ๋๋ ๊ตฌ๋
๊ฒ์ดํธ์จ์ด์ ๋ณ๋๋ก ์ค์ ยท์คํํ๋ฉฐ ๋ณ๋ API ์๊ธ์ด ๋ฐ์ํฉ๋๋ค.
์ค์น๋ Grok / xAI ์๋ด๋ฅผ ๋ฐ๋ฅด๊ณ , ์คํ์๋ gateway api-run,
์ ๊ฑฐ์๋ gateway api-uninstall์ ์ฌ์ฉํ์ธ์. ๊ธฐ๋ณธ ์ค์ ์
~/.secure-gateway/xai-api/config.json, ๊ธฐ๋ณธ ํฌํธ๋ 38118์
๋๋ค.
๊ด๋ฆฌ์ ํ๋ฉด์ ๋์ผํ ๋ช
๋ น์ผ๋ก ํด๋น ์ค์ ํ์ผ์ ์ง์ ํด ์ฝ๋๋ค.
secure-gateway gateway admin --config /path/to/xai-api/config.json6. ์ข ๋ฃยท์ค์ ํด์ ยทํจํค์ง ์ญ์
์ํ๋ ์์ | ๋ฐฉ๋ฒ | ๋จ๋ ํญ๋ชฉ |
๊ด๋ฆฌ์ ํ๋ฉด ๋ก๊ทธ์์ | ํ๋ฉด์ ๋ก๊ทธ์์ | ๊ฒ์ดํธ์จ์ด๋ ๊ณ์ ์คํ๋๊ณ DB ๋ก๊ทธ๋ ์ ์ง |
ํ์ฌ ๊ฒ์ดํธ์จ์ด๋ง ์ข ๋ฃ |
| ์์ด์ ํธ ์ค์ ยท์๋ ์์ ๋ฑ๋กยท๋ก์ปฌ ๋ฐ์ดํฐ ์ ์ง |
๊ฒ์ดํธ์จ์ด ์ค์ ํด์ |
| ์ค์ ๋ณต์ ํ ๋ก์ปฌ ์ค์ ํ์ผยท๋ก๊ทธยท์ธ์ ๋ฐ์ดํฐ ์ ์ง |
์ค์นํ ํจํค์ง ์ญ์ | ์ค์ ํด์ ํ | ์ ์ฅ์์ ๋ก์ปฌ ๋ฐ์ดํฐ ์ ์ง |
stop๋ง ์คํํ๋ฉด ๋ค์ ์ด์์ฒด์ ๋ก๊ทธ์ธ ๋ ๊ฒ์ดํธ์จ์ด๊ฐ ๋ค์ ์์๋ ์ ์์ต๋๋ค.
์ข
๋ฃ๋ ๋์์๋ ๊ฒ์ดํธ์จ์ด๋ฅผ ์ฌ์ฉํ๋๋ก ์ค์ ๋ ์์ด์ ํธ ์์ฒญ์ด ์คํจํฉ๋๋ค.
์๋ ์์ ๋ฑ๋ก์ ์ ๊ฑฐํ๊ณ ์์ด์ ํธ์ ๊ธฐ์กด ์ค์ ์ผ๋ก ๋์๊ฐ๋ ค๋ฉด uninstall์ ์ฌ์ฉํ์ธ์.
์์ ํ ์ฌ์ฉ์ ์ค๋จํ ๋์ ์์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
secure-gateway gateway uninstall
uv tool uninstall secure-gatewayuninstall์ ์คํ ์ค์ธ ๊ฒ์ดํธ์จ์ด๋ฅผ ์ข
๋ฃํ๊ณ , ๋ฐฑ์
ํ ์์ด์ ํธ ์ค์ ๊ณผ ์๋ ์์ ํ์ผ์
์ค์น ์ ์ํ๋ก ๋ณต์ํฉ๋๋ค. ์ฑ๊ณตํ ๋ค ์์ด์ ํธ๋ฅผ ์ฌ์์ํ์ธ์. ์ค์น ํ ์์ ๋ ํ์ผ์
๋ฎ์ด์ฐ์ง ์๋๋ก ์ ๊ฑฐ๊ฐ ๊ฑฐ๋ถ๋๋ฉด ๋จผ์ ์ค์ ์ ๊ฒํ ยท๋ณํฉํด์ผ ํฉ๋๋ค. ์ค์ ๋ณต์์ด ์๋ฃ๋๊ธฐ
์ ์ ํจํค์ง๋ ๋ฐฑ์
์ ์ญ์ ํ์ง ๋ง์ธ์. xAI API ์ค์ ๋ ์ฌ์ฉํ๋ค๋ฉด ํจํค์ง๋ฅผ ์ญ์ ํ๊ธฐ ์ ์
gateway api-uninstall๋ ์คํํ์ธ์.
๋ณต๊ตฌ์ฉ ์ค์ ยทSQLite ๋ก๊ทธยท์ํธํ ์ธ์ ์ ์๋์ผ๋ก ์ญ์ ํ์ง ์์ต๋๋ค. ์ ๊ฑฐ๊ฐ ์ฑ๊ณตํ๊ณ ๊ฒ์ดํธ์จ์ด๊ฐ ์ข ๋ฃ๋ ๊ฒ์ ํ์ธํ ๋ค, ๋ฐ์ดํฐ๊น์ง ์ญ์ ํ๋ ค๋ฉด ํ์ํ ๋ก๊ทธ๋ฅผ ๋จผ์ ๋ฐฑ์ ํ๊ณ ํด๋น ๋ฐ์ดํฐ ํด๋๋ฅผ ์๋ ์ญ์ ํ์ธ์.
์ค์น ๋ฐฉ์ | ์ญ์ ํ ๋ฐ์ดํฐ ํด๋ |
๊ธฐ๋ณธ ๊ตฌ๋ ๊ฒ์ดํธ์จ์ด | Windows: |
๊ธฐ๋ณธ xAI API ๊ฒ์ดํธ์จ์ด | Windows: |
์ฌ์ฉ์ ์ง์ ์ค์ | ์ง์ ํ |
์ฌ์ฉ์ ์ง์ ํด๋์ ๋ค๋ฅธ ํ์ผ์ด ์๋ค๋ฉด ํด๋ ์ ์ฒด๋ฅผ ์ญ์ ํ์ง ๋ง์ธ์. ์์ค ์ ์ฅ์๋ ํจํค์ง ์ ๊ฑฐ์ ๋ณ๊ฐ์ด๋ฏ๋ก ๋ ์ด์ ํ์ํ์ง ์์ ๋ ์ง์ ์ญ์ ํ ์ ์์ต๋๋ค.
์์ธํ ๋ณดํธ ๋ฒ์์ ์ค๋ฅ ์ง๋จ์ ๊ฒ์ดํธ์จ์ด ์๋ด๋ฅผ ์ฐธ๊ณ ํ์ธ์.
Legacy optional agent hooks
uv tool install .
secure-gateway init --agent claude
secure-gateway doctorRestart Claude Code after installation. Hooks default to the current project; use --global
for user-wide registration. See local integration for supported
tool fields, installation/removal and limitations.
For Codex:
secure-gateway init --agent codex
secure-gateway doctor --agent codexRestart Codex and review/trust the installed definitions in /hooks. Project hooks require a
trusted project. Codex masks tool results and restores Bash/apply_patch inputs; automatic
screen restoration is unavailable. Use secure-gateway restore --agent codex --session-id <id>
with masked text on UTF-8 stdin for local display. See Codex integration.
Development installation and demo
uv venv
uv pip install -e ".[dev]"
uv run python -m secure_gateway demoTrusted local Python API
from secure_gateway import LocalPrivacyClient
# Replace echo with your provider adapter. Only its argument may leave the host.
def provider(masked_payload: str) -> str:
return masked_payload
with LocalPrivacyClient() as client:
result = client.request(
"Patient John Doe received 50mg.", provider,
sensitive_terms={"John Doe"},
)
print(result.unmasked_text) # Local display onlyFeatures
Feature | Behavior |
๐ English & Korean | Per-word multilingual handling, conservative Korean particle separation and explicit sensitive terms |
๐งฉ Code-aware masking | Language-specific lexer modes for identifiers, literals and comments; numbers preserved by default |
๐ญ Four surrogate strategies | Bracket, Unicode, delimited pseudoword and random hash representations |
๐ Subscription gateway | Automatic request masking, shared prompt/code aliases, local tool-argument restoration and automatic answer display; existing OAuth, no API-key fallback |
๐ Local admin dashboard | Token-authenticated log viewer, routing/account metadata, filters and request details; SQLite storage, no prompt/reply/credential logging |
๐ Local agent hooks | Claude Code and Codex tool-text masking and local execution-argument restoration; Claude Code also supports display-only restoration |
๐ Session management | Stable per-session mappings, operation locks, idle expiry and opt-in encrypted snapshots |
๐ ๏ธ CLI & Python API | Local masking/restoration, hook diagnostics, statistics and a buffered command wrapper |
Masking policies
Mode | Behavior |
| Mask content words and detected sensitive spans; keep functional grammar. |
| Mask recognized PII, URLs, secrets, code spans, numbers and capitalized names. Korean and other case-free/non-ASCII words are masked conservatively, including ordinary nouns. |
| Keep a small structural subset of articles/prepositions/conjunctions; mask auxiliaries, adverbs, pronouns and other words. |
| Mask identifiers, literals and comments using the selected lexer; preserve numbers unless explicitly enabled. |
English, Korean and mixed input are handled per word. Unicode names remain atomic. Korean
particle splitting uses known stems and conservative rules; unknown ambiguous words stay whole.
It is not a full morphological analyzer or universal person-name detector. Supply sensitive_terms
for domain names, lowercase names, ambiguous names, and custom secrets. custom_preserve / CLI
--preserve deliberately exempts selected words; recognized sensitive spans still take precedence.
Unknown secret formats and context-dependent names may evade entities_only; inspect the payload
or use broader masking. A high masking ratio does not prove absence of sensitive data.
Surrogate strategies
Strategy | Representation |
|
|
|
|
| Explicitly delimited pronounceable words, e.g. |
| Random 96-bit nonce, independent of the original |
Pseudowords use explicit delimiters
to avoid collisions with real words and adjacent tokens. Allocation is stable within a session;
random strategies intentionally differ between sessions. Keep all surrogate spelling intact.
Altered/unknown placeholder candidates are reported in unmatched_surrogates; strict=True
rejects them. Free-form deletion or invention by a model cannot always be detected or reconstructed.
Korean restoration
Exact mask/unmask roundtrips keep written particles. For newly generated Korean responses,
opt into normalize_particles=True (CLI --normalize-particles) to choose ์ด/๊ฐ, ์/๋, ์/๋ฅผ,
๊ณผ/์ and ์ผ๋ก/๋ก from a restored Hangul stem. Pronunciation of foreign names is not guessed.
Code-aware review representations
Code languages: python, javascript, typescript, go, rust, java, c, cpp, sql.
Use explicit language in mask_code (CLI --code-language) for ambiguous snippets.
Auto detection is best effort. Keywords are language-specific; builtins and shadowed builtin
names are masked. Unicode identifiers, SQL comments/doubled quotes, backticks, Python f-strings
and escaped newlines, C++/Rust raw strings and numeric suffixes/separators are covered by tests.
Code allocations use ASCII names (smcp_ID_n and smcp_LIT_n inside literals)
and, when numeric masking is enabled, random native integer constants for numbers
(reserved 732846 prefix plus 12 digits),
independently of the text strategy, so byte literals remain valid too. Python output
is syntax-checked in tests. Output is an opaque review representation: it need not execute,
type-check or preserve f-string/template interpolation behavior. Numeric types/values can
change when numeric masking is enabled. This
small lexer is not a complete parser for every version of every supported language.
System Architecture
flowchart LR
Input[Trusted local input] --> Mask[Masking engine]
Mask -->|Masked payload| Provider[AI provider callback]
Provider -->|Surrogate response| Restore[Local restoration]
Restore --> Display[User display]
Vault[Local session mappings] --- Mask
Vault --- RestoreThe subscription gateway masks configured inference requests before forwarding them and restores responses before the CLI consumes them. The callback path masks its provider argument. Legacy agent hooks use a separate, partial tool-text path; they do not intercept all outgoing context. See the architecture and local integration documents.
CLI and Sessions
python -m secure_gateway mask "Alice from Google" --session-id example --session-file example.enc --json-output
python -m secure_gateway unmask "[ENT_1] from [ENT_2]" --session-id example --session-file example.enc --strict
python -m secure_gateway mask "john doe" --mode entities_only --sensitive-term "john doe"Use the same hidden password, or SECURE_GATEWAY_SESSION_PASSWORD. CLI files use authenticated
Fernet encryption, random salt, PBKDF2-HMAC-SHA256 with 600,000 iterations, atomic writes and a
lock over the complete CLI read/modify/write operation. A concurrent writer fails clearly.
Marked .lock files are persistent and their OS locks are released after a crash; retain
these files. Only legacy empty locks require manual migration after all old writers stop.
Files are opt-in; without --session-file, mappings only survive in the current process.
Payload schema v2 stores allocations/counters without regenerating mappings. Legacy v1 files
remain readable; unknown schema versions fail explicitly. Delete session files after use.
Legacy bare pseudoword allocations retain their old ambiguity; start a new session to use
the safe delimited representation for every allocation.
Session strategies are immutable; mode records the last-used policy. Creating a duplicate ID
fails without changing its TTL or mappings. TTL must be positive and at most one day. The vault
sweeps idle expired sessions at most one cleanup interval later (default one second), and checks
expiration on access. Clear waits for active operations and invalidates retained references.
Library users must use session.operation() for custom mutations; built-in engine operations
use the same lock. vault.close() stops cleanup and releases all mapping references. Python
cannot promise byte-level memory zeroization. Standalone PrivacySession owners manage lifetime
themselves; use SessionVault for scheduled expiry.
Version 0.6 adds UTF-8 stdin and --input-file for mask/unmask, configurable MCP
resource limits, and local Hook snapshot diagnostics:
secure-gateway mask --input-file private.txt --session-file example.enc --json-output
secure-gateway state status
secure-gateway state gc # read-only preview
secure-gateway state gc --apply # retire expired snapshots; use new conversations
secure-gateway gateway diagnosticsMCP defaults are 1,000 sessions, 100,000 mappings per session, and 16 MiB per input.
serve --max-sessions, --mapping-limit, and --input-limit configure them. Gateway
defaults admit 32 inference requests globally and eight per provider; JSON configuration
keys are max_active_requests and max_provider_requests. See the integration guides
for command limits, safe cleanup, and supported schema constraints.
masked_ratio counts masked token occurrences divided by non-whitespace/non-punctuation
occurrences. Deprecated privacy_entropy_score is an alias, not information entropy.
restored_occurrences counts replacements; restored_unique_tokens counts distinct allocations.
restored_tokens_count remains a compatibility alias for replacement occurrences.
MCP Tools Reference
python -m secure_gateway serve supports local stdio only. HTTP/SSE transports are disabled in the CLI;
directly exposing the Python server over a network requires host-provided authentication and isolation.
MCP tool | Purpose |
| Mask text with a selected policy and session |
| Create a code review representation using a selected language lexer |
| Create an isolated mapping session |
| Return counters without original values or mapping entries |
| Release the session's mapping references |
Local Python unmask_text / unmask_code and CLI unmask are not registered as MCP tools,
so a model cannot enumerate mappings via restoration. Resources: privacy://policies, privacy://status.
Example desktop configurations are utility setups, not privacy proxies.
Migration from 0.1
Version 0.2 changes pseudoword delimiters, code identifier/number representations, mapping keys
(mapping_key(original, token_type, code=...)), sentence-initial entity classification, keyword
preservation, and the MCP restoration boundary. Direct store readers should use mapping values
or mapping_key. Validate explicitly requested strategies; omitted strategies follow the generator.
ํ๊ตญ์ด ์๋ด (Korean Overview)
0.5์์๋ Claude CodeยทCodex์ ๊ธฐ์กด ๊ตฌ๋
๋ก๊ทธ์ธ์ ์ ์งํ๋ ๋ก์ปฌ ๊ฒ์ดํธ์จ์ด๋ฅผ ์ ๊ณตํฉ๋๋ค.
uv tool install . ์ค์น ํ secure-gateway gateway install์ ํ ๋ฒ ์คํํ๊ณ ๋ CLI๋ฅผ ์ฌ์์ํ์ธ์.
๊ทธ ๋ค์๋ ํ์์ฒ๋ผ claude / codex๋ฅผ ์ฌ์ฉํ๋ฉด ๋ฉ๋๋ค. ์ง์ ์
๋ ฅยทํ
์คํธ ์ฝ๋ยท๋๊ตฌ ๊ฒฐ๊ณผ๋ฅผ ์๋์ผ๋ก
๋ง์คํนํ๊ณ , ๋ต๋ณ๊ณผ ๋ก์ปฌ ์คํ ์ธ์๋ ์๋ ๋ณต์ํฉ๋๋ค. ํจ์๋ช
ยท๋ณ์๋ช
ยท๋ฌธ์์ดยท์ซ์ยท์ฃผ์์ ๋ณด์กดํ๋
์์ธ๋ ์ถ๊ฐํ์ง ์์์ต๋๋ค. ์
๋ ฅ์์ ์ง์นญํ ํจ์์ ์ฝ๋์ ํจ์๋ ๊ฐ์ ์นํํ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
๊ธฐ์กด ๋ก๊ทธ์ธ ํ์ผ์ ์ฝ๊ฑฐ๋ ๋ณต์ฌํ์ง ์์ต๋๋ค. CLI๊ฐ ๊ด๋ฆฌํ๋ OAuth ํค๋์ ๊ฐฑ์ ํ๋ฆ์ ์ฌ์ฉํ๊ณ , API ํค ์์ฒญ์ ๊ฑฐ๋ถํ๋ฏ๋ก ์ ๋ฃ API๋ก ์๋ ์ ํํ์ง ์์ต๋๋ค. ์ Hook์ ๋ฑ๋กํ์ง ์์ผ๋ฉฐ, ์ด์์ฒด์ ์ฌ์ฉ์ ๋ก๊ทธ์ธ ์ ๋ฐฑ๊ทธ๋ผ์ด๋๋ก ์๋ ์์ํ๋๋ก ์ค์ ํฉ๋๋ค. ๊ธฐ์กด Hook ๋ฐฉ์์ ์ ํ ๊ธฐ๋ฅ์ผ๋ก ๋จ๊ฒจ ๋์์ต๋๋ค. ์ค์นยทํด์ ๋ฐ ๋ณดํธ ๋ฒ์๋ฅผ ํ์ธํ์ธ์.
Claude Code 2.1.287ยทCodex 0.160.0์ ์ค์ CLI๋ฅผ ๋ชจ์ OAuth/๋ก์ปฌ ์๋ฒ๋ก ๊ฒ์ฆํ์ต๋๋ค. ๋ CLI ๋ชจ๋ ๊ธฐ์กด ๊ตฌ๋ ๋ก๊ทธ์ธ์ผ๋ก ์์ดยทํ๊ตญ์ด ์ง๋ฌธ โ ์ค์ ํ์ผ ์ฝ๊ธฐ โ ์ฝ๋ ๋ง์คํน ์ ์ก โ ์ ์ ๋ต๋ณยท์๋ ๋ณต์๊น์ง ๊ฒ์ฆํ์ต๋๋ค. Claude์ ์๋ณ ๋ธ๋กยท์นํ๋ช ํธํ ์ค๋ฅ๋ฅผ ์์ ํ์ผ๋ฉฐ, ๊ธฐ์กด 429๋ ๊ตฌ๋ ํ๋ ์์ง์ด ์๋์์ต๋๋ค. ์ด๋ฏธ์งยท์๊ฒฉ ์ฒจ๋ถยท๋ฏธ์ง์ ์์ฒญ์ ์ฐจ๋จํ๊ณ , ๊ฒ์ดํธ์จ์ด ๋ฐ์ ๋๊ตฌ ๋คํธ์ํฌยทํ ๋ ๋ฉํธ๋ฆฌ๊น์ง ๋ณดํธํ๋ค๊ณ ์ฃผ์ฅํ์ง ์์ต๋๋ค.
SecureGateway๋ ์์ดยทํ๊ตญ์ดยทํผํฉ ๋ฌธ์ฅ์ ๋ก์ปฌ์์ ๋ง์คํนํ๊ณ ๋ณต์ํฉ๋๋ค. ํด๋ผ์ฐ๋์ ์์ฒญํ๊ธฐ
์ ์ LocalPrivacyClient ๋๋ ๋ก์ปฌ API/CLI๋ก ์๋ฌธ์ ๊ฐ๋ฆฌ๊ณ , ์๋ต์ ๋ก์ปฌ์์๋ง ๋ณต์ํ์ธ์.
๋ชจ๋ธ์ด ํธ์ถํ๋ MCP ๋๊ตฌ์ ์ธ์๋ ์ด๋ฏธ ์ ๊ณต์์๊ฒ ์ ๋ฌ๋์ด ์์ผ๋ฏ๋ก, Claude Desktop/Cursor์
์๋ฒ๋ฅผ ์ถ๊ฐํ๋ ๊ฒ๋ง์ผ๋ก ๊ฐ์ธ์ ๋ณด๊ฐ ๋ณดํธ๋์ง๋ ์์ต๋๋ค. ๋ณต์ํ ์๋ฌธ์ ๋ชจ๋ธ ์ปจํ
์คํธ์ ๋ค์
๋ฃ์ผ๋ฉด ์ ๋ฉ๋๋ค. MCP ๋ณต์ ๋๊ตฌ๋ ์ ๊ฑฐํ์ผ๋ฉฐ, ๊ธฐ๋ณธ CLI ์๋ฒ๋ ๋ก์ปฌ stdio๋ง ์ง์ํฉ๋๋ค.
์์ด ๋๋ฌธ์ ์ด๋ฆ๊ณผ Unicode ์ด๋ฆ์ ํ๋์ ํ ํฐ์ผ๋ก ์ฒ๋ฆฌํฉ๋๋ค. ํ๊ตญ์ด ์ด๋ฆ๊ณผ ์ผ๋ฐ ๋ช
์ฌ๊ฐ
๊ตฌ๋ถ๋์ง ์๋ entities_only์์๋ ๋น๊ธฐ๋ฅ์ด๋ฅผ ๋ณด์์ ์ผ๋ก ๊ฐ๋ฆฝ๋๋ค. ์กฐ์ฌ ๋ถ๋ฆฌ๋ ์๋ ค์ง ์ด๊ฐ๊ณผ
๋ณด์์ ์ธ ๊ท์น์ ์ฌ์ฉํ๋ฉฐ, ๋ชจํธํ ๋ฏธ๋ฑ๋ก ๋จ์ด๋ ํต์งธ๋ก ๊ฐ๋ฆฝ๋๋ค. ๋ชจ๋ ๊ณ ์ ๋ช
์ฌยท๋น๋ฐ๊ฐ ๋๋
ํ๊ตญ์ด ํํ์๋ฅผ ์๋ฒฝํ ์ธ์ํ๋ ๋๊ตฌ๋ ์๋๋๋ค. sensitive_terms / --sensitive-term์ผ๋ก
ํน์ ์ฉ์ด๋ฅผ ์ง์ ํ๊ณ , ์ ์ ์๋ ๋ฏผ๊ฐ์ ๋ณด์๋ ๋ ๋์ ๋ง์คํน ์ ์ฑ
์ ์ฌ์ฉํ์ธ์.
์ ํํ ์๋ณต ๋ณต์์์๋ ์
๋ ฅ ์กฐ์ฌ๋ฅผ ๊ทธ๋๋ก ์ ์งํฉ๋๋ค. ๋ชจ๋ธ์ด ์๋ก ๋ง๋ ๋ฌธ์ฅ์๋
normalize_particles=True / --normalize-particles๋ฅผ ์ ํํ์ฌ ๋ฐ์นจ์ ๋ง๋ ์กฐ์ฌ๋ฅผ ๋ณด์ ํ ์
์์ต๋๋ค. ์์ด ์ด๋ฆยท์ฝ์ด์ ๋ฐ์์ ์ถ์ธกํ์ง ์์ต๋๋ค. --strict๋ ํ์งํ ๋ณํยท๋ฏธ๋ฑ๋ก
ํ๋ ์ด์คํ๋์ ๋ณต์์ ๊ฑฐ๋ถํ์ง๋ง, ๋ชจ๋ธ์ด ์์ ํ ์ญ์ ํ ๋ด์ฉ์ ์ฌ๊ตฌ์ฑํ์ง๋ ๋ชปํฉ๋๋ค.
์ธ์
์ ๋ต์ ์์ฑ ํ ๊ณ ์ ๋๋ฉฐ, ์ค๋ณต ID ์์ฑ์ ์ค๋ฅ์
๋๋ค. ๋ง๋ฃ ์ธ์
์ ์ฃผ๊ธฐ์ ์ผ๋ก ์ ๋ฆฌํ๊ณ ,
์ญ์ ์ ์งํ ์ค ์์
์ ์ ๊ธ์ผ๋ก ์กฐ์จํฉ๋๋ค. ๋ณ๋ CLI ํ๋ก์ธ์ค ๊ฐ ๋ณต์์๋ ๋์ผํ ์ํธํ
--session-file์ด ํ์ํฉ๋๋ค. ๋ง์คํน ๋น์จ์ ํต๊ณ์ด๋ฉฐ ๊ธฐ๋ฐ์ฑยท์ต๋ช
์ฑยท๊ท์ ์ค์์ ์ฆ๋ช
์ด ์๋๋๋ค.
Development
python -m ruff check src tests examples
python -m mypy src
python -m pytest -W error --cov=secure_gateway --cov-report=term-missing --cov-fail-under=85Documentation
Host Compatibility and Shared Contract / ํธ์คํธ ํธํ์ฑ
Legacy Local Claude Code & Codex Integration / ๊ธฐ์กด Hook ์๋ด
License
Licensed under Apache License 2.0. See LICENSE for details.
Code numeric literals
Code masking preserves numeric literals by default, including their original spelling, base, exponent, separators and suffixes. This keeps indexes, loop bounds and comparison constants useful for code review. Names, strings and comments remain masked. Numeric values inside strings/comments follow their existing literal masking policy; ordinary natural-language number masking and provider protocol controls are unchanged.
To hide sensitive code numbers explicitly:
CLI:
secure-gateway mask --mode code_aware --mask-numbers ...MCP/Python: pass
mask_numbers=Truetomask_code, or tomask_textwithmode="code_aware"(Python engine/client useMaskMode.CODE_AWARE).Gateway: set
"mask_numbers": truein the gateway configuration, or startgateway run --mask-numbers/gateway api-run --mask-numbers.--preserve-numbersoverrides a configured opt-in. Both paths default to preservation.
Existing saved numeric aliases still restore. A literal that collides with an existing numeric alias is rejected rather than silently restored to another value; start a fresh session/conversation in that case. Literal numbers in the reserved alias range receive identity mappings so strict restoration and saved sessions remain unambiguous. Switching those particular literals to numeric masking also requires a fresh session. Turning on numeric masking changes values and does not preserve executable behavior.
This server cannot be deployed
Maintenance
Related MCP Connectors
Detect and redact PII and secrets before text reaches an LLM, with reversible placeholders.
Detect and redact PII and secrets (API keys, tokens) in text, HTML or PDF before it reaches an LLM.
Detecta e mascara dado pessoal brasileiro (CPF, CNPJ, RG, e-mail) antes do texto ir a uma IA. LGPD.
Detects and redacts PII (emails, phones, SSNs, names, addresses) from text. $0.02/call via x402.
Related MCP Servers
- AlicenseAqualityDmaintenanceScans prompts for PII and masks or redacts sensitive data locally before sending to an LLM, supporting multiple anonymization modes.1MIT
- AlicenseAqualityCmaintenanceEnables AI assistants to mask sensitive personal data and project directories before sending to AI, then unmask responses to restore original values using configurable swap sessions.7MIT
- FlicenseNot gradedqualityBmaintenanceEnables agents to encrypt and sanitize sensitive data such as credentials, credit card numbers, and addresses locally before dispatching prompts to cloud LLMs, then rehydrate the masked values client-side. It runs deterministically with zero external dependencies over MCP JSON-RPC stdio, so no plaintext PII leaves the user's machine.7-
- AlicenseAqualityCmaintenanceEnables local, in-memory de-identification of PII, PHI, and credentials with deterministic reversible surrogate tokens before LLM transmission, then restores originals from volatile session mappings and audits for exposures without network egress or disk writes.547 npmApache 2.0