Open Bug 2091473 Opened 7 days ago

[firefox-devtools-mcp] restart_firefox drops the CLI prefs and env when Firefox is not running

Categories

(Developer Infrastructure :: Firefox MCP, defect)

defect

Tracking

(Not tracked)

People

(Reporter: jdescottes, Unassigned)

References

Details

restart_firefox should keep the launch options from the command line (--pref, --env, --headless, ...) and only change what it is given. But when no browser is running, it builds a new config with only the binary, profile, env, headless flag and start URL from the call.

STRs:

  • start the server with ./mach firefox-devtools-mcp (the in-tree .mcp.json passes --pref remote.prefs.recommended=false)
  • before any other tool call, call restart_firefox(env=["MOZ_REMOTE_ALLOW_SYSTEM_ACCESS=1"])
  • call get_firefox_info

ER: the prefs from .mcp.json are still set
AR: no prefs. --env, --headless, --viewport, --firefox-arg, --accept-insecure-certs and --output-file are all dropped

This is the first step our docs suggest for privileged access, so it is easy to hit.

Note: the same root cause gives two more cases:

  • calling restart_firefox twice before the next tool call: the second call goes through the same branch and drops the first one's config
  • after a lost connection, getFirefox() rebuilds the config from the CLI args, so the prefs and env set by earlier restarts are lost

Possible fix: keep a single launch config in src/index.ts, built from the CLI args at startup. getFirefox() always launches with it, and restart_firefox always merges into it. This removes the "not running" branch and nextLaunchOptions.

See https://github.com/mozilla/firefox-devtools-mcp/blob/a1b4ef0606f7a71a2f5e734707ed0c93a7bc10c7/src/tools/firefox-launch.ts#L189-L197

    const newOptions = {
      firefoxPath: resolvedFirefoxPath,
      profilePath: profilePath ?? args.profilePath ?? undefined,
      env: newEnv,
      headless: headless ?? false,
      startUrl: startUrl ?? 'about:blank',
    };
You need to log in before you can comment on or make changes to this bug.