Skip to content

refactor: extract worker logic into McpWorker - #2800

Merged
OrKoN merged 1 commit into
ChromeDevTools:mainfrom
gunjanjaswal:feat/2434-mcp-worker-abstraction
Oct 1, 2026
Merged

OrKoN merged 1 commit into
ChromeDevTools:mainfrom
gunjanjaswal:feat/2434-mcp-worker-abstraction

Conversation

@gunjanjaswal

Copy link
Copy Markdown
Contributor

Closes #2434.

Worker handling reached through Puppeteer targets directly: the context stored plain ExtensionServiceWorker objects, kept their ids in a side WeakMap, and callers such as the script evaluator resolved target.worker() themselves. This introduces an McpWorker class that mirrors McpPage, wrapping a worker target together with its stable id, type, url, and a lazy worker() accessor, so dedicated and service workers can share a single representation.

What changed

  • New src/McpWorker.ts with an McpWorker class and a WorkerType (service_worker | dedicated_worker | shared_worker), plus a small per-type id prefix so ids never collide across types.
  • McpContext snapshots into McpWorker instances via getWorkers() / createWorkersSnapshot(). The id now lives on the worker, so the separate getExtensionServiceWorkerId() lookup is gone.
  • ServiceWorkerConsoleCollector, the browser_evaluate_script worker resolver, and the extension-service-worker response section consume the abstraction. The response filters by type === 'service_worker', so the "Extension Service Workers" listing stays correct once other worker types start appearing.
  • ExtensionServiceWorker removed from types.ts.

Scope

No behavior change: the snapshot still tracks only extension service workers, and the sw-N id scheme is preserved (existing tests exercise the same ids). This is deliberately just the abstraction — surfacing dedicated workers is left to #2352, which should rebase cleanly on top.

tsc, eslint, and prettier are clean, and the build passes.

@gunjanjaswal gunjanjaswal changed the title Extract worker logic into McpWorker (#2434) refactor: extract worker logic into McpWorker Sep 22, 2026
Comment thread src/McpWorker.ts Resolved

@OrKoN OrKoN left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The PR is a clean step toward decoupling worker consumers from raw Puppeteer Target objects and preparing for dedicated/shared workers (#2352). However, several design inconsistencies with McpPage, state caching issues, and missing unit tests should be addressed before merging.


1. Design & Architectural Issues

A. McpWorker instances are recreated on every snapshot instead of cached (unlike McpPage)

  • Where: src/McpContext.ts (createWorkersSnapshot)

  • Issue: The commit description states:

    "Worker handling used raw Puppeteer targets directly: the context stored plain ExtensionServiceWorker objects, tracked their ids in a side WeakMap... This adds an McpWorker class mirroring McpPage"

    However, McpContext still keeps a side WeakMap<Target, string> (#workerIdMap) and instantiates new McpWorker(id, 'service_worker', target) on every call to createWorkersSnapshot().

  • Why it matters:

    1. In McpContext.#createMcpPage, McpPage instances are stored in #mcpPages = new Map<Page, McpPage>() and reused across snapshots until disposed.
    2. Recreating McpWorker on every snapshot breaks referential identity (workerA === workerB) across snapshots and prevents McpWorker from ever holding per-worker state (such as console/network collectors, attached CDP sessions, or lifecycle listeners) as #2352 progresses.
    3. Fix: Replace #workerIdMap = new WeakMap<Target, string>() with #workers = new Map<Target, McpWorker>() (or cache McpWorker in a WeakMap<Target, McpWorker>), reusing existing McpWorker instances on subsequent snapshots and pruning closed targets—just like #mcpPages.

B. Redundant #url snapshot field on McpWorker

  • Where: src/McpWorker.ts (constructor & get url())
  • Issue: McpWorker retains #target: Target and also copies this.#url = target.url() in the constructor.
  • Why it matters: target.url() in Puppeteer is already a synchronous getter reading from the target's TargetInfo. Caching #url separately duplicates state and will become stale if McpWorker instances are cached across snapshots or if a target's URL updates after initial target creation. get url(): string can simply return this.#target.url().

C. Contradictory ID prefix comment vs. shared #nextWorkerId counter

  • Where: src/McpWorker.ts (WORKER_ID_PREFIX) and src/McpContext.ts (#nextWorkerId)
  • Issue: The JSDoc in src/McpWorker.ts says:
    /**
     * Short, human-readable id prefix per worker type, e.g. `sw-1`. Keyed by type
     * so a dedicated worker never collides with a service worker in the same id
     * space.
     */
    Yet McpContext uses a single shared counter (#nextWorkerId = 1), which would produce sw-1, dw-2, sw-3 (they could never collide anyway because the counter is shared, while per-type sequences become non-contiguous).
  • Also note: nextPageId in McpContext.ts is module-scoped so IDs are not reused across browser reconnects. #nextWorkerId is an instance field on McpContext, meaning sw-1 will be re-issued after a reconnect.

D. Inconsistent worker.type filtering between McpResponse and script.ts

  • Where: src/McpResponse.ts vs. src/tools/script.ts (getWebWorker)
  • Issue: McpResponse was updated to filter .filter(worker => worker.type === 'service_worker') "so the 'Extension Service Workers' listing stays correct as other worker types join."
    However, getWebWorker(context, serviceWorkerId) in src/tools/script.ts (which backs the serviceWorkerId parameter of evaluate_script, only exposed when categoryExtensions is enabled) does not filter by worker.type === 'service_worker', while still throwing 'Service worker not found.'.
  • Suggestion: Also consider adding a getWorkerById(id: string): McpWorker | undefined helper on McpContext (mirroring getPageById) instead of repeating .getWorkers().find(w => w.id === ...) in tool handlers.

2. Testing & Code Hygiene (AGENTS.md compliance)

  1. Zero unit tests for McpWorker and McpResponse filtering:
    • Per AGENTS.md:
      • Core classes should have mock-based unit tests (tests/McpWorker.test.ts testing workerIdPrefix, url, and worker() coercion of null → undefined).
      • McpResponse's new .filter(worker => worker.type === 'service_worker') behavior is untested—there should be a unit test in tests/McpResponse.test.ts verifying that dedicated_worker / shared_worker entries in context.getWorkers() are excluded from ## Extension Service Workers and structuredContent.extensionServiceWorkers.
      • Add a createMockMcpWorker factory in tests/mocks.ts alongside createMockMcpPage.
  2. Copyright year in src/McpWorker.ts:
    • src/McpWorker.ts uses Copyright 2025 Google LLC instead of Copyright 2026 Google LLC (per AGENTS.md).
  3. Unnecessary async on createWorkersSnapshot():
    • createWorkersSnapshot(): Promise<McpWorker[]> contains no await expressions (this.browser.targets() is synchronous). Unless an await is needed soon, returning McpWorker[] synchronously (or documenting why it returns a Promise) avoids unnecessary async ceremony.

@gunjanjaswal

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review — all addressed in the latest push.

1A — McpWorker now cached across snapshots. Replaced the side WeakMap<Target,string> with #workers = new Map<Target, McpWorker>(), reusing the existing instance per target and pruning gone targets, exactly like #mcpPages. Referential identity holds now, and it's ready to carry per-worker state (collectors/sessions) as #2352 lands.

1B — dropped the cached #url. get url() reads through to this.#target.url(), so it can't go stale.

1C — id counter is module-scoped now (like nextPageId), with a resetWorkerIdsForTesting() to match, so ids aren't reused across reconnects. Reworded the prefix comment: the prefix just labels the type, and the shared counter keeps ids globally unique — I didn't switch to per-type sequences since, as you noted, they can't collide anyway.

1D — added getWorkerById(id) mirroring getPageById, and getWebWorker in script.ts uses it instead of repeating the find. On the type filtering: I kept the service_worker filter specific to the "Extension Service Workers" listing (that heading is service-worker-only), while id lookup stays type-agnostic since the id space is shared — happy to tighten getWebWorker to service workers if you'd prefer once dedicated workers actually surface.

2.3 — createWorkersSnapshot() is synchronous now (no awaited work); updated the callers.

2.2 — copyright year fixed to 2026.

2.1 — tests added. tests/McpWorker.test.ts covers workerIdPrefix, the live url, and worker() coercing null → undefined. I extracted selectExtensionServiceWorkers so the response's type filter is unit-tested (dedicated/shared excluded) without needing a live browser — the full response path can't produce dedicated workers yet. Added a createMockMcpWorker factory in tests/mocks.ts alongside createMockMcpPage.

Typecheck, eslint, and prettier are clean.

@OrKoN
OrKoN self-requested a review September 23, 2026 06:09

@OrKoN OrKoN left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor improvements:

  • Replace the hand-rolled fakeTarget helper and as unknown as Target / as WebWorker type casts in tests/McpWorker.test.ts and tests/mocks.ts with sinon.createStubInstance(Target), sinon.createStubInstance(WebWorker), and sinon.createStubInstance(McpWorker) (re-exporting Target and WebWorker values from src/third_party/index.ts and including afterEach(() => sinon.restore())). AGENTS.md forbids as type casts and hand-rolled fake* objects, requiring all mocks to be centralized in tests/mocks.ts via sinon.createStubInstance().
  • Inline selectExtensionServiceWorkers in src/McpResponse.ts and test McpResponse.prototype.handle directly in tests/McpResponse.test.ts by stubbing context.getWorkers.returns([sw, dw, shw]) on createMockMcpContext() with response.setIncludeExtensionServiceWorkers(true). tests/McpResponse.test.ts already uses MockMcpContext, so both the ## Extension Service Workers markdown section and structuredContent.extensionServiceWorkers can be tested without exporting a test-only helper.
  • Check serviceWorker.type === 'service_worker' in getWebWorker (src/tools/script.ts) alongside if (!serviceWorker). Since serviceWorkerId specifically targets extension service workers and McpResponse now filters worker.type === 'service_worker', getWebWorker should reject non-service-worker IDs consistently.

@gunjanjaswal

gunjanjaswal commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks — all three done in the latest push.

Sinon stubs instead of hand-rolled fakes/casts. Added createMockTarget() and createMockWebWorker() to tests/mocks.ts and routed createMockMcpWorker and McpWorker.test.ts through them, so the test files have no fakeTarget and no as casts. afterEach(() => sinon.restore()) is in. One detail worth noting: Target/WebWorker are abstract (Target.prototype has no url), so createStubInstance(Target) can't stub it, and a SinonStubbedInstance<CdpTarget> isn't nominally assignable to Target. I handled it the same way createMockPuppeteerPage already does — stub the concrete CdpTarget/WebWorker and bridge with a single as unknown as contained in mocks.ts — rather than introduce a new pattern. Re-exported CdpTarget and WebWorker as values for that.

Inlined the helper + test through handle. Removed selectExtensionServiceWorkers, put the type === 'service_worker' filter back inline in format, and added setIncludeExtensionServiceWorkers. The test now stubs context.getWorkers.returns([sw, dw, shw]) on createMockMcpContext(), calls response.handle(context), and asserts both the ## Extension Service Workers section and structuredContent.extensionServiceWorkers contain only the service worker.

getWebWorker type guard. It now rejects an id whose worker isn't a service_worker, consistent with the response filter.

@gunjanjaswal

Copy link
Copy Markdown
Contributor Author

Gentle nudge on this whenever you have time, @OrKoN. I worked through the last round (the alignment with McpPage, the cached/pruned worker snapshot, and the unit tests), and left a note earlier on why sinon.createStubInstance doesn't apply cleanly to the abstract Target/WebWorker classes, along with the concrete-mock approach I used instead in mocks.ts.

The branch has since drifted behind main and picked up a merge conflict. Rather than rebase repeatedly while it waits, I'll do it in one clean pass the moment you're ready to take another look — just say the word and I'll have it green.

@OrKoN

OrKoN commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

@gunjanjaswal please re-request the review if comments are addressed so that it shows up in the dashboard. I think the branch requires another rebase.

@OrKoN OrKoN left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I think we need the following changes:

  • Call McpContext.resetWorkerIdsForTesting() alongside McpContext.resetPageIdsForTesting() in withMcpContext (tests/utils.ts). Without resetting nextWorkerId between tests, list pages for side panels with --category-extensions (tests/tools/pages.test.ts) assigns sw-2 instead of sw-1 and fails in CI.
  • Rebase onto main and reuse the existing MockTarget / createMockPuppeteerTarget in tests/mocks.ts (plus a MockWebWorker extends WebWorker subclass for createMockWebWorker) instead of exporting CdpTarget and using as unknown as casts in tests/mocks.ts and tests/McpResponse.test.ts. main already subclasses Target in tests/mocks.ts to stub abstract Puppeteer classes without as type casts, which are prohibited by AGENTS.md.
  • Delete destroyed worker targets in #onTargetDestroyed (this.#workers.delete(target)) and clear this.#workers.clear() in dispose() (src/McpContext.ts). This mirrors #mcpPages lifecycle cleanup so getWorkers() and getWorkerById() do not return destroyed workers between createWorkersSnapshot() calls.

@gunjanjaswal

Copy link
Copy Markdown
Contributor Author

Thanks @OrKoN, all three are clear:

  1. resetWorkerIdsForTesting() in withMcpContext alongside resetPageIdsForTesting().
  2. Rebase onto main and move the mocks to your MockTarget / createMockPuppeteerTarget, plus a MockWebWorker extends WebWorker for createMockWebWorker, dropping the as unknown as casts.
  3. this.#workers.delete(target) in #onTargetDestroyed and this.#workers.clear() in dispose().

One thing the rebase surfaces that's worth naming: since I opened this, main has grown new consumers of getExtensionServiceWorkers() / getExtensionServiceWorkerId() — the serviceWorkerId lookup in tools/script.ts and the extension-SW inclusion in McpResponse — and this PR replaces that API with getWorkers() / getWorkerById(). Since McpWorker already carries id/url/target, I'll migrate those consumers over as a drop-in so everything lands on the one abstraction. Shout if you'd rather keep getExtensionServiceWorkers() as a thin wrapper instead; otherwise I'll fold them in and re-request review once it's green.

@OrKoN

OrKoN commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

@gunjanjaswal it does not appear to be rebased nevermind, migrating new consumers SG! thanks!

@gunjanjaswal
gunjanjaswal force-pushed the feat/2434-mcp-worker-abstraction branch from 7c7cf90 to 62233d6 Compare September 30, 2026 10:01
@gunjanjaswal

Copy link
Copy Markdown
Contributor Author

Rebased onto main and pushed. Summary of what changed:

  • Reset: withMcpContext now calls McpContext.resetWorkerIdsForTesting() alongside resetPageIdsForTesting(), so nextWorkerId resets between tests.
  • Mocks: createMockTarget now uses your createMockPuppeteerTarget, and createMockWebWorker uses a new MockWebWorker extends WebWorker subclass with sinon.createStubInstance — no as unknown as casts, and the CdpTarget export is gone.
  • Lifecycle: #onTargetDestroyed deletes the worker's target from #workers, and dispose() clears the map, mirroring #mcpPages.
  • API migration: the new service-worker consumers that were on getExtensionServiceWorkers() (the serviceWorkerId lookup in script.ts, the extension-SW listing in McpResponse, ServiceWorkerCollector) now go through getWorkers()/getWorkerById(), and the script.test.ts assertions reference getWorkers.

Typecheck and build are green; McpWorker and the extension-service-worker McpResponse tests pass locally. Re-requested your review.

@OrKoN
OrKoN self-requested a review September 30, 2026 10:17
Comment thread src/McpContext.ts Resolved
@gunjanjaswal
gunjanjaswal force-pushed the feat/2434-mcp-worker-abstraction branch from 62233d6 to 2ff350c Compare September 30, 2026 10:29
@gunjanjaswal

Copy link
Copy Markdown
Contributor Author

Good call — done in 2ff350c. Moved the id composition into McpWorker: there's now a McpWorker.create(type, target) factory that owns the ${workerIdPrefix(type)}-${counter} logic and the shared counter, plus McpWorker.resetIdsForTesting(). McpContext.createWorkersSnapshot() just calls McpWorker.create('service_worker', target) now, and McpContext.resetWorkerIdsForTesting() delegates to the McpWorker reset (so withMcpContext is unchanged). The plain constructor stays for the test mocks that assert specific ids. Typecheck/build green, worker tests pass.

@OrKoN
OrKoN force-pushed the feat/2434-mcp-worker-abstraction branch from 2ff350c to 901fc88 Compare September 30, 2026 10:31
@OrKoN
OrKoN enabled auto-merge September 30, 2026 10:31
auto-merge was automatically disabled September 30, 2026 10:36

Head branch was pushed to by a user without write access

@gunjanjaswal
gunjanjaswal force-pushed the feat/2434-mcp-worker-abstraction branch from 901fc88 to 35bcf1e Compare September 30, 2026 10:36
@OrKoN
OrKoN enabled auto-merge September 30, 2026 10:43
Introduce an McpWorker class mirroring McpPage: it wraps a worker Target with a
stable id, type, url and a lazy worker() accessor, generalizing the former plain
ExtensionServiceWorker type so service, dedicated and shared workers share one
representation. McpContext caches McpWorker per target (pruned like #mcpPages),
hands them out via getWorkers()/getWorkerById(), and the id counter is module
scoped like nextPageId. ServiceWorkerCollector, the script evaluator and the
extension-service-worker response listing consume the abstraction; getWebWorker
and the listing both gate on type === 'service_worker'.

Behaviour is unchanged: only extension service workers are tracked and the sw-N
id scheme is preserved. Tests use sinon.createStubInstance via centralized
createMockTarget/createMockWebWorker/createMockMcpWorker helpers.
auto-merge was automatically disabled October 1, 2026 04:04

Head branch was pushed to by a user without write access

@gunjanjaswal
gunjanjaswal force-pushed the feat/2434-mcp-worker-abstraction branch from 35bcf1e to 2cda83b Compare October 1, 2026 04:04
@OrKoN
OrKoN enabled auto-merge October 1, 2026 05:45
@OrKoN
OrKoN added this pull request to the merge queue Oct 1, 2026
Merged via the queue into ChromeDevTools:main with commit 77165c6 Oct 1, 2026
20 checks passed
@gunjanjaswal

Copy link
Copy Markdown
Contributor Author

Thanks @OrKoN for the thorough review and for merging this. The back-and-forth got McpWorker into much better shape — the id factory living on the worker, reusing the MockTarget/MockWebWorker pattern instead of casts, and the target lifecycle cleanup. Glad it's in as a foundation for the dedicated/shared worker work in #2352.

@gunjanjaswal
gunjanjaswal deleted the feat/2434-mcp-worker-abstraction branch October 1, 2026 09:17
OrKoN added a commit that referenced this pull request Oct 15, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.11.0](chrome-devtools-mcp-v1.10.1...chrome-devtools-mcp-v1.11.0)
(2026-10-15)


### 🎉 Features

* add --file-navigations flag to reject file: URL navigations
([#2853](#2853))
([54cae57](54cae57))
* Add analyze_heapsnapshot_contexts MCP tool
([#2791](#2791))
([190aeee](190aeee))
* add ignoreCache option to performance_start_trace
([#2931](#2931))
([3467d40](3467d40))
* add maxNameLength truncation option to compare_heapsnapshots
([#3098](#3098))
([1e1c53e](1e1c53e))
* Add pagination to compare_heapsnapshots
([#3140](#3140))
([daebfd1](daebfd1))
* **config:** add ConfigWatcher to watch config file changes
([#3139](#3139))
([9171f77](9171f77))
* discover the config file in predefined locations
([#2876](#2876))
([02c0112](02c0112))
* implement ffmpeg-free screencast tools enabled by default
([#3123](#3123))
([8953ea5](8953ea5))
* reduce StaticText noise in text snapshots
([#2895](#2895))
([4441325](4441325))
* report pages opened by input actions
([#2679](#2679))
([28fb230](28fb230))
* resolve config defaults after merging CLI and config file
([#2849](#2849))
([bdeb70d](bdeb70d))
* return failing audits and DOM nodes inline from lighthouse_audit
([#2930](#2930))
([241fba5](241fba5))
* skip more redundant data in text snapshots
([#2896](#2896))
([b2f522c](b2f522c))
* support debugging WebMCP tools in third-party developer tools
([#2900](#2900))
([0db519f](0db519f))
* support emulating additional CSS media features
([#2929](#2929))
([69524f0](69524f0))
* support evaluating scripts from local files
([#2606](#2606))
([9cf47a4](9cf47a4))
* Support truncation in get_heapsnapshot_details
([#3137](#3137))
([f827e06](f827e06))
* Truncate long names by default to 100 characters
([#2893](#2893))
([5ddb0a3](5ddb0a3))


### 🛠️ Fixes

* account for scroll offsets in downscaled screenshots
([#2685](#2685))
([830c693](830c693))
* allow --categoryExtensions when connecting to an existing browser
([#3041](#3041))
([d250bc5](d250bc5))
* allow stopping the CLI if command fails
([#3088](#3088))
([77e238e](77e238e)),
closes
[#2982](#2982)
* avoid runtime title fetches
([#2883](#2883))
([04195d1](04195d1))
* better config support for chrome-devtools CLI
([#2819](#2819))
([9624e64](9624e64))
* clamp async stack trace separator repeat count
([#3035](#3035))
([93e06ab](93e06ab)),
closes
[#3031](#3031)
* **cli:** pass positional values starting with `-` through to tools
([#3084](#3084))
([9de05ae](9de05ae)),
closes
[#2984](#2984)
* **collectors:** ignore transient target errors when subscribing to
service workers
([#2888](#2888))
([551dd6c](551dd6c))
* **daemon:** bound browser shutdown and avoid watchFile timeout on stop
([#2887](#2887))
([f3db5e7](f3db5e7))
* **daemon:** keep fallback socket in private runtime dir
([#2766](#2766))
([871a37e](871a37e))
* **daemon:** verify process identity before treating PID file as active
([#3109](#3109))
([b608bed](b608bed))
* do not close a healthy browser when a tool call outlasts 60s
([#3149](#3149))
([39c7db1](39c7db1))
* ensure aggregate IDs in heap snapshots are deterministic
([#2923](#2923))
([e918c47](e918c47))
* escape client-supplied values in McpContext logs and errors
([#2832](#2832))
([efb0d02](efb0d02)),
closes
[#2831](#2831)
* fail fast on tool calls stuck after a dead browser connection
([#2699](#2699))
([2a7ef50](2a7ef50))
* harden third-party tool result serialization
([#2892](#2892))
([4418a7b](4418a7b))
* honor explicit --allowUnrestrictedPaths=false in CLI mode
([#3040](#3040))
([61fc362](61fc362))
* include errors in slim responses
([#3085](#3085))
([ee38097](ee38097))
* **input:** reject multiple file paths on single-file input in
upload_file
([#2995](#2995))
([#3135](#3135))
([e650843](e650843))
* list fresh page titles
([#3103](#3103))
([e717082](e717082))
* **memory:** reject contradictory pagination options in
take_heapsnapshot
([#3002](#3002))
([#3131](#3131))
([508126c](508126c))
* **network:** enforce URL policy across redirects
([#2767](#2767))
([274cd4c](274cd4c))
* pass categoryExtensions to the target filter when connecting
([#3047](#3047))
([4e90238](4e90238))
* **performance:** report an error when performance_stop_trace is called
with no active trace
([#3001](#3001))
([#3126](#3126))
([e170384](e170384))
* preserve HeapSnapshotManager across browser reconnects
([#3025](#3025))
([64388c6](64388c6))
* propagate failed responseFilePath write error instead of reporting
body unavailable
([#2957](#2957))
([#3119](#3119))
([3cee3bd](3cee3bd))
* **pwa:** wait for initial navigation on launch and retry transient
install error
([#2889](#2889))
([63010cb](63010cb))
* record screencast at the page's device pixel size
([#3155](#3155))
([62e2aa4](62e2aa4))
* reject --blockedUrlPattern/--allowedUrlPattern hostname regexp groups
([#2796](#2796))
([ae0aaef](ae0aaef))
* reject JSON arrays as 3p and WebMCP tool params
([#2785](#2785))
([c14e616](c14e616))
* reject named groups in URL patterns
([#2857](#2857))
([5b2c6f9](5b2c6f9))
* reject non-positive --viewport dimensions
([#2781](#2781))
([0ef528a](0ef528a))
* reject non-positive resize_page dimensions
([#2784](#2784))
([6ab6d35](6ab6d35))
* reject unrestricted paths with an explicit workspace
([#2858](#2858))
([45c1c6c](45c1c6c))
* report unknown page id before last-page guard in close_page
([#3042](#3042))
([bdc7e24](bdc7e24))
* round lighthouse category scores and show unscored categories as n/a
([#2924](#2924))
([7007680](7007680)),
closes
[#2915](#2915)
[#2916](#2916)
* set empty filePath to undefined instead of empty string
([#2836](#2836))
([adfc1ff](adfc1ff)),
closes
[#2825](#2825)
* surface WebMCP tool exceptions in execute_webmcp_tool
([#3107](#3107))
([d80d22e](d80d22e)),
closes
[#2975](#2975)
* url pattern partial ipv4
([#2859](#2859))
([c87d190](c87d190))


### 📄 Documentation

* clarify Antigravity MCP setup for VS Code extension
([#2855](#2855))
([12e13ca](12e13ca))
* clarify scope of --no-javascript-evaluation
([#3100](#3100))
([0c67cd5](0c67cd5))
* correct link to configuration
([#3086](#3086))
([bbb1e36](bbb1e36))
* document trusted host environment in SECURITY.md
([#3125](#3125))
([1352207](1352207))
* fix inaccurate examples in skills and CLI docs
([#2922](#2922))
([ec372b0](ec372b0)),
closes
[#2906](#2906)
[#2907](#2907)
[#2908](#2908)
[#2910](#2910)
[#2912](#2912)
[#2913](#2913)
[#2918](#2918)
[#2919](#2919)
[#2920](#2920)
[#2921](#2921)
* fix some reported issues
([#3099](#3099))
([d5d2f08](d5d2f08))
* include serviceWorkerId parameter for evaluate_script
([#3015](#3015))
([#3129](#3129))
([0623434](0623434))
* mention heapsnapshot being cached between runs
([#3045](#3045))
([f08dbe1](f08dbe1)),
closes
[#2976](#2976)
* **skills:** remove invalid outputDir flag from lighthouse_audit calls
([#3013](#3013))
([#3130](#3130))
([7754226](7754226))
* update documentation and SKILL for get_css_styles tool
([#2824](#2824))
([3c12a91](3c12a91))


### ⚡ Performance

* **cli:** re-use MCPServer.from helpers for daemon
([#2804](#2804))
([89eb3d5](89eb3d5))
* Load heap snapshots in parallel in compare_heapsnapshots
([#3023](#3023))
([20c1391](20c1391))


### 🏗️ Refactor

* centralize config defaults and conflict checks
([#2753](#2753))
([a739ba8](a739ba8))
* create all tools and register per slim mode
([#2874](#2874))
([99847a7](99847a7))
* enable categories by default
([#2811](#2811))
([e33ee48](e33ee48))
* extract CLI examples and conflict list in mcp-options
([#2848](#2848))
([45000d9](45000d9))
* extract config parsing logic in a class
([#2861](#2861))
([e4168d0](e4168d0))
* extract worker logic into McpWorker
([#2800](#2800))
([77165c6](77165c6))
* group Puppeteer and tool options
([#2875](#2875))
([699c4d5](699c4d5))
* lazily initialize McpPage from Target and enumerate targets in
McpContext
([#2812](#2812))
([545cbe3](545cbe3))
* use default Error for toolSchema
([#2822](#2822))
([8b2768d](8b2768d))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: Alex Rudenko <OrKoN@users.noreply.github.com>
OrKoN pushed a commit to nancy6547/chrome-devtools-mcp that referenced this pull request Oct 16, 2026
…2881)

## Summary

- Fix `list_console_messages` to accept the `sw-N` service worker IDs
returned by `list_pages`. Resolve the service worker in
`McpContext.getServiceWorkerConsoleData` and use its extension ID to
retrieve console messages.
- Reject raw extension IDs, unknown IDs, and IDs for dedicated or shared
workers with `Service worker not found.`.
- Update the parameter documentation and generated CLI options to
describe the supported ID format.

Fixes ChromeDevTools#2846.

## Testing

- `npm run test -- tests/McpResponse.test.ts
tests/tools/console.test.ts` (with local Chrome): passed.
- `npm run check-format`: passed.
- `npm run test` (with local Chrome): one large full-page screenshot
test failed with `Page.captureScreenshot: Page is too large`; the same
test fails on a clean checkout of base `45c1c6c` with the same Chrome.
All other tests passed.

Note: ChromeDevTools#2800 is refactoring worker IDs; this patch is based on current
`main` and can be rebased if needed.

Co-authored-by: guolisha <guolisha@kylinos.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task]: Extract worker related logic into McpWorker

2 participants