Open
Description
Describe the bug
In my typescript ESM module project (https://github.com/compiler-explorer/compiler-explorer) I tried to install and use this package, and it picks up @modelcontextprotocol/sdk@1.11.0
. That package appears to come from git+ssh://git@github.com/modelcontextprotocol/typescript-sdk.git#621ccea...
This git package is missing the dist
subdirectory.
To Reproduce
- Create a new project and install dependencies:
mkdir mcp-repro && cd mcp-repro
npm init -y
npm install @modelcontextprotocol/sdk@github:modelcontextprotocol/typescript-sdk tsx
- Create a simple TypeScript file (mcp-repro.ts):
// Simple file to test MCP SDK import
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
console.log('McpServer successfully imported:', McpServer);
- Run the file with tsx:
npx tsx mcp-repro.ts
Expected behavior
The script should successfully import the McpServer class from the SDK and output its details.
Actual behavior
$ npx tsx mcp-repro.ts
node:internal/modules/cjs/loader:1281
const err = new Error(`Cannot find module '${request}'`);
^
Error: Cannot find module '/tmp/mcp-repro/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/mcp.js'
at createEsmNotFoundErr (node:internal/modules/cjs/loader:1281:15)
at finalizeEsmResolution (node:internal/modules/cjs/loader:1269:15)
at resolveExports (node:internal/modules/cjs/loader:638:14)
at Function._findPath (node:internal/modules/cjs/loader:743:31)
at node:internal/modules/cjs/loader:1230:27
at nextResolveSimple (/tmp/mcp-repro/node_modules/tsx/dist/register-D2KMMyKp.cjs:3:942)
at /tmp/mcp-repro/node_modules/tsx/dist/register-D2KMMyKp.cjs:2:2550
at /tmp/mcp-repro/node_modules/tsx/dist/register-D2KMMyKp.cjs:2:1624
at resolveTsPaths (/tmp/mcp-repro/node_modules/tsx/dist/register-D2KMMyKp.cjs:3:760)
at /tmp/mcp-repro/node_modules/tsx/dist/register-D2KMMyKp.cjs:3:1038 {
code: 'MODULE_NOT_FOUND',
path: '/tmp/mcp-repro/node_modules/@modelcontextprotocol/sdk/package.json'
}
Node.js v22.13.1
Additional context
Related issues:
- Issue Error [ERR_PACKAGE_PATH_NOT_EXPORTED] when importing @modelcontextprotocol/sdk #427: Error [ERR_PACKAGE_PATH_NOT_EXPORTED] when importing @modelcontextprotocol/sdk #427
- Nearly identical to our error - package can't find the specified paths
- Problem with the exports field in package.json not correctly mapping to dist files - Issue ERR_MODULE_NOT_FOUND When Importing from proxyProvider Without .js Extension #440: ERR_MODULE_NOT_FOUND When Importing from proxyProvider Without .js Extension #440
- Similar module not found error
- Workaround: add .js extension to imports (though this won't help in our case) - Issue Module Resolution Error in ESM: Unable to Resolve @modelcontextprotocol/sdk/types.js #459: Module Resolution Error in ESM: Unable to Resolve @modelcontextprotocol/sdk/types.js #459
- Another module resolution issue in ESM context
- Very similar error pattern to what we're experiencing
The core issue appears to be in how the SDK is packaged and exported:
- The package.json has an exports field that points to:
"exports": {
"./": {
"import": "./dist/esm/",
"require": "./dist/cjs/*"
}
} - However, when installed, the dist directory is missing entirely, causing any imports
to fail with ERR_MODULE_NOT_FOUND - This is likely happening because the package is being installed directly from GitHub
without being properly built first.