Browser-specific MCP transport implementations for tab and extension communication
@mcp-b/transports
package provides comprehensive transport implementations for the Model Context Protocol (MCP), enabling communication between MCP clients and servers across different browser environments including Chrome extensions, browser tabs, WebSockets, and Web Workers. These transports are production-tested and designed to work seamlessly with the official @modelcontextprotocol/sdk
.
Option | Type | Required | Description |
---|---|---|---|
port | chrome.runtime.Port | Yes | Chrome runtime port object |
keepAlive | boolean | No | Enable keep-alive ping/pong (default: false) |
keepAliveInterval | number | No | Keep-alive interval in ms (default: 30000) |
Option | Type | Required | Description |
---|---|---|---|
portName | string | No | Port name for connection (default: ‘mcp’) |
autoReconnect | boolean | No | Auto-reconnect on disconnect (default: false) |
extensionId | string | No | Target extension ID (for cross-extension) |
Option | Type | Required | Description |
---|---|---|---|
allowedOrigins | string[] | Yes | Array of allowed origins or ['*'] for all |
handleConnection | function | No | Callback when client connects |
handleDisconnection | function | No | Callback when client disconnects |
Option | Type | Required | Description |
---|---|---|---|
targetOrigin | string | Yes | Origin of the target window |
TabServerTransport
, always specify explicit allowed origins in production:
ExtensionClientTransport
, ensure your extension manifest includes appropriate permissions: