mirror of
https://github.com/morluto/rea.git
synced 2026-10-27 01:45:32 +00:00
refactor(config): share HTTP listener port contract
This commit is contained in:
1 parent
ce5bc8cb01
commit
dd46a13dec
3 files changed
+8
-11
No files matched your search
@@ -11,6 +11,7 @@ import { logCliCommand } from "../cliLogging.js";
|
||||
import { parseEnvironmentName } from "../config/environmentName.js";
|
||||
import {
|
||||
parseMcpHttpEndpoint,
|
||||
mcpHttpListenerPortSchema,
|
||||
type McpHttpEndpoint,
|
||||
} from "../config/mcpHttpEndpoint.js";
|
||||
import type { AnalysisError } from "../domain/analysisErrorBase.js";
|
||||
@@ -364,11 +365,7 @@ export const registerEnvironmentCommands = (
|
||||
.min(1)
|
||||
.optional()
|
||||
.describe("Listener address; default MCP_HOST, else 127.0.0.1"),
|
||||
port: z
|
||||
.number()
|
||||
.int()
|
||||
.min(0)
|
||||
.max(65535)
|
||||
port: mcpHttpListenerPortSchema
|
||||
.optional()
|
||||
.describe(
|
||||
"Listener port; default MCP_PORT, else 0 for an ephemeral port",
|
||||
|
||||
@@ -11,12 +11,15 @@ export const DEFAULT_MCP_HTTP_HOST = "127.0.0.1";
|
||||
/** Port 0 asks the host for an ephemeral port, reported by the listening log line. */
|
||||
export const DEFAULT_MCP_HTTP_PORT = 0;
|
||||
|
||||
/** A listener may request an ephemeral port with 0; connected endpoints may not. */
|
||||
export const mcpHttpListenerPortSchema = z.number().int().min(0).max(65535);
|
||||
|
||||
/** Decimal TCP port text, shared by the `--port` flag and `MCP_PORT`. */
|
||||
export const mcpHttpPortSchema = z
|
||||
.string()
|
||||
.regex(/^(?:0|[1-9]\d*)$/u)
|
||||
.transform(Number)
|
||||
.pipe(z.number().int().min(0).max(65535));
|
||||
.pipe(mcpHttpListenerPortSchema);
|
||||
|
||||
const mcpHttpHostSchema = z.string().trim().min(1);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Help, z } from "incur";
|
||||
|
||||
import {
|
||||
MCP_HTTP_PORT_CONSTRAINT,
|
||||
mcpHttpListenerPortSchema,
|
||||
mcpHttpPortSchema,
|
||||
} from "../config/mcpHttpEndpoint.js";
|
||||
|
||||
@@ -18,11 +19,7 @@ const MCP_HTTP_OPTIONS = z.object({
|
||||
.min(1)
|
||||
.optional()
|
||||
.describe("Listener address; default MCP_HOST, else 127.0.0.1"),
|
||||
port: z
|
||||
.number()
|
||||
.int()
|
||||
.min(0)
|
||||
.max(65535)
|
||||
port: mcpHttpListenerPortSchema
|
||||
.optional()
|
||||
.describe("Listener port; default MCP_PORT, else 0 for an ephemeral port"),
|
||||
help: z.boolean().optional().describe("Show help"),
|
||||
|
||||
Reference in new issue
Block a user