@hasna/cloud 0.1.37 → 0.1.38
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/mcp/bin.js +33 -9
- package/dist/mcp/http.d.ts.map +1 -1
- package/dist/mcp/index.js +33 -9
- package/package.json +1 -1
package/dist/mcp/bin.js
CHANGED
|
@@ -27374,17 +27374,33 @@ Done. ${results.length} services, ${totalApplied} migrations applied.`);
|
|
|
27374
27374
|
// src/mcp/http.ts
|
|
27375
27375
|
var DEFAULT_MCP_HTTP_PORT = 8852;
|
|
27376
27376
|
var MCP_SERVICE_NAME = "cloud";
|
|
27377
|
+
var MIN_PORT = 0;
|
|
27378
|
+
var MAX_PORT = 65535;
|
|
27379
|
+
function invalidPortMessage(source, value) {
|
|
27380
|
+
return `Invalid ${source} "${value}". Expected an integer between ${MIN_PORT} and ${MAX_PORT}.`;
|
|
27381
|
+
}
|
|
27382
|
+
function validatePort(port, source) {
|
|
27383
|
+
if (!Number.isInteger(port) || port < MIN_PORT || port > MAX_PORT) {
|
|
27384
|
+
throw new Error(invalidPortMessage(source, String(port)));
|
|
27385
|
+
}
|
|
27386
|
+
return port;
|
|
27387
|
+
}
|
|
27388
|
+
function parsePortValue(value, source) {
|
|
27389
|
+
const trimmed = value.trim();
|
|
27390
|
+
if (!/^\d+$/.test(trimmed)) {
|
|
27391
|
+
throw new Error(invalidPortMessage(source, value));
|
|
27392
|
+
}
|
|
27393
|
+
return validatePort(Number(trimmed), source);
|
|
27394
|
+
}
|
|
27377
27395
|
function isStdioMode(argv = process.argv) {
|
|
27378
27396
|
return argv.includes("--stdio") || process.env.MCP_STDIO === "1";
|
|
27379
27397
|
}
|
|
27380
27398
|
function resolveMcpHttpPort(explicit) {
|
|
27381
|
-
if (explicit != null
|
|
27382
|
-
return explicit;
|
|
27399
|
+
if (explicit != null)
|
|
27400
|
+
return validatePort(explicit, "--port");
|
|
27383
27401
|
const env = process.env.MCP_HTTP_PORT;
|
|
27384
|
-
if (env) {
|
|
27385
|
-
|
|
27386
|
-
if (!Number.isNaN(parsed))
|
|
27387
|
-
return parsed;
|
|
27402
|
+
if (env && env.trim() !== "") {
|
|
27403
|
+
return parsePortValue(env, "MCP_HTTP_PORT");
|
|
27388
27404
|
}
|
|
27389
27405
|
return DEFAULT_MCP_HTTP_PORT;
|
|
27390
27406
|
}
|
|
@@ -27394,9 +27410,17 @@ function isHttpMode(argv = process.argv) {
|
|
|
27394
27410
|
function parseHttpArgv(argv = process.argv) {
|
|
27395
27411
|
const http = isHttpMode(argv);
|
|
27396
27412
|
let port;
|
|
27413
|
+
const portEqualsArg = argv.find((arg) => arg.startsWith("--port="));
|
|
27414
|
+
if (portEqualsArg) {
|
|
27415
|
+
port = parsePortValue(portEqualsArg.slice("--port=".length), "--port");
|
|
27416
|
+
}
|
|
27397
27417
|
const portIdx = argv.indexOf("--port");
|
|
27398
|
-
if (portIdx !== -1
|
|
27399
|
-
|
|
27418
|
+
if (portIdx !== -1) {
|
|
27419
|
+
const value = argv[portIdx + 1];
|
|
27420
|
+
if (value === undefined) {
|
|
27421
|
+
throw new Error(invalidPortMessage("--port", ""));
|
|
27422
|
+
}
|
|
27423
|
+
port = parsePortValue(value, "--port");
|
|
27400
27424
|
}
|
|
27401
27425
|
return { http, port };
|
|
27402
27426
|
}
|
|
@@ -27738,13 +27762,13 @@ Done. ${results.length} services, ${totalApplied} migrations applied.`);
|
|
|
27738
27762
|
return server;
|
|
27739
27763
|
}
|
|
27740
27764
|
async function main() {
|
|
27741
|
-
const { port } = parseHttpArgv();
|
|
27742
27765
|
if (isStdioMode()) {
|
|
27743
27766
|
const server = buildServer2();
|
|
27744
27767
|
const transport = new StdioServerTransport;
|
|
27745
27768
|
await server.connect(transport);
|
|
27746
27769
|
return;
|
|
27747
27770
|
}
|
|
27771
|
+
const { port } = parseHttpArgv();
|
|
27748
27772
|
await runMcpHttpServer({ port: resolveMcpHttpPort(port) });
|
|
27749
27773
|
}
|
|
27750
27774
|
|
package/dist/mcp/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/mcp/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAEpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,eAAO,MAAM,gBAAgB,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/mcp/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAEpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAGzE,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAuBxC,wBAAgB,WAAW,CAAC,IAAI,GAAE,MAAM,EAAiB,GAAG,OAAO,CAElE;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAO5D;AAED,wBAAgB,UAAU,CAAC,IAAI,GAAE,MAAM,EAAiB,GAAG,OAAO,CAEjE;AAED,wBAAgB,aAAa,CAAC,IAAI,GAAE,MAAM,EAAiB,GAAG;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAgB7F;AAUD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,EACnB,SAAS,GAAE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAe,GAC5D,OAAO,CAAC,IAAI,CAAC,CAUf;AAED,wBAAgB,aAAa,CAAC,IAAI,GAAE,MAAyB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAE/F;AAED,wBAAsB,kBAAkB,CAAC,OAAO,GAAE;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;CACV,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CAAC,CAuC7D;AAED,wBAAsB,gBAAgB,CAAC,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAIrF"}
|
package/dist/mcp/index.js
CHANGED
|
@@ -27413,17 +27413,33 @@ class StreamableHTTPServerTransport {
|
|
|
27413
27413
|
// src/mcp/http.ts
|
|
27414
27414
|
var DEFAULT_MCP_HTTP_PORT = 8852;
|
|
27415
27415
|
var MCP_SERVICE_NAME = "cloud";
|
|
27416
|
+
var MIN_PORT = 0;
|
|
27417
|
+
var MAX_PORT = 65535;
|
|
27418
|
+
function invalidPortMessage(source, value) {
|
|
27419
|
+
return `Invalid ${source} "${value}". Expected an integer between ${MIN_PORT} and ${MAX_PORT}.`;
|
|
27420
|
+
}
|
|
27421
|
+
function validatePort(port, source) {
|
|
27422
|
+
if (!Number.isInteger(port) || port < MIN_PORT || port > MAX_PORT) {
|
|
27423
|
+
throw new Error(invalidPortMessage(source, String(port)));
|
|
27424
|
+
}
|
|
27425
|
+
return port;
|
|
27426
|
+
}
|
|
27427
|
+
function parsePortValue(value, source) {
|
|
27428
|
+
const trimmed = value.trim();
|
|
27429
|
+
if (!/^\d+$/.test(trimmed)) {
|
|
27430
|
+
throw new Error(invalidPortMessage(source, value));
|
|
27431
|
+
}
|
|
27432
|
+
return validatePort(Number(trimmed), source);
|
|
27433
|
+
}
|
|
27416
27434
|
function isStdioMode(argv = process.argv) {
|
|
27417
27435
|
return argv.includes("--stdio") || process.env.MCP_STDIO === "1";
|
|
27418
27436
|
}
|
|
27419
27437
|
function resolveMcpHttpPort(explicit) {
|
|
27420
|
-
if (explicit != null
|
|
27421
|
-
return explicit;
|
|
27438
|
+
if (explicit != null)
|
|
27439
|
+
return validatePort(explicit, "--port");
|
|
27422
27440
|
const env = process.env.MCP_HTTP_PORT;
|
|
27423
|
-
if (env) {
|
|
27424
|
-
|
|
27425
|
-
if (!Number.isNaN(parsed))
|
|
27426
|
-
return parsed;
|
|
27441
|
+
if (env && env.trim() !== "") {
|
|
27442
|
+
return parsePortValue(env, "MCP_HTTP_PORT");
|
|
27427
27443
|
}
|
|
27428
27444
|
return DEFAULT_MCP_HTTP_PORT;
|
|
27429
27445
|
}
|
|
@@ -27433,9 +27449,17 @@ function isHttpMode(argv = process.argv) {
|
|
|
27433
27449
|
function parseHttpArgv(argv = process.argv) {
|
|
27434
27450
|
const http = isHttpMode(argv);
|
|
27435
27451
|
let port;
|
|
27452
|
+
const portEqualsArg = argv.find((arg) => arg.startsWith("--port="));
|
|
27453
|
+
if (portEqualsArg) {
|
|
27454
|
+
port = parsePortValue(portEqualsArg.slice("--port=".length), "--port");
|
|
27455
|
+
}
|
|
27436
27456
|
const portIdx = argv.indexOf("--port");
|
|
27437
|
-
if (portIdx !== -1
|
|
27438
|
-
|
|
27457
|
+
if (portIdx !== -1) {
|
|
27458
|
+
const value = argv[portIdx + 1];
|
|
27459
|
+
if (value === undefined) {
|
|
27460
|
+
throw new Error(invalidPortMessage("--port", ""));
|
|
27461
|
+
}
|
|
27462
|
+
port = parsePortValue(value, "--port");
|
|
27439
27463
|
}
|
|
27440
27464
|
return { http, port };
|
|
27441
27465
|
}
|
|
@@ -27777,13 +27801,13 @@ Done. ${results.length} services, ${totalApplied} migrations applied.`);
|
|
|
27777
27801
|
return server;
|
|
27778
27802
|
}
|
|
27779
27803
|
async function main() {
|
|
27780
|
-
const { port } = parseHttpArgv();
|
|
27781
27804
|
if (isStdioMode()) {
|
|
27782
27805
|
const server = buildServer();
|
|
27783
27806
|
const transport = new StdioServerTransport;
|
|
27784
27807
|
await server.connect(transport);
|
|
27785
27808
|
return;
|
|
27786
27809
|
}
|
|
27810
|
+
const { port } = parseHttpArgv();
|
|
27787
27811
|
await runMcpHttpServer({ port: resolveMcpHttpPort(port) });
|
|
27788
27812
|
}
|
|
27789
27813
|
export {
|
package/package.json
CHANGED