@anurag134/nexusmcp 1.0.1 → 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.
- package/dist/index.js +25 -2
- package/package.json +1 -1
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 || "
|
|
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:
|
|
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.
|
|
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",
|