Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/common/config/userConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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')."
Expand Down
2 changes: 1 addition & 1 deletion src/lib.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/common/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<CreateUserConfigHelpers["closeProcess"]>();
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);
Expand Down