-
Notifications
You must be signed in to change notification settings - Fork 521
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
@modelcontextprotocol/sdk fails in CommonJS projects due to incompatible ESM-only dependency (pkce-challenge) #217
Comments
This is blocking our usage of MCP as well |
It seems to me like you're importing from the cjs dist, instead of the esm dist. I think there is a dist/esm folder that has what you're looking for |
@dimavedenyapin @MauroPerna Have you tried changing the imports? |
I also encountered the same problem. |
@QuantGeekDev How to change the important to import from esm dist?
but not working |
We encountered the same issue here: AIGNE-io/aigne-framework#36 |
Having the same issue as well |
I went to version 1.5.0 which doesn't have the |
@MauroPerna, thanks for the fix, it works for me as well! I used this little script ( |
Thanks, your script works very well :D |
Manually update the "pkce challenge" version to "5.0.0", for example: |
same error |
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
@modelcontextprotocol/[email protected]
for the project I'm working on.When importing
@langchain/mcp-adapters
in a CommonJS project (such as NestJS), the following error occurs at runtime:The issue originates from
@modelcontextprotocol/sdk
, which uses a CommonJS-stylerequire()
to importpkce-challenge
, an ESM-only package.Steps to Reproduce
@langchain/mcp-adapters
in a CommonJS-based NestJS backendSuggested fix
Use dynamic
import()
instead ofrequire()
inauth.js
to support ESM-only dependencies within CommonJS projects.Here’s the minimal diff that solved the issue:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: