Yeachan-Heo/oh-my-codex · error · Error

Missing value for --input

Error message

Missing value for --input

What it means

While parsing MCP parity CLI args, --input must be immediately followed by its value token. If the next token is missing (end of argv), the parser throws `Missing value for --input` before attempting JSON parsing.

Source

Thrown at src/cli/mcp-parity.ts:107

export function parseMcpCliArgs(args: string[]): ParsedMcpCliArgs {
  if (args.length === 0 || args[0] === "--help" || args[0] === "-h" || args[0] === "help") {
    return { toolName: null, input: {}, json: false, help: true };
  }

  const [toolName, ...rest] = args;
  let input: Record<string, unknown> = {};
  let json = false;

  for (let i = 0; i < rest.length; i += 1) {
    const token = rest[i];
    if (token === "--json") {
      json = true;
      continue;
    }
    if (token === "--input") {
      const next = rest[i + 1];
      if (!next) throw new Error("Missing value for --input");
      input = parseInputJson(next);
      i += 1;
      continue;
    }
    if (token === "--help" || token === "-h" || token === "help") {
      return { toolName: null, input: {}, json: false, help: true };
    }
    throw new Error(`Unknown argument: ${token}`);
  }

  return { toolName, input, json, help: false };
}

function extractPayload(result: ToolHandlerResult): unknown {
  const text = result.content
    ?.filter((entry) => entry.type === "text" && typeof entry.text === "string")
    .map((entry) => entry.text as string)
    .join("\n")

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Supply the JSON value right after --input: --input '{"k":1}'
  2. Check shell variable expansion — use "${VAR:?set}" or default '{} ' so empty vars don't vanish
  3. Echo the full command before running in scripts to catch truncation

Example fix

# before (EMPTY_INPUT unset -> value disappears)
mycli t --input $EMPTY_INPUT

# after
mycli t --input "${EMPTY_INPUT:-{}}"
Defensive patterns

Strategy: validation

Validate before calling

const i = args.indexOf('--input');
if (i !== -1 && (i === args.length - 1 || args[i + 1].startsWith('--'))) {
  console.error('--input requires a JSON object value');
  process.exit(2);
}

Type guard

function hasInputValue(args: readonly string[]): boolean {
  const i = args.indexOf('--input');
  return i === -1 || (i + 1 < args.length && !args[i + 1].startsWith('--'));
}

Try / catch

try { await parseMcpCliArgs(args); }
catch (e) { if (/Missing value for --input/.test(String(e))) { printUsage(); process.exit(2); } throw e; }

Prevention

When it happens

Trigger: Invoking the command with --input as the last token, e.g. `... run-tool --input` or `... --input --json` style truncation where no following token exists (note: a following token that starts with -- would be consumed as the value here only if present; absence throws).

Common situations: Truncated command lines from copy-paste; scripts building args arrays that drop the value on empty variables ("$VAR" unquoted/unset expanding to nothing); CI pipelines with templated arguments that render empty.

Related errors


AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/f69998343d365d0f. Report an issue: GitHub.