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

Unknown argument: ${token}

Error message

Unknown argument: ${token}

What it means

The MCP parity arg parser accepts only a tool name (first positional), --json, --input <json>, and --help/-h/help. Any other token throws `Unknown argument: <token>`.

Source

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

  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")
    .trim() ?? "";

  if (!text) return {};
  try {
    return JSON.parse(text);
  } catch {
    return text;
  }

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Run with --help to print the accepted arguments for this command
  2. Remove the unrecognized token; only [toolName] [--json] [--input <json>] are valid
  3. If you meant a subcommand of another command, re-check the top-level routing

Example fix

# before
mycli mcp run-tool --verbose search --json

# after
mycli mcp run-tool search --json
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = new Set(['--json', '--input', '--help', '-h', 'help']);
const bad = args.filter((a, i) => !ALLOWED.has(a) && !(i > 0 && args[i - 1] === '--input') && i > 0);
if (bad.length) { console.error(`Unknown argument: ${bad[0]}`); process.exit(2); }

Type guard

function isKnownParityToken(tok: string): boolean {
  return !tok.startsWith('-') || ['--json', '--input', '--help', '-h'].includes(tok);
}

Try / catch

try { await executeDescriptorCommand(...); }
catch (e) { if (/Unknown argument:/.test(String(e))) { printHelp(); process.exit(2); } throw e; }

Prevention

When it happens

Trigger: Passing flags like --verbose, --tool, -t, or a second positional argument to the parity command, e.g. `mcp run-tool list --json extra`.

Common situations: Assuming flags from the main CLI apply here; typo'd flag names; leftover debug flags in scripts; version drift where a flag was renamed or removed.

Related errors


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