@anurag134/nexusmcp 1.0.0 → 1.0.2

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 (3) hide show
  1. package/README.md +60 -21
  2. package/dist/index.js +25 -2
  3. package/package.json +11 -2
package/README.md CHANGED
@@ -1,25 +1,62 @@
1
1
  # NexusMCP
2
2
 
3
- **Local-First MCP Gateway & Semantic Tool Router**
3
+ **Local-First MCP Gateway, Semantic Tool Router & Zero-Trust Security Layer**
4
4
 
5
- Connect 50+ MCP servers behind a single local gateway without blowing up your AI client's context window or exposing your credentials.
5
+ Connect 50+ MCP servers behind a single local gateway (`http://localhost:3000/mcp/sse`) without flooding your AI client's context window or storing credentials in plain text.
6
6
 
7
- ## Why NexusMCP?
7
+ > **Demo:** Record a 15-second walkthrough of `http://localhost:3000` (search $\rightarrow$ `mcp.json` connect $\rightarrow$ live logs) and save it as `docs/demo.gif` in your public GitHub repo so it renders on both GitHub and npm:
8
+ >
9
+ > `![NexusMCP Demo](https://raw.githubusercontent.com/Anurag6212/NexusMCP/main/docs/demo.gif)`
8
10
 
9
- - **Semantic Tool Routing (`nexus_search_tools`)**: Indexes all upstream tools in memory and returns only the top relevant tools for a task, saving ~250 context tokens per filtered-out tool.
10
- - **Zero-Credential Database (OS-Native Vault)**: Secrets are stored in your OS credential layer (Windows DPAPI, macOS Keychain, Linux Secret Service) rather than SQLite, and active secret values + common token patterns (`ghp_`, `github_pat_`, `sk-`, `AKIA`, Bearer tokens) are redacted before any tool output reaches an AI model.
11
- - **`mcp.json` Control Plane**: Paste or edit standard `mcp.json` directly, or search the official MCP Registry / npm and auto-extract `mcp.json` and environment variables from repo READMEs.
12
- - **Parallel Startup & Live Diagnostics**: Connects upstream servers in parallel (`concurrency = 6`) with live progress tracking, `stderr` capture, cold-start `npx` retry, and inline missing-env Quick Fix.
13
- - **1-Click IDE Migration**: Wrap or restore `~/.cursor/mcp.json` (`nexusmcp wrap` / `nexusmcp unwrap`).
14
- - **Automatic Port Fallback**: Automatically switches to `3001+` if port `3000` is already occupied (or pass `--port <number>`).
11
+ ---
15
12
 
16
- ## Quick Start
13
+ ## The Problem NexusMCP Solves
14
+
15
+ 1. **Context Window Bloat:** Connecting 20–50 MCP servers directly to Cursor or Claude Desktop injects 300+ tool schemas into every prompt (~75,000+ wasted tokens).
16
+ 2. **Credential Trust & `.zshrc` Friction:** Cloud-hosted MCP gateways ask you to paste personal tokens onto someone else's server, while raw CLI setups force users to manually maintain `.env` / `.zshrc` files.
17
+ 3. **Opaque Startup Failures:** When an upstream `npx` or OAuth server fails, IDEs rarely surface `stderr`, cold-start delays, or missing environment variable names clearly.
18
+
19
+ ---
20
+
21
+ ## How It Works (End-to-End Flow)
22
+
23
+ ```mermaid
24
+ flowchart LR
25
+ IDE["AI IDE (Cursor / Claude / Cline)"] -- "1. SSE (/mcp/sse)" --> GW["NexusMCP Gateway"]
26
+ GW -- "2. nexus_search_tools" --> SR["In-Memory Semantic Vector Router"]
27
+ SR -- "Top-K matching tools" --> IDE
28
+ IDE -- "3. nexus_execute" --> SG["Security Gate + OS Vault"]
29
+ SG -- "4. Spawn & inject in memory" --> UP["Upstream MCPs (GitHub, Filesystem, Playwright, ...)"]
30
+ UP -- "5. PII & Token Redaction + Output Pruning" --> IDE
31
+ ```
32
+
33
+ 1. **Single Gateway Connection:** Your IDE connects only to `nexusmcp` (`http://localhost:3000/mcp/sse`), seeing 5 lightweight synthetic tools (`nexus_search_tools`, `nexus_execute`, `nexus_list_servers`, `nexus_rollback`, `nexus_diff`).
34
+ 2. **On-Demand Semantic Routing:** When your AI needs a tool, it calls `nexus_search_tools`. NexusMCP's subword cosine-similarity router returns only the top relevant tools and logs estimated schema tokens saved (~250 tokens per filtered-out tool).
35
+ 3. **Zero-Credential Database:** Secrets entered in `mcp.json` are stored in your **OS-native credential layer** (Windows DPAPI, macOS Keychain, Linux `secret-tool`)—SQLite only stores `"__OS_VAULT__"` markers.
36
+ 4. **Scoped Safety & Output Redaction:** Destructive SQL/shell commands (`DROP DATABASE`, `rm -rf`, `.env` path access) are blocked before execution, and any leaked tokens (`ghp_`, `github_pat_`, `sk-`, `AKIA`, Bearer tokens, or active vault secrets) are redacted from tool outputs before reaching the LLM.
37
+
38
+ ---
39
+
40
+ ## Quick Start (60 Seconds)
41
+
42
+ ### 1. Start NexusMCP locally
17
43
 
18
44
  ```bash
19
45
  npx -y @anurag134/nexusmcp
20
46
  ```
21
47
 
22
- Open **`http://localhost:3000`** (or the port printed in your terminal) to add servers via `mcp.json`, then connect your AI IDE to:
48
+ * Requirements: **Node.js 24+** (uses built-in `node:sqlite`).
49
+ * If port `3000` is busy, NexusMCP automatically switches to `3001+` (or pass `--port 4500`).
50
+
51
+ ### 2. Add Upstream MCPs at `http://localhost:3000`
52
+
53
+ - **Paste `mcp.json`:** Drop any standard `{ "mcpServers": { ... } }` config and click **Save & Connect All** (connects up to 6 servers in parallel with a live progress bar).
54
+ - **Search / Auto-Extract:** Type any tool name (e.g. `github`, `postgres`) or paste a GitHub repo URL—NexusMCP queries npm & `registry.modelcontextprotocol.io`, extracts the `mcp.json` + env vars from the README, and populates the editor.
55
+ - **1-Click IDE Migration:** Click **Wrap Cursor Config** (or run `npx -y @anurag134/nexusmcp wrap`) to import `~/.cursor/mcp.json` with automatic backup and restore.
56
+
57
+ ### 3. Connect Your AI IDE
58
+
59
+ Add this single entry to Cursor (`~/.cursor/mcp.json`), Claude Desktop, or VS Code Cline:
23
60
 
24
61
  ```json
25
62
  {
@@ -31,16 +68,18 @@ Open **`http://localhost:3000`** (or the port printed in your terminal) to add s
31
68
  }
32
69
  ```
33
70
 
34
- ## CLI Commands
71
+ *(Use the exact port printed in your terminal or click the SSE pill in the dashboard header to copy it.)*
35
72
 
36
- ```bash
37
- nexusmcp # Start gateway and local control plane UI
38
- nexusmcp --port 4500 # Start on a custom port
39
- nexusmcp wrap # Import ~/.cursor/mcp.json and route Cursor through NexusMCP
40
- nexusmcp unwrap # Restore original ~/.cursor/mcp.json backup
41
- nexusmcp list # List registered servers and indexed tool count
42
- ```
73
+ ---
43
74
 
44
- ## Requirements
75
+ ## CLI Reference
45
76
 
46
- - **Node.js 24+** (uses built-in `node:sqlite`)
77
+ ```bash
78
+ npx -y @anurag134/nexusmcp # Start gateway + web control plane
79
+ npx -y @anurag134/nexusmcp --port 4500 # Start on a custom port
80
+ npx -y @anurag134/nexusmcp wrap # Import ~/.cursor/mcp.json and wrap Cursor
81
+ npx -y @anurag134/nexusmcp unwrap # Restore original ~/.cursor/mcp.json backup
82
+ npx -y @anurag134/nexusmcp list # List registered servers and indexed tools
83
+ npx -y @anurag134/nexusmcp diff # Inspect git diff since last checkpoint
84
+ npx -y @anurag134/nexusmcp rollback # Roll back to latest git checkpoint
85
+ ```
package/dist/index.js CHANGED
@@ -57,7 +57,7 @@ export class Application {
57
57
  }
58
58
  return {
59
59
  port: cliPort || Number(process.env.PORT || 3000),
60
- host: process.env.HOST || "0.0.0.0",
60
+ host: process.env.HOST || "127.0.0.1",
61
61
  dbPath: process.env.DATABASE_PATH || path.join(defaultDataDir, "nexus.db"),
62
62
  configPath: process.env.CONFIG_PATH || path.join(defaultDataDir, "nexus.config.json")
63
63
  };
@@ -137,10 +137,33 @@ export class Application {
137
137
  return false;
138
138
  }
139
139
  async start() {
140
+ const isLocalOnly = this.config.host === "127.0.0.1" || this.config.host === "localhost";
140
141
  await this.server.register(cors, {
141
- origin: true,
142
+ origin: (origin, cb) => {
143
+ if (!origin || !isLocalOnly) {
144
+ cb(null, true);
145
+ return;
146
+ }
147
+ const allowed = /^https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?$/i.test(origin);
148
+ cb(allowed ? null : new Error("Origin not allowed"), allowed);
149
+ },
142
150
  methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"]
143
151
  });
152
+ if (isLocalOnly) {
153
+ this.server.addHook("onRequest", async (req, reply) => {
154
+ const remote = req.socket.remoteAddress || "";
155
+ const isLoopback = remote === "127.0.0.1" || remote === "::1" || remote === "::ffff:127.0.0.1";
156
+ if (!isLoopback) {
157
+ reply.status(403).send({ error: "Forbidden: local-only mode rejects non-loopback connections." });
158
+ return reply;
159
+ }
160
+ const hostHeader = String(req.headers.host || "");
161
+ if (hostHeader && !/^(localhost|127\.0\.0\.1)(:\d+)?$/i.test(hostHeader)) {
162
+ reply.status(403).send({ error: "Forbidden: invalid Host header." });
163
+ return reply;
164
+ }
165
+ });
166
+ }
144
167
  const mcpController = new McpController(this.mcpService);
145
168
  const upstreamController = new UpstreamController(this.upstreamService, this.db, this.securityService);
146
169
  const routerController = new RouterController(this.routerService);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@anurag134/nexusmcp",
3
3
  "mcpName": "io.github.Anurag6212/nexusmcp",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "description": "Local-first MCP Gateway & Semantic Router with OS-keychain secret storage, mcp.json control plane, and PII redaction.",
6
6
  "main": "dist/index.js",
7
7
  "type": "module",
@@ -24,7 +24,16 @@
24
24
  "url": "git+https://github.com/Anurag6212/NexusMCP.git"
25
25
  },
26
26
  "homepage": "https://github.com/Anurag6212/NexusMCP#readme",
27
- "keywords": ["mcp", "model-context-protocol", "mcp-server", "router", "gateway", "ai", "cursor", "claude"],
27
+ "keywords": [
28
+ "mcp",
29
+ "model-context-protocol",
30
+ "mcp-server",
31
+ "router",
32
+ "gateway",
33
+ "ai",
34
+ "cursor",
35
+ "claude"
36
+ ],
28
37
  "author": "Anurag6212",
29
38
  "license": "MIT",
30
39
  "dependencies": {