@node9/proxy 1.1.7 β†’ 1.3.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.
Files changed (6) hide show
  1. package/README.md +125 -18
  2. package/dist/cli.js +4138 -3652
  3. package/dist/cli.mjs +4435 -3952
  4. package/dist/index.js +1651 -1620
  5. package/dist/index.mjs +1649 -1618
  6. package/package.json +8 -3
package/README.md CHANGED
@@ -206,11 +206,117 @@ node9 shield status # see what's currently active
206
206
 
207
207
  ## πŸ›  Protection Modes
208
208
 
209
- | Mode | Target | How it works |
210
- | :-------------- | :--------------------- | :------------------------------------------------------ |
211
- | **Hook Mode** | Claude, Gemini, Cursor | `node9 addto <agent>` wires native pre-execution hooks. |
212
- | **Proxy Mode** | MCP Servers, Shell | `node9 "npx <server>"` intercepts JSON-RPC traffic. |
213
- | **Manual Mode** | You | `node9 rm -rf /` protects you from your own typos. |
209
+ | Mode | Target | How it works |
210
+ | :-------------- | :---------------------------- | :----------------------------------------------------------------------- |
211
+ | **Hook Mode** | Claude Code, Gemini, Cursor | `node9 addto <agent>` wires native pre-execution hooks. |
212
+ | **MCP Gateway** | Any MCP server, any AI client | `node9 mcp-gateway --upstream <cmd>` wraps any MCP server transparently. |
213
+ | **Manual Mode** | You | `node9 rm -rf /` protects you from your own typos. |
214
+
215
+ ---
216
+
217
+ ## 🌐 MCP Gateway
218
+
219
+ The MCP Gateway is a **transparent stdio proxy** that sits between any AI agent and any MCP server. The agent doesn't know Node9 is there β€” it just sees the same MCP server it always did.
220
+
221
+ ```
222
+ AI Agent (Claude, Cursor, Gemini…)
223
+ ↓ stdio (JSON-RPC)
224
+ Node9 MCP Gateway ← intercepts every tools/call
225
+ ↓ stdio (JSON-RPC)
226
+ Upstream MCP Server (filesystem, postgres, browser…)
227
+ ```
228
+
229
+ **Every `tools/call` is intercepted.** Read-only tools pass through silently. Write/mutate tools are routed through the full approval engine β€” DLP scan, smart rules, shields, and human approval.
230
+
231
+ ### Setup
232
+
233
+ **1. Register any MCP server through the gateway:**
234
+
235
+ ```bash
236
+ # Filesystem server β€” protect all file writes
237
+ claude mcp add filesystem -- node9 mcp-gateway --upstream \
238
+ "npx -y @modelcontextprotocol/server-filesystem /your/workspace"
239
+
240
+ # Any other MCP server β€” same pattern
241
+ claude mcp add myserver -- node9 mcp-gateway --upstream \
242
+ "npx -y @some/mcp-server"
243
+ ```
244
+
245
+ **2. Add globally (all projects):**
246
+
247
+ ```bash
248
+ claude mcp add --scope user filesystem -- node9 mcp-gateway --upstream \
249
+ "npx -y @modelcontextprotocol/server-filesystem /home/you"
250
+ ```
251
+
252
+ **3. Share with your team via `.mcp.json` in the repo:**
253
+
254
+ ```json
255
+ {
256
+ "mcpServers": {
257
+ "filesystem": {
258
+ "command": "node9",
259
+ "args": ["mcp-gateway", "--upstream", "npx -y @modelcontextprotocol/server-filesystem ."]
260
+ }
261
+ }
262
+ }
263
+ ```
264
+
265
+ > **Note:** `--upstream` takes a single command string. The gateway's tokenizer splits it on whitespace and handles double-quoted paths (e.g. `"npx \"/path with spaces/server.js\""`) β€” it does not run a shell.
266
+ >
267
+ > ⚠️ **Supply-chain warning:** `.mcp.json` files from untrusted repositories can specify any `--upstream` command. Always review `.mcp.json` before using it β€” treat it with the same caution as a `Makefile` or `package.json` `postinstall` script.
268
+
269
+ ### What gets protected
270
+
271
+ The same `ignoredTools`, smart rules, shields, and DLP that protect hook-mode tools apply here β€” but matched against **MCP tool names** (e.g. `write_file`, `execute_query`) instead of Claude's built-in tools.
272
+
273
+ **Tune your config for MCP tool names:**
274
+
275
+ ```json
276
+ {
277
+ "policy": {
278
+ "ignoredTools": ["read_file", "read_text_file", "list_*", "search_*"],
279
+ "toolInspection": {
280
+ "write_file": "content",
281
+ "execute_query": "sql",
282
+ "run_command": "command"
283
+ }
284
+ }
285
+ }
286
+ ```
287
+
288
+ **Add MCP-specific smart rules:**
289
+
290
+ ```json
291
+ {
292
+ "policy": {
293
+ "smartRules": [
294
+ {
295
+ "name": "block-write-production-config",
296
+ "tool": "write_file",
297
+ "conditions": [{ "field": "path", "op": "matches", "value": "/etc/|/prod/" }],
298
+ "verdict": "block",
299
+ "reason": "Writes to production config require a manual change process"
300
+ }
301
+ ]
302
+ }
303
+ }
304
+ ```
305
+
306
+ ### How blocked calls look to the AI
307
+
308
+ When Node9 blocks an MCP tool call, it returns a structured JSON-RPC error that tells the AI exactly what happened and instructs it to pivot:
309
+
310
+ ```json
311
+ {
312
+ "jsonrpc": "2.0",
313
+ "id": 42,
314
+ "error": {
315
+ "code": -32000,
316
+ "message": "NODE9 SECURITY ALERT: Action blocked by DLP β€” credential detected in content field. Do NOT retry. Remove the hardcoded secret and use an environment variable instead."
317
+ }
318
+ }
319
+ ```
214
320
 
215
321
  ---
216
322
 
@@ -327,18 +433,19 @@ Use `node9 explain <tool> <args>` to dry-run any tool call and see exactly which
327
433
 
328
434
  ## πŸ–₯️ CLI Reference
329
435
 
330
- | Command | Description |
331
- | :---------------------------- | :------------------------------------------------------------------------------------ |
332
- | `node9 setup` | Interactive menu β€” detects installed agents and wires hooks for you |
333
- | `node9 addto <agent>` | Wire hooks for a specific agent (`claude`, `gemini`, `cursor`) |
334
- | `node9 init` | Create default `~/.node9/config.json` |
335
- | `node9 status` | Show current protection status and active rules |
336
- | `node9 doctor` | Health check β€” verifies binaries, config, credentials, and all agent hooks |
337
- | `node9 shield <cmd>` | Manage shields (`enable`, `disable`, `list`, `status`) |
338
- | `node9 tail [--history]` | Stream live agent activity to the terminal (auto-starts daemon if needed) |
339
- | `node9 explain <tool> [args]` | Trace the policy waterfall for a given tool call (dry-run, no approval prompt) |
340
- | `node9 undo [--steps N]` | Revert the last N AI file edits using shadow Git snapshots |
341
- | `node9 check` | Called by agent hooks; evaluates a pending tool call and exits 0 (allow) or 1 (block) |
436
+ | Command | Description |
437
+ | :----------------------------------- | :------------------------------------------------------------------------------------ |
438
+ | `node9 setup` | Interactive menu β€” detects installed agents and wires hooks for you |
439
+ | `node9 addto <agent>` | Wire hooks for a specific agent (`claude`, `gemini`, `cursor`) |
440
+ | `node9 init` | Create default `~/.node9/config.json` |
441
+ | `node9 status` | Show current protection status and active rules |
442
+ | `node9 doctor` | Health check β€” verifies binaries, config, credentials, and all agent hooks |
443
+ | `node9 shield <cmd>` | Manage shields (`enable`, `disable`, `list`, `status`) |
444
+ | `node9 tail [--history]` | Stream live agent activity to the terminal (auto-starts daemon if needed) |
445
+ | `node9 explain <tool> [args]` | Trace the policy waterfall for a given tool call (dry-run, no approval prompt) |
446
+ | `node9 undo [--steps N]` | Revert the last N AI file edits using shadow Git snapshots |
447
+ | `node9 mcp-gateway --upstream <cmd>` | Wrap an MCP server with Node9 security β€” intercepts every tool call |
448
+ | `node9 check` | Called by agent hooks; evaluates a pending tool call and exits 0 (allow) or 1 (block) |
342
449
 
343
450
  ### `node9 doctor`
344
451
 
@@ -408,7 +515,7 @@ This can happen when the daemon's PID file (`~/.node9/daemon.pid`) is missing
408
515
  - [x] **Shield Templates** (`node9 shield enable <service>` β€” one-click protection for Postgres, GitHub, AWS)
409
516
  - [x] **Content Scanner / DLP** (Detect and block secrets like AWS keys and Bearer tokens in-flight)
410
517
  - [x] **Flight Recorder** (Real-time activity stream in browser dashboard and `node9 tail` terminal view)
411
- - [ ] **Universal MCP Gateway** (Standalone security tunnel for LangChain, CrewAI, and any agent without native hooks)
518
+ - [x] **Universal MCP Gateway** (Transparent stdio proxy β€” wraps any MCP server for any AI agent: `node9 mcp-gateway --upstream <cmd>`)
412
519
  - [ ] **Cursor & Windsurf Hook** (Native hook support for AI-first IDEs)
413
520
  - [ ] **VS Code Extension** (Approval requests in a native sidebar β€” no more OS popups)
414
521
  - [ ] **Execution Sandboxing** (Simulate dangerous commands in a virtual FS before applying)