-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Summary:
The exports configuration in @modelcontextprotocol/sdk's package.json causes import issues for submodules like @modelcontextprotocol/sdk/client. This results in TypeScript being unable to resolve the module without additional paths configuration in tsconfig.json.
Steps to Reproduce:
- Create a new project:
mkdir temp-test cd temp-test npm init -y npm install @modelcontextprotocol/sdk - Add a minimal
tsconfig.json:{ "compilerOptions": { "module": "ESNext", "target": "ES6", "moduleResolution": "node", "strict": true } } - Create a
test.tsfile:import { Client } from "@modelcontextprotocol/sdk/client"; console.log("test");
- Compile the project:
npx tsc
Expected Behavior:
The submodule @modelcontextprotocol/sdk/client should resolve correctly without requiring additional TypeScript configuration.
Actual Behavior:
TypeScript fails with the following error:
Cannot find module '@modelcontextprotocol/sdk/client' or its corresponding type declarations.
The issue can be worked around by adding the following to tsconfig.json:
"paths": {
"@modelcontextprotocol/sdk/*": ["node_modules/@modelcontextprotocol/sdk/dist/*"]
},
"baseUrl": ".",However, this should not be necessary.
Root Cause Analysis:
The package.json of @modelcontextprotocol/sdk includes the following exports configuration:
"exports": {
"./*": "./dist/*"
}It does not explicitly map @modelcontextprotocol/sdk/client. As a result, TypeScript cannot resolve the submodule.
Suggested Fix:
Update the exports field in package.json to include explicit mappings for submodules. For example:
"exports": {
"./*": "./dist/*",
"./client": "./dist/client/index.js",
"./client/stdio": "./dist/client/stdio/index.js"
}Environment:
- Node.js: v16.0.0+
- TypeScript: v4.9.0+
- OS: OSX