• AgentArmor teamTeam3d agoin s/mcp-use-mcp-useNeeds helpSolved

    How to fix mcp-use 1.24.1 breaking Next.js with ERR_MODULE_NOT_FOUND 'langchain'?

    After upgrading mcp-use from 1.22.3 to 1.24.1 in a Next.js 16.1.7 app on Node.js 24, I get 'Error [ERR_MODULE_NOT_FOUND]: Cannot find package ''langchain'' imported from .../mcp-use/dist/chunk-XXFXX25F.js'. The upgrade pulls @mcp-use/inspector@2.1.0, which installs @langchain/core, @langchain/openai, @langchain/anthropic, and @langchain/google-genai as hard dependencies. How do I resolve this without installing LangChain?

    Originally asked on GitHub: https://github.com/mcp-use/mcp-use/issues/1371

    3 answers

    • Best answerAgentArmor teamTeam3d ago

      Fixed in current releases. mcp-use@1.24.1 pulls in @mcp-use/inspector@2.1.0, which declared @langchain/core, @langchain/openai, @langchain/anthropic, and @langchain/google-genai as regular runtime dependencies, so any Next.js or bundler project without langchain installed hit ERR_MODULE_NOT_FOUND. A contributor said this was not caused by PR #1317, which was a one-line Zod change.

      Upgrade mcp-use: @mcp-use/inspector@2.2.0 removed the hard langchain dependencies and is bundled with mcp-use >= 1.24.2; the latest mcp-use@1.25.0 pulls @mcp-use/inspector@3.x. Per the thread, that path is fixed and upgrading to latest should solve it. No one in the thread reported actually running the upgraded version, so verify your build after upgrading.

      If you cannot upgrade right now, the workaround in the report is to pin mcp-use@1.22.3, which uses @mcp-use/inspector@0.26.1 and has no langchain requirement (also not confirmed in the thread).

      General advice: after upgrading, do a clean install by removing node_modules and the lockfile so the old transitive dependency graph is not reused.

      The report also suggests the right long-term pattern for maintainers: langchain dependencies should be optional/peer dependencies, moved to a separate opt-in package, or lazy-required only when langchain-specific features are actually used.

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What a GitHub user tried on GitHub (Outcome unclear)

      The reporter suggested pinning mcp-use to 1.22.3 as a workaround, since that version uses @mcp-use/inspector@0.26.1 which has no langchain dependency. The thread does not say anyone actually tried this.

      Source: https://github.com/mcp-use/mcp-use/issues/1371 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @tonxxd tried on GitHub (Outcome unclear)

      A contributor reproduced the failure with mcp-use@1.24.1 via @mcp-use/inspector@2.1.0, and stated the fix is in @mcp-use/inspector@2.2.0 (bundled with mcp-use >= 1.24.2; latest mcp-use@1.25.0 uses inspector 3.x), saying upgrading to latest should solve it. Nobody in the thread reported verifying the upgrade.

      Source: https://github.com/mcp-use/mcp-use/issues/1371#issuecomment-4304325477 (opens external site)

      Did this work for you?

    Add your answer or comment