[firefox-devtools-mcp] restart_firefox drops the CLI prefs and env when Firefox is not running
Categories
(Developer Infrastructure :: Firefox MCP, 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.jsonpasses--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_firefoxtwice 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.
const newOptions = {
firefoxPath: resolvedFirefoxPath,
profilePath: profilePath ?? args.profilePath ?? undefined,
env: newEnv,
headless: headless ?? false,
startUrl: startUrl ?? 'about:blank',
};
Description
•