diff --git a/.claude-plugin/COWORK.md b/.claude-plugin/COWORK.md index a9374623..3d59231e 100644 --- a/.claude-plugin/COWORK.md +++ b/.claude-plugin/COWORK.md @@ -2,7 +2,7 @@ ## Prerequisites -- **Firefox** 120+ installed +- **Firefox** 153+ installed - **Node.js 20.19.0+** (includes npm) — required to run the MCP server. Download from [nodejs.org](https://nodejs.org). ## Installation Steps diff --git a/.claude-plugin/README.md b/.claude-plugin/README.md index 6eaac52c..beb420e1 100644 --- a/.claude-plugin/README.md +++ b/.claude-plugin/README.md @@ -88,12 +88,12 @@ The plugin works automatically when you ask about browser tasks: The plugin enables the following by default: -- **`--enable-script`** — enables JavaScript evaluation and debugging tools (`evaluate_script`, logpoints, script inspection). Requires Firefox 153+. +- **`--enable-script`** — enables JavaScript evaluation and debugging tools (`evaluate_script`, logpoints, script inspection). - **`remote.prefs.recommended=false`** — skips WebDriver's automation preferences so Firefox behaves closer to a regular browser session. See [RecommendedPreferences](https://searchfox.org/firefox-main/source/remote/shared/RecommendedPreferences.sys.mjs) for what those preferences do. ## Requirements -- Firefox 153+ (for script tools) or Firefox 120+ (without script tools) +- Firefox 153+ - Node.js 20.19.0+ ## Links diff --git a/README.md b/README.md index 7dd6bc31..04d4b6fe 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ See [SECURITY.md](SECURITY.md) for a full breakdown of risks and how to report v ## Requirements - Node.js ≥ 20.19.0 -- Firefox 100+ installed (auto‑detected, or pass `--firefox-path`) +- Firefox 153+ installed (auto‑detected, or pass `--firefox-path`) ## Install and use with Claude Code or Codex (npx) diff --git a/docs/tools.md b/docs/tools.md index 7ef243f9..a325458d 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -71,7 +71,7 @@ accepted paths. - [profiler](#profiler): Start, stop, and query the performance profiler. - [screencast](#screencast): Record screencasts of the page viewport (Firefox 154+). - [script](#script): Evaluate arbitrary JavaScript in the page context. -- [debugging](#debugging): Inspect scripts and set logpoints (Firefox 153+). +- [debugging](#debugging): Inspect scripts and set logpoints. - [prefs](#prefs): Get and set Firefox preferences. - [privileged](#privileged): Access privileged ("chrome") browsing contexts. - [bidi](#bidi): Send raw WebDriver BiDi commands. @@ -607,11 +607,11 @@ Parameters: ## debugging -Inspect scripts and set logpoints (Firefox 153+). +Inspect scripts and set logpoints. ### `enable_debugger` -Enable the JS debugger for the current page. Required before set_logpoint works. Requires Firefox 153+. +Enable the JS debugger for the current page. Required before set_logpoint works. No parameters. diff --git a/src/cli.ts b/src/cli.ts index 421bd95c..8e739f48 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -200,8 +200,7 @@ export const cliOptions = { }, enableScript: { type: 'boolean', - description: - 'Deprecated: use --tools/--tool-preset. Enable the script and debugging tools (Firefox 153+ required).', + description: 'Deprecated: use --tools/--tool-preset. Enable the script and debugging tools.', default: (process.env.ENABLE_SCRIPT ?? 'false') === 'true', }, enablePrivilegedContext: { diff --git a/src/firefox/index.ts b/src/firefox/index.ts index d0f7cf0a..3bb02b4c 100644 --- a/src/firefox/index.ts +++ b/src/firefox/index.ts @@ -22,6 +22,7 @@ import { PageManagement } from './pages.js'; import { CacheManagement, type CacheBehavior } from './cache.js'; import { SnapshotManager, type Snapshot, type SnapshotOptions } from './snapshot/index.js'; import type { ResolvedElement } from './snapshot/resolver.js'; +import { assertSupportedFirefoxVersion } from '../utils/version.js'; /** * Main Firefox Client facade @@ -77,7 +78,9 @@ export class FirefoxClient { * Connect and initialize all modules */ async connect(): Promise { - this.bidi = new BiDiFacade(await this.core.connect()); + const driver = await this.core.connect(); + assertSupportedFirefoxVersion(this.core.getFirefoxVersion()); + this.bidi = new BiDiFacade(driver); // Firefox creates a dedicated user context for sessions started at runtime, // and reports it with this capability. const userContext = this.core.getCapabilities().get('moz:userContext') as string | undefined; diff --git a/src/tools/debugging.ts b/src/tools/debugging.ts index 4bf7b61c..e9bcd12d 100644 --- a/src/tools/debugging.ts +++ b/src/tools/debugging.ts @@ -1,20 +1,8 @@ import { successResponse, errorResponse } from '../utils/response-helpers.js'; -import { compareVersions } from '../utils/version.js'; import { remoteValueToNative } from '../utils/remote-value.js'; import { defineModule, defineToolHandler, type ToolDefinition } from './module.js'; import type { McpToolResponse } from '../types/common.js'; -const MIN_VERSION = '153'; - -function requireDebuggingSupport(firefox: { getFirefoxVersion(): string | null }): void { - const version = firefox.getFirefoxVersion(); - if (version !== null && compareVersions(version, MIN_VERSION) < 0) { - throw new Error( - `moz:debugging requires Firefox ${MIN_VERSION}+, current version is ${version}` - ); - } -} - function requireContext(contextId: string | null): string { if (!contextId) { throw new Error('No active browsing context'); @@ -28,8 +16,7 @@ function requireContext(contextId: string | null): string { export const enableDebuggerTool = { name: 'enable_debugger', - description: - 'Enable the JS debugger for the current page. Required before set_logpoint works. Requires Firefox 153+.', + description: 'Enable the JS debugger for the current page. Required before set_logpoint works.', annotations: { readOnlyHint: false, }, @@ -121,7 +108,6 @@ export const handleEnableDebugger = defineToolHandler async (_args): Promise => { const { getFirefox } = await import('../index.js'); const firefox = await getFirefox(); - requireDebuggingSupport(firefox); await firefox.sendBiDiCommand('moz:debugging.setDebuggerEnabled', { enabled: true }); return successResponse('Debugger enabled'); }, @@ -132,7 +118,6 @@ export const handleListScripts = defineToolHandler( async (_args): Promise => { const { getFirefox } = await import('../index.js'); const firefox = await getFirefox(); - requireDebuggingSupport(firefox); const contextId = requireContext(firefox.getCurrentContextId()); const result = await firefox.sendBiDiCommand('moz:debugging.listScripts', { context: contextId, @@ -151,7 +136,6 @@ export const handleGetScriptSource = defineToolHandler( const { url, line, expression } = args; const { getFirefox } = await import('../index.js'); const firefox = await getFirefox(); - requireDebuggingSupport(firefox); const logpointId = await firefox.setLogpoint(url, line, expression); return successResponse(`Logpoint set (id: ${logpointId})`); }, @@ -179,7 +162,6 @@ export const handleRemoveLogpoint = defineToolHandler const { logpoint } = args; const { getFirefox } = await import('../index.js'); const firefox = await getFirefox(); - requireDebuggingSupport(firefox); await firefox.removeLogpoint(logpoint); return successResponse('Logpoint removed'); }, @@ -191,7 +173,6 @@ export const handleGetLogpointResults = defineToolHandler { describe('compareVersions', () => { @@ -30,4 +30,17 @@ describe('Version helpers', () => { expect(() => compareVersions('153.0', '')).toThrow('Unable to parse Firefox version'); }); }); + + describe('assertSupportedFirefoxVersion', () => { + it('should throw for a version older than 153', () => { + expect(() => assertSupportedFirefoxVersion('152.0.1')).toThrow( + 'Firefox 152.0.1 is not supported. Firefox MCP requires Firefox 153 or later.' + ); + }); + it('should accept 153 and later, or an unknown version', () => { + expect(() => assertSupportedFirefoxVersion('153.0esr')).not.toThrow(); + expect(() => assertSupportedFirefoxVersion('161.0a1')).not.toThrow(); + expect(() => assertSupportedFirefoxVersion(null)).not.toThrow(); + }); + }); });