fix: replace tsc with tsup to resolve OOM during build - #2
Open
Ostico wants to merge 1 commit into
Open
Conversation
@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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1 —
npm run build(tsc) crashes with JavaScript heap out of memory due to exponential type expansion in@modelcontextprotocol/sdk >=1.23.0.Changes
tscwithtsup(esbuild-based) for the build step — builds in 12mstypecheckscript (tsc --noEmit) for optional type checkingtsupas dev dependency@modelcontextprotocol/sdkat 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 SDK1.23.0—1.22.0is the last version wheretsccompletes.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
tsupthe correct solution.Testing
Upstream reference: modelcontextprotocol/typescript-sdk#985