From 8dc5cf343b2fcee207fb66800348acbed7610a5f Mon Sep 17 00:00:00 2001 From: nirinchev Date: Mon, 1 Dec 2025 14:42:08 +0200 Subject: [PATCH 1/3] chore: export UserConfigSchema for consumers --- src/lib.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.ts b/src/lib.ts index babdbde7..a1d8532d 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -1,6 +1,6 @@ export { Server, type ServerOptions } from "./server.js"; export { Session, type SessionOptions } from "./common/session.js"; -export { type UserConfig } from "./common/config/userConfig.js"; +export { type UserConfig, UserConfigSchema } from "./common/config/userConfig.js"; export { LoggerBase, type LogPayload, type LoggerType, type LogLevel } from "./common/logger.js"; export { StreamableHttpRunner } from "./transports/streamableHttp.js"; export { StdioRunner } from "./transports/stdio.js"; From 7e9a0fc75cea673a0dab285cd3fb3bbce4e7b9d5 Mon Sep 17 00:00:00 2001 From: nirinchev Date: Mon, 1 Dec 2025 16:18:21 +0200 Subject: [PATCH 2/3] Use 0 as http port --- src/common/config/userConfig.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common/config/userConfig.ts b/src/common/config/userConfig.ts index 661e0046..bb52e1ea 100644 --- a/src/common/config/userConfig.ts +++ b/src/common/config/userConfig.ts @@ -113,10 +113,10 @@ export const UserConfigSchema = z4.object({ httpPort: z4.coerce .number() .int() - .min(1, "Invalid httpPort: must be at least 1") + .min(0, "Invalid httpPort: must be at least 0") .max(65535, "Invalid httpPort: must be at most 65535") .default(3000) - .describe("Port number for the HTTP server (only used when transport is 'http').") + .describe("Port number for the HTTP server (only used when transport is 'http'). Use 0 for a random port.") .register(configRegistry, { overrideBehavior: "not-allowed" }), httpHost: z4 .string() @@ -125,7 +125,7 @@ export const UserConfigSchema = z4.object({ .register(configRegistry, { overrideBehavior: "not-allowed" }), httpHeaders: z4 .object({}) - .passthrough() + .loose() .default({}) .describe( "Header that the HTTP server will validate when making requests (only used when transport is 'http')." From 71ead0b27cc35b4a3b5b1984f8c246778f8000d9 Mon Sep 17 00:00:00 2001 From: nirinchev Date: Mon, 1 Dec 2025 17:26:19 +0200 Subject: [PATCH 3/3] fix test --- tests/unit/common/config.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/common/config.test.ts b/tests/unit/common/config.test.ts index c5f537d2..a8cd5f18 100644 --- a/tests/unit/common/config.test.ts +++ b/tests/unit/common/config.test.ts @@ -690,17 +690,17 @@ describe("config", () => { }); describe("httpPort", () => { - it("must be above 1", () => { + it("must be above 0", () => { const onErrorFn = vi.fn(); const onExitFn = vi.fn(); createUserConfig({ onError: onErrorFn, closeProcess: onExitFn, - cliArguments: ["--httpPort", "0"], + cliArguments: ["--httpPort", "-1"], }); expect(onErrorFn).toBeCalledWith( expect.stringContaining( - "Invalid configuration for the following fields:\nhttpPort - Invalid httpPort: must be at least 1" + "Invalid configuration for the following fields:\nhttpPort - Invalid httpPort: must be at least 0" ) ); expect(onExitFn).toBeCalledWith(1);