[firefox-devtools-mcp] Call global commands with the proper user context in container restricted sessions
Categories
(Developer Infrastructure :: Firefox MCP, enhancement, P2)
Tracking
(Not tracked)
People
(Reporter: jdescottes, Assigned: jdescottes)
References
(Depends on 2 open bugs)
Details
(Whiteboard: [webdriver:m22])
Attachments
(1 external file)
When the WebDriver BiDi server is started at runtime, Firefox restricts the session to a dedicated container (remote-control-container) if remote.experimental.dynamicstart.container-isolation-enabled is true (bug 2072964, bug 2081128). A restricted session only sees the tabs of the container, only supports a small set of commands, and requires explicit targets for some of them. See "Sessions restricted to a single user context" in remote/doc/webdriver-bidi/Extensions.md.
The MCP needs these changes to work with such a session, typically with --connect-existing:
- Read the
moz:userContextcapability from the new session. If it is present, the session is restricted, and the value is the user context of the container. session.subscribe: passuserContexts: [userContext]in a restricted session. Subscriptions without targets are rejected.session.unsubscribe: unsubscribe by subscription id. Unsubscribing by event names only removes global subscriptions.browser.setDownloadBehavior: passuserContexts: [userContext]in a restricted session.network.addDataCollector: passuserContexts: [userContext]in a restricted session, so that request and response bodies can still be captured (needs the matching Firefox change).- Hide the tools which need commands that a restricted session rejects: debugging, profiler, prefs, privileged contexts, web extensions, print and the network cache tool. Send a tool list change notification once the restriction is known, and return a clear error if a hidden tool is called anyway.
- Map the
unsupported operationerror to a clear message, for example "Not available when connected to an existing Firefox".
In unrestricted sessions, keep the current behavior (global subscriptions and settings, all tools).
The page tools still use WebDriver classic, which is not restricted, so they keep seeing all tabs until they are migrated to BiDi (see the dependencies of bug 2037070).
| Assignee | ||
Updated•1 month ago
|
| Assignee | ||
Comment 1•1 month ago
|
||
Scope reduced a bit, this bug focuses on commands which can be restricted at framework level, and the special cases which need individual fixes moves to Bug 2082353.
| Assignee | ||
Updated•1 month ago
|
Comment 2•1 month ago
|
||
(via GitHub webhook, authenticated as firefox-devtools-mcp@bots.tld)
| Assignee | ||
Comment 3•1 day ago
|
||
Waiting on Bug 2080973 and Bug 2080977: once they land, this bug will also pass the restricted user context to browsingContext.create, so new tabs open in the session's container.
Description
•