Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommonJS Support #90

Open
wu-joyous opened this issue Dec 10, 2024 · 3 comments
Open

CommonJS Support #90

wu-joyous opened this issue Dec 10, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@wu-joyous
Copy link

Is your feature request related to a problem? Please describe.
The current SDK is incompatible with "commonjs" packages, such as using @modelcontextprotocol/sdk in Nest.js.

Describe the solution you'd like
@modelcontextprotocol/sdk should be compatible with both ESModules and CommonJS.

Describe alternatives you've considered
n/a

Additional context
n/a

@wu-joyous wu-joyous added the enhancement New feature or request label Dec 10, 2024
@jspahrsummers
Copy link
Member

This can be worked around by using dynamic import() at runtime. ESM is the way the ecosystem is trending, so we'd prefer to avoid maintaining CJS if possible.

@wu-joyous
Copy link
Author

Dynamic import does not work when the tsconfig.module is set to commonjs in TypeScript, since "await import" is compiled into "require". It would be highly beneficial to have the build file support both "CJS" and "ESM," similar to packages like anthropic-sdk-typescript.

@jspahrsummers
Copy link
Member

You should be able to use "module": "node16", right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants