chrome-devtools-mcp icon indicating copy to clipboard operation
chrome-devtools-mcp copied to clipboard

fix(extensions): preserve list_extensions fields in JSON output

Open coygeek opened this issue 3 weeks ago • 1 comments

Description of the bug

list_extensions returns one empty object per installed extension in CLI JSON output and in MCP structuredContent. The same responses include the extension's ID, name, version, and enabled state in their text content. Programmatic callers cannot identify extensions or read their metadata from the structured result.

Reproduction

Use the release baseline below with Chrome stable installed. The following commands create a disposable MV3 extension and browser profile. Run them in a shell where chrome-devtools resolves to that release:

export CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS=1
export CHROME_DEVTOOLS_MCP_NO_CONFIG_DISCOVERY=1
W=$(mktemp -d /tmp/extension-json-repro.XXXXXX)
mkdir -p "$W/ext"
printf '%s\n' '{"manifest_version":3,"name":"Probe Ext","version":"1.0.0"}' > "$W/ext/manifest.json"
SID=$(openssl rand -hex 6)
chrome-devtools start --sessionId "$SID" --headless --channel=stable --userDataDir="$W/profile" --workspace="$W" --categoryExtensions --no-usage-statistics --no-performance-crux
chrome-devtools list_extensions --output-format=json --sessionId "$SID"
chrome-devtools install_extension "$W/ext" --sessionId "$SID"
chrome-devtools list_extensions --sessionId "$SID"
chrome-devtools list_extensions --output-format=json --sessionId "$SID"
chrome-devtools stop --sessionId "$SID"
rm -rf "$W"

For the MCP surface, start chrome-devtools-mcp over stdio with --headless --channel=stable --userDataDir="$W/mcp-profile" --workspace="$W" --categoryExtensions --experimentalStructuredContent --no-usage-statistics --no-performance-crux before removing the fixture. After the normal MCP initialize/initialized exchange, call list_extensions, install_extension with {"path":"<absolute fixture directory>/ext"}, and list_extensions again. This sequence was also executed against a separate fresh profile.

Expectation

CLI JSON and MCP structured content should retain each installed extension's ID, name, version, and enabled status, consistent with the list_extensions tool description and the text result. The empty-browser result should remain an empty array.

Actual behavior

Both executed release runs reproduced the defect, one through the CLI and one through MCP stdio. The CLI commands exited successfully. Before installation, CLI JSON was {"extensions":[]}. After installation, text output was:

## Extensions
id=<generated-extension-id> "Probe Ext" v1.0.0 Enabled

The corresponding CLI JSON was:

{"extensions":[{}]}

The final MCP tools/call response contained:

{
  "content": [
    {
      "type": "text",
      "text": "## Extensions\nid=<generated-extension-id> \"Probe Ext\" v1.0.0 Enabled"
    }
  ],
  "structuredContent": {"extensions": [{}]}
}

The generated extension ID is replaced with a descriptive marker in these excerpts; it agreed between installation and listing in each run. The empty-browser MCP control returned "extensions": [] and the text No extensions installed.

Evidence

  • Expected source: docs/cli.md, Output format documents JSON for programmatic use; src/tools/extensions.ts:56-70 specifies name, ID, version, and enabled status.
  • Failure source: The CLI output and MCP stdio response reproduced above from an isolated npm install; the unchanged assignment of extension instances in src/McpResponse.ts:1616-1628.
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete

On the inspected default branch, list_extensions calls response.setListExtensions(), McpResponse.handle() obtains context.listExtensions(), and McpContext.listExtensions() returns browser.extensions(). McpResponse assigns the resulting instances directly to structuredContent.extensions, while the text formatter accesses their getters. The CLI's src/daemon/client.ts:316-321 serializes structured content with JSON.stringify; src/ToolHandler.ts:528-529 includes it in MCP responses when the structured-content flag is enabled.

The branch's lockfile pins puppeteer-core to 25.16.0. Its Extension class stores the metadata in private fields and exposes prototype getters, so an extension instance has no enumerable own properties and serializes as {}. A focused probe executed the exact extension-formatting block extracted from current src/McpResponse.ts with that pinned CdpExtension class: text retained all four fields, JSON contained {"extensions":[{}]}, and the empty-map control contained {"extensions":[]}. This is a focused serializer check and source trace, not a full build or end-to-end execution of main.

Restoration check

With the same disposable extension, CLI JSON and the MCP structured result should contain one entry with the same ID, name, version, and enabled state as the text result. Listing a fresh empty profile must still yield an empty array. Verify the serialized wire result, since inspecting getters on the in-process instance can conceal this failure.

Chrome DevTools MCP version

1.12.0, confirmed as npm's latest and installed freshly in isolation. Default-branch baseline: main at 0b37364dc0a88a804c6d73d3335e776adc7f33c4, inspected from a fresh clone; focused serializer execution only.

Chrome version

156.0.8078.80 stable in headless mode.

Node version

v26.12.1

Operating system

macOS 27.2

MCP configuration

The commands above use disposable profiles with the extension category enabled, update checks and configuration discovery disabled, and usage statistics and CrUX disabled. MCP stdio additionally enables experimental structured content and negotiated protocol version 2025-11-25. Other operating systems, Chrome versions, and disabled extensions were not tested.

Triage assessment

  • Impact level: P2
  • Assessment status: supported
  • Impact basis: CLI JSON and MCP structured-content consumers lose all identifying metadata for the installed extension in both executed runs; the text result retains it. Reach beyond the measured environment is untested.
  • Workaround status: available
  • Workaround basis: The executed default CLI output and MCP text content both retain ID, name, version, and enabled state; callers can read that text while structured output is corrected.

coygeek avatar Nov 07 '26 00:11 coygeek

Hi maintainers,

I'd like to work on this issue as my first contribution to Chrome DevTools MCP.

I've reviewed the reported serialization problem in src/McpResponse.ts.

My proposed approach is to:

  • Convert extension instances into plain serializable objects containing id, name, version, and enabled.
  • Add regression tests for populated and empty extension lists.
  • Verify that both CLI JSON output and MCP structured content preserve the expected fields.

Could you please let me know if this issue is available for contribution and whether I may take it on?

Thanks!

JIUSAN3 avatar Nov 07 '26 08:11 JIUSAN3