Merge archives (no recompression)
merge_zipMerge 1–32 ZIP archives into one without recompressing, copying selected entries intact with CRC checks and name-conflict handling.
Instructions
Merge 1–32 archives into one WITHOUT recompressing anything: zipnative's addFromReader() transplants each entry's compressed bytes with its method, CRC, sizes, timestamp, attributes, comment and extra fields, in O(bytes copied). Each source is zipBase64 XOR zipPath with an optional filter. Every entry is CRC- and size-checked before it is copied (verify, default true), so a corrupt payload is refused with its ZIP_* code instead of being propagated; an entry whose method has no codec here (ZIP_UNSUPPORTED_METHOD) and encrypted entries are refused. A foreign name the writer will not accept (e.g. a bsdtar './'-prefixed entry) is ZIP_INVALID_ENTRY_NAME — exclude it with that source's filter. Name collisions: onConflict 'error' (default, ZIP_DUPLICATE_ENTRY_NAME), 'first' or 'last' (summary.dropped lists what was not kept). order 'canonical' (default) sorts like create_zip. Run canonicalize_zip on the result for the full canonical form. Output base64 or a sandbox file (streamed).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| order | No | 'canonical' (default): entries sorted by raw name bytes, as create_zip writes them; 'insertion': the sources' order, then each source's central-directory order. | canonical |
| limits | No | Per-call override of zipnative's security bounds (CWE-400/409); absent keys keep the engine defaults (describe_engine.defaultLimits). A value above its operator ceiling is LIMIT_CEILING_EXCEEDED. Raise only for trusted input. | |
| strict | No | Turn the first engine diagnostic into a ZIP_STRICT_DIAGNOSTIC error. | |
| verify | No | Decompress each entry once to check its CRC and size before copying it (secure by default: a corrupt entry is refused with ZIP_CRC_MISMATCH / ZIP_SIZE_MISMATCH instead of being propagated). false trusts the sources — their bytes travel as they are. | |
| comment | No | Archive comment of the result (UTF-8, ≤ 65535 bytes). Default none — the sources' comments are not merged. | |
| sources | Yes | The archives to merge, in order (1–32; total ≤ 1073741824 bytes, inline payloads ≤ 134217728 bytes in all). Each is zipBase64 XOR zipPath, with an optional filter selecting the entries taken from it (directories are kept unless the filter excludes them). | |
| onConflict | No | Two entries with the same name: 'error' (default) — the engine refuses the second with ZIP_DUPLICATE_ENTRY_NAME; 'first' / 'last' — keep the first / last occurrence across the sources in order, the others are reported in summary.dropped. | error |
| outputMode | No | 'base64' (default): inline embedded resource (≤ 50 MiB; the bytes appear in both its data: uri and its blob). 'file': written into the sandbox (never overwrites; ≤ ZIPNATIVE_MCP_MAX_FILE_OUTPUT_BYTES, default 4 GiB) and returned as a resource_link — far fewer tokens. | base64 |
| outputPath | No | Relative path inside the sandbox (only when outputMode='file'); must end in a container extension (.zip recommended). | |
| includeSha256 | No | Add `summary.sha256` of the produced bytes. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | Yes | ||
| summary | Yes | merge_zip summary. | |
| filePath | No | Sandboxed absolute path (file mode). | |
| sizeBytes | Yes | ||
| diagnostics | Yes | Non-fatal engine concerns (de-duplicated by code + entry, ≤ 200; codes in describe_engine.diagnosticCodes). Empty for a clean archive. | |
| diagnosticCounts | No | Occurrences per code, duplicates included. | |
| diagnosticsTruncated | No | true when rows beyond 200 were dropped. |