mirror of
https://github.com/morluto/rea.git
synced 2026-11-21 22:15:50 +00:00
fix(mcp): name the HTTP option that requires --http
This commit is contained in:
1 parent
3dcd6b62e8
commit
2fbcec84eb
2 files changed
+22
-17
No files matched your search
@@ -389,7 +389,7 @@ const readMcpHttpOption = (argument: string, next: string | undefined) => {
|
||||
const readMcpHttpCommand = (
|
||||
arguments_: readonly string[],
|
||||
): McpHttpCommand | undefined => {
|
||||
let mode: "explicit" | "required" | undefined;
|
||||
let transportFlag: string | undefined;
|
||||
const values = new Map<string, string>();
|
||||
const allowedHosts: string[] = [];
|
||||
let problem: McpHttpCommandProblem | undefined;
|
||||
@@ -400,13 +400,13 @@ const readMcpHttpCommand = (
|
||||
continue;
|
||||
}
|
||||
if (argument === "--http") {
|
||||
mode = "explicit";
|
||||
transportFlag = "--http";
|
||||
continue;
|
||||
}
|
||||
const next = arguments_[index + 1];
|
||||
const { flag, inline, value } = readMcpHttpOption(argument, next);
|
||||
if (MCP_HTTP_VALUED_FLAGS.has(flag)) {
|
||||
mode ??= "required";
|
||||
transportFlag ??= flag;
|
||||
if (value === undefined) {
|
||||
problem ??= invalidMcpHttpCommand(`Missing value for ${flag}`);
|
||||
} else {
|
||||
@@ -424,10 +424,10 @@ const readMcpHttpCommand = (
|
||||
if (!argument.startsWith("-") || argument === "--") break;
|
||||
if (!inline && spacedOutputValue(flag, next) !== undefined) index += 1;
|
||||
}
|
||||
if (mode === undefined) return undefined;
|
||||
if (transportFlag === undefined) return undefined;
|
||||
if (problem !== undefined) return problem;
|
||||
if (mode === "required")
|
||||
return invalidMcpHttpCommand("--host and --port require --http");
|
||||
if (transportFlag !== "--http")
|
||||
return invalidMcpHttpCommand(`${transportFlag} requires --http`);
|
||||
return {
|
||||
kind: "listen",
|
||||
host: values.get("--host"),
|
||||
|
||||
@@ -168,17 +168,22 @@ processTest(
|
||||
processTest(
|
||||
"reports an HTTP option without its mode through the compiled CLI",
|
||||
async ({ processes }) => {
|
||||
const result = await processes.run(process.execPath, [
|
||||
fileURLToPath(new URL("../../../scripts/rea.mjs", import.meta.url)),
|
||||
"mcp",
|
||||
"--port",
|
||||
"8765",
|
||||
]);
|
||||
expect(result).toMatchObject({
|
||||
exitCode: 1,
|
||||
stdout: "",
|
||||
stderr: "--host and --port require --http\n",
|
||||
});
|
||||
for (const [flag, value] of [
|
||||
["--allowed-hosts", "localhost"],
|
||||
["--port", "8765"],
|
||||
] as const) {
|
||||
const result = await processes.run(process.execPath, [
|
||||
fileURLToPath(new URL("../../../scripts/rea.mjs", import.meta.url)),
|
||||
"mcp",
|
||||
flag,
|
||||
value,
|
||||
]);
|
||||
expect(result).toMatchObject({
|
||||
exitCode: 1,
|
||||
stdout: "",
|
||||
stderr: `${flag} requires --http\n`,
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user