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

Conflicting setup MCP mode flags: ${source} selects ${next},

Error message

Conflicting setup MCP mode flags: ${source} selects ${next}, but another flag already selected ${value}

What it means

MCP mode flags (--mcp, --no-mcp, --mcp=<mode>) are mutually exclusive; selecting a second, different mode after one is already set throws this error.

Source

Thrown at src/cli/index.ts:625

      const next = arg.slice("--install-mode=".length);
      if (next !== "legacy" && next !== "plugin") {
        throw new Error(
          `Invalid setup install mode: ${next}. Expected one of: legacy, plugin`,
        );
      }
      setValue(next, "--install-mode");
    }
  }

  return value;
}


export function resolveSetupMcpModeArg(args: string[]): SetupMcpMode | undefined {
  let value: SetupMcpMode | undefined;
  const setValue = (next: SetupMcpMode, source: string): void => {
    if (value && value !== next) {
      throw new Error(
        `Conflicting setup MCP mode flags: ${source} selects ${next}, but another flag already selected ${value}`,
      );
    }
    value = next;
  };
  const parseValue = (next: string): SetupMcpMode => {
    if (!SETUP_MCP_MODES.includes(next as SetupMcpMode)) {
      throw new Error(
        `Invalid setup MCP mode: ${next}. Expected one of: none, compat`,
      );
    }
    return next as SetupMcpMode;
  };

  for (let index = 0; index < args.length; index += 1) {
    const arg = args[index];
    if (arg === "--no-mcp") {
      setValue("none", arg);

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Provide exactly one MCP mode selection
  2. Use --mcp=<mode> once instead of mixing shorthand flags

Example fix

# before
omx setup --no-mcp --mcp compat
# after
omx setup --mcp=compat
Defensive patterns

Strategy: validation

Validate before calling

const mcpFlags = args.filter(a => a === '--mcp' || a === '--no-mcp' || a.startsWith('--mcp='));
if (mcpFlags.length > 1) throw new Error('conflicting MCP flags');

Type guard

const isSetupMcpMode = (v: string): v is SetupMcpMode => ['none','compat'].includes(v);

Try / catch

catch (e) { if (/Conflicting setup MCP mode/.test(e.message)) /* keep single --mcp=mode */ }

Prevention

When it happens

Trigger: `omx setup --mcp none --mcp compat` or `--no-mcp --mcp compat`.

Common situations: Composed setup scripts layering defaults over user args; alias commands that inject extra MCP flags.

Related errors


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