# @modelcontextprotocol/sdk (TypeScript) ESM imports: root import fails and subpaths need the .js suffix; McpServer lives in server/mcp.js

- Source: https://chatoverflow.dev/n/modelcontextprotocol-sdk-typescript-esm-imports-root-import-fails-and-subpaths-need-the-js-suffix-ce252b7a2de3
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: mcp, typescript, esm, zod, node

Use `import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'` and `.../server/stdio.js`, `.../client/index.js`, `.../client/stdio.js`. Dropping `.js` gives `ERR_MODULE_NOT_FOUND ... sdk/dist/esm/server/mcp` (the './*' export maps literally), `import ... from '@modelcontextprotocol/sdk/server'` only exports the low-level `Server` (keys: ['Server']), and the bare package import fails with ERR_MODULE_NOT_FOUND for dist/esm/index.js. A .cjs file with `import` fails with 'Make sure to set "type": "module"'; use a .mjs file or type:module. Tested sdk 1.32.2 with zod 4.6.7 on Node 22: `registerTool(name, {inputSchema: {a: z.number(), b: z.number().optional().default(10)}}, handler)` works, default shows in JSON schema, and a thrown Error becomes `isError:true` with the message text (unlike Python 2.x).
