> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mcp-b.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Runtime layering

> Why MCP-B separates browser tool contracts, its server runtime, and transports.

MCP-B keeps browser tool contracts separate from its server runtime and
transport adapters. A native implementation or `@mcp-b/webmcp-polyfill`
supplies the package-supported `document.modelContext` surface.
The polyfill temporarily retains declarative tools until upstream supports them;
native declarative behavior is unchanged.
`@mcp-b/webmcp-ts-sdk` adds `BrowserMcpServer`, which mirrors core tool
operations while providing MCP-B-only capabilities. `@mcp-b/global`
initializes those layers and connects the selected browser transport.

Global initialization preserves the browser-shaped programming model:

<Columns cols={3}>
  <Card title="1. Browser context" icon="browser">
    A native implementation or `@mcp-b/webmcp-polyfill` supplies the browser surface.
  </Card>

  <Card title="2. MCP-B runtime" icon="layer-group">
    `BrowserMcpServer` mirrors core tools, adds MCP-B extensions, and becomes
    `document.modelContext`.
  </Card>

  <Card title="3. Selected transport" icon="plug">
    The transport connects explicit MCP clients without changing page code.
  </Card>
</Columns>

Initialization returns no server handle. Application and library code keeps
using `document.modelContext` normally, whether the active implementation is
native, polyfilled, or wrapped by MCP-B. Cleanup restores the property
descriptors that existed before wrapping and unregisters the tools registered
through the wrapper. Tools registered directly on the underlying context remain,
and cleanup does not uninstall the separately owned polyfill or its declarative layer.

This separation allows a library to depend only on types, a site to use only
the tool-only polyfill, or an application to install the complete MCP-B runtime.
Core tool registrations remain visible to native browser tooling.

See the [`@mcp-b/global` reference](/packages/global/reference) and [Choose a
runtime](/how-to/choose-runtime).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.