description: "Share per-Session browser ownership and MCP activation across experimental browser providers."
English | 中文
Browser providers use this library to reuse a browser across one Session's turns and close its resources when that Session's runtime is disposed. Operations for one Session run in order, while isolated Sessions can proceed independently. Attachment mode reserves one external browser for a single Session. The library also connects provider-owned MCP servers and discovers their tools before the Session's first model request.
This public experimental library is a dependency of the browser providers. It has no plugin entry or mount configuration. The browser-use service remains independent of the library.
Native providers construct SessionResources from the package root, supplying resource acquisition and cleanup callbacks. Calls pass the exact live Agent to run(); stale owners and a second owner of an exclusive attachment fail before acquisition. Canceling an acquisition wait leaves initialization available to other callers in the same Session; Session disposal aborts and awaits that initialization. Providers keep their registration until dispose() finishes.
MCP providers use mountSessionMcp from @deepseek-ai/dsh-experimental-browser-use-runtime/mcp, supplying their fixed server name, executable, arguments, and ownership policy. The helper awaits one scoped client startup and discovery attempt within each future Agent's agent/created event. Agent creation or resume completes after discovery, before queued input runs; a successful client remains owned by that Session across turns.
A busy attachment skips startup permanently for that live activation while its other work continues. Releasing the attachment does not retry skipped activations; a newly created or resumed Agent can acquire it. Startup failure or cancellation rejects Agent creation or resume and triggers creation rollback, including client cleanup. Reconnection is disabled. Loading or reloading a provider applies only to future Agent activations.
Callers can inspect prompt assembly and scoped tool definitions after awaited Agent creation or resume completes.
Browser tools and resource requests targeting this server use the same queue and require the calling Session's own connection. Other MCP servers remain usable. Inherited server instructions are omitted without ownership; the shared server-name inventory keeps its normal scope behavior.
Indirectly, through provider-owned browser tools, whose catalogs the MCP helper discovers before model request assembly; providers and the MCP client own descriptions, schemas, results, and image behavior.
The library adds no prompt text. Discovered tool schemas and provider guidance determine request-prefix changes; ordinary browser resource reuse does not alter those schemas.
Providers remain responsible for the browser operations they supply.