Skip to content

Skip directory entries when unpacking (fixes mcpb unpack on standard ZIP archives)#268

Open
aosmcleod wants to merge 1 commit into
modelcontextprotocol:mainfrom
aosmcleod:fix/unpack-directory-entries
Open

Skip directory entries when unpacking (fixes mcpb unpack on standard ZIP archives)#268
aosmcleod wants to merge 1 commit into
modelcontextprotocol:mainfrom
aosmcleod:fix/unpack-directory-entries

Conversation

@aosmcleod

Copy link
Copy Markdown

Problem

mcpb unpack aborts on any archive containing explicit directory entries (keys ending in /). Standard ZIP tooling (zip -r, most language libraries) emits these, so unpack fails on the majority of real-world .mcpb files not produced by mcpb pack itself: the trailing-slash write fails with ENOENT/EISDIR and the throw aborts the whole extraction.

Fixes #261.

Fix

Skip directory entries in the extraction loop (src/cli/unpack.ts). Needed parent directories are already created by the existing mkdirSync, so no functionality is lost.

Test

Adds test/unpack.test.ts: builds a ZIP with a server/ directory entry via fflate's zipSync and asserts unpack succeeds and extracts the nested file. Verified the test fails against the old code and passes with the fix. yarn lint and yarn test pass.

ZIP archives produced by standard tooling (e.g. `zip -r`) include explicit
directory entries (keys ending in "/") with empty data. unpackExtension wrote
every entry unconditionally, so the trailing-slash path write failed and aborted
the entire unpack — making `mcpb unpack` unusable on most real-world .mcpb files
not produced by `mcpb pack` itself. Skip directory entries; needed parents are
already created. Adds a regression test using a zip with a directory entry.

Fixes modelcontextprotocol#261
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.

mcpb unpack fails on archives containing directory entries (unusable on standard ZIP/.mcpb files)

1 participant