MCPBビルドでhoistedな依存レイアウトを使う#16
Open
Sinhalite wants to merge 1 commit into
Open
Conversation
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.
概要
MCPB生成時に、pnpm標準のsymlink layoutではなく、pack前だけproduction依存をhoisted layoutで入れ直すようにしました。あわせて、MCPB CLIを
@anthropic-ai/mcpb@2.1.2に更新しています。背景
ビルドしたMCP BundleをClaude Desktopに登録すると、
initialize送信後にサーバーtransportが閉じ、MCPサーバーが早期終了する状態になっていました。ローカルで
dist/index.jsを直接起動すると問題なく動作しましたが、MCPBを展開したディレクトリから起動すると、以下のように@modelcontextprotocol/sdkの依存解決に失敗しました。pnpm標準layoutでは依存の実体が
node_modules/.pnpm配下に置かれ、rootのnode_modules/*はsymlinkになります。MCPB pack後に展開するとこの参照関係が崩れ、.pnpm配下に依存は存在していても、Nodeの通常のmodule resolutionではajv-formatsなどを見つけられない状態になっていました。変更内容
node_modulesを削除pnpm install --prod --frozen-lockfile --config.node-linker=hoistedでproduction依存をhoisted layoutとして再インストール@anthropic-ai/mcpbを1.1.1から2.1.2に更新npx @anthropic-ai/mcpb@2.1.2 packを直接使うように変更検証
一時ディレクトリで同等手順を実行し、生成したMCPBを展開したうえで、展開先の
dist/index.jsをSDKクライアントから起動しました。また、通常pnpm layoutで生成したMCPBでは約70.7MBだったpackage sizeが、hoisted layoutでは約20.2MBまで小さくなることも確認しています。これは
.pnpm配下とroot側の依存が重複してpackされることを避けられるためです。