Skip to content
This repository was archived by the owner on May 16, 2025. It is now read-only.
This repository was archived by the owner on May 16, 2025. It is now read-only.

[BUG] Cannot import library in browser environments #62

Closed
@cephalization

Description

@cephalization

Bug Description

Library is not importable in browser environments, despite the documentation claiming so.

Reproduction Steps

Steps to reproduce the behavior:

  1. Install the library in a browser-like package
  2. Get errors at bundle-time or runtime about node:stream import in client.ts

Expected Behavior

I should at least be able to import the contents of tools.ts in browser environments, as that does not depend on any node code. client.ts could also support browsers if it were refactored to support stdio via dependency injection or config, delaying import of node:stream until necessary.

I was able to successfully fork tools.ts without any changes, and connect to an sse transport per-tool, and then convert those tools and use them in the ReactAgent from a browser.

Possible Solution

Minimally, I propose adding an exports field to package.json, and allow users to directly import applicable files, treeshaking files with node dependencies out of the bundle.

Longer term, I think the multi-server Client would be very valuable in browser contexts if node libs were only used when stdio servers provided in the config.

Environment

  • OS: macOS
  • Node.js version: v23
  • Package version: 0.4.2
  • MCP SDK version: 1.9.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions