Skip to content

Add Browser-Based MCP Transport for Client-Server Communication within Browser Environments #219

Open
@AdirD

Description

@AdirD

Is your feature request related to a problem? Please describe.
Currently, MCP transport implementations (stdio, SSE) require separate processes or dedicated HTTP endpoints, making it impossible to run MCP client-server communications entirely within browser environments. This limitation prevents implementing MCP in use cases like browser extensions, static web applications, embedded web components, or isolated environments such as Web Workers or cross-domain iframes.

Describe the solution you'd like
Introduce a browser-based MCP transport implementation (BrowserContextTransport) that enables bidirectional client-server communication directly within the browser using the browser's built-in MessageChannel API. This would allow MCP servers to run in-browser alongside MCP clients, significantly simplifying the architecture and enabling new, previously unsupported scenarios.

Describe alternatives you've considered

  • Using existing transports (stdio, SSE), but these inherently rely on external processes or server-side endpoints, which are unsuitable for purely browser-based environments.
  • Utilizing WebSocket or other external messaging libraries, but they introduce unnecessary complexity, external dependencies, and still typically require external backend services.

Additional context
The proposed solution leverages the standard MessageChannel API, widely supported across browsers, ensuring compatibility and easy integration. This solution has been validated with basic scenarios and is structured to support additional use cases, including communication between the main thread and Web Workers, and cross-domain iframes for isolated or secure deployments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions