Skip to content

fix: replace tsc with tsup to resolve OOM during build - #2

Open
Ostico wants to merge 1 commit into
macarthy:mainfrom
Ostico:fix/tsc-oom-mcp-sdk
Open

fix: replace tsc with tsup to resolve OOM during build#2
Ostico wants to merge 1 commit into
macarthy:mainfrom
Ostico:fix/tsc-oom-mcp-sdk

Conversation

@Ostico

@Ostico Ostico commented Jun 7, 2026

Copy link
Copy Markdown

Summary

Fixes #1npm run build (tsc) crashes with JavaScript heap out of memory due to exponential type expansion in @modelcontextprotocol/sdk >=1.23.0.

Changes

  • Replace tsc with tsup (esbuild-based) for the build step — builds in 12ms
  • Add typecheck script (tsc --noEmit) for optional type checking
  • Add tsup as dev dependency
  • Keep @modelcontextprotocol/sdk at latest (^1.29.0)

Root Cause

registerTool() in the MCP SDK uses deeply nested Zod generic chains for type inference. With 8 tools registered with complex schemas, TypeScript's declaration emit phase enters exponential type computation. The regression was introduced in SDK 1.23.01.22.0 is the last version where tsc completes.

tsc --noEmit (type checking only, no declaration emit) works fine on all SDK versions, confirming the issue is specifically in declaration generation.

Since bruno-mcp is an executable MCP server (not a library), declaration files are unnecessary, making tsup the correct solution.

Testing

$ npm run build

> tsup src/index.ts --format esm --sourcemap --clean

ESM dist/index.js     55.67 KB
ESM dist/index.js.map 109.32 KB
ESM ⚡️ Build success in 12ms

Upstream reference: modelcontextprotocol/typescript-sdk#985

@modelcontextprotocol/sdk >=1.23.0 causes TypeScript compiler to exhaust
heap memory during declaration emit due to deep Zod generic inference
chains in registerTool(). Affects all Node.js versions.

- Switch build from tsc to tsup (esbuild-based, 12ms builds)
- Add separate typecheck script (tsc --noEmit) which works on all SDK versions
- Add tsup as dev dependency

Ref: modelcontextprotocol/typescript-sdk#985
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tsc OOM: @modelcontextprotocol/sdk >=1.23.0 causes heap exhaustion during build

1 participant