{"record":{"id":"78e3e1214c7b985c","repo":"Yeachan-Heo/oh-my-codex","slug":"unknown-argument-token","errorCode":null,"errorMessage":"Unknown argument: ${token}","messagePattern":"Unknown argument: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/cli/mcp-parity.ts","lineNumber":115,"sourceCode":"  let json = false;\n\n  for (let i = 0; i < rest.length; i += 1) {\n    const token = rest[i];\n    if (token === \"--json\") {\n      json = true;\n      continue;\n    }\n    if (token === \"--input\") {\n      const next = rest[i + 1];\n      if (!next) throw new Error(\"Missing value for --input\");\n      input = parseInputJson(next);\n      i += 1;\n      continue;\n    }\n    if (token === \"--help\" || token === \"-h\" || token === \"help\") {\n      return { toolName: null, input: {}, json: false, help: true };\n    }\n    throw new Error(`Unknown argument: ${token}`);\n  }\n\n  return { toolName, input, json, help: false };\n}\n\nfunction extractPayload(result: ToolHandlerResult): unknown {\n  const text = result.content\n    ?.filter((entry) => entry.type === \"text\" && typeof entry.text === \"string\")\n    .map((entry) => entry.text as string)\n    .join(\"\\n\")\n    .trim() ?? \"\";\n\n  if (!text) return {};\n  try {\n    return JSON.parse(text);\n  } catch {\n    return text;\n  }","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/mcp-parity.ts#L97-L133","documentation":"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>`.","triggerScenarios":"Passing flags like --verbose, --tool, -t, or a second positional argument to the parity command, e.g. `mcp run-tool list --json extra`.","commonSituations":"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.","solutions":["Run with --help to print the accepted arguments for this command","Remove the unrecognized token; only [toolName] [--json] [--input <json>] are valid","If you meant a subcommand of another command, re-check the top-level routing"],"exampleFix":"# before\nmycli mcp run-tool --verbose search --json\n\n# after\nmycli mcp run-tool search --json","handlingStrategy":"validation","validationCode":"const ALLOWED = new Set(['--json', '--input', '--help', '-h', 'help']);\nconst bad = args.filter((a, i) => !ALLOWED.has(a) && !(i > 0 && args[i - 1] === '--input') && i > 0);\nif (bad.length) { console.error(`Unknown argument: ${bad[0]}`); process.exit(2); }","typeGuard":"function isKnownParityToken(tok: string): boolean {\n  return !tok.startsWith('-') || ['--json', '--input', '--help', '-h'].includes(tok);\n}","tryCatchPattern":"try { await executeDescriptorCommand(...); }\ncatch (e) { if (/Unknown argument:/.test(String(e))) { printHelp(); process.exit(2); } throw e; }","preventionTips":["Run --help before scripting new flags","Keep a single source of truth for supported flags in wrappers"],"tags":["cli","argument-validation","usage"],"backgroundTag":"invalid-cli-argument","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}