Caveman Shrink
caveman-shrink compresses MCP and OpenAI tool catalogs. It keeps the selection surface byte-for-byte and removes annotation bulk around it.
Tool catalogs spend tokens on examples, titles, defaults, $schema, and long descriptions. Shrink strips or truncates those fields while keeping names, types, enums, and required flags. It wraps the engine's forced-only toolschema compressor.
The selectability invariant
This is the whole point, and a conformance test asserts it:
SelectionProfile(input) == SelectionProfile(Shrink(input).Output)Tool selection is a function of the selection surface alone — tool and parameter names, types, enums, and which params are required. Shrink never touches any of that. So a compressed catalog exposes the identical selection surface as the original, and the model picks the same tool from either. What gets smaller is the annotation around the surface, not the surface itself.
S4lossy · recoverable Compression is lossy but recoverable. A real shrink stores the original catalog under a CCR handle, so the dropped detail can be recovered to the byte.
Use it
Shrink reads a catalog on stdin and writes the compressed catalog to stdout. The inferred ratio report goes to stderr, so it stays out of your piped output.
go build -o caveman-shrink ./public/shrink/cmd/caveman-shrink
# Compress a catalog; stdout is the result, stderr is the inferred report.
cat tools.json | ./caveman-shrink > tools.min.json
# Inspect per-tool reductions without committing to the result.
./caveman-shrink lint tools.jsonlint <file> prints the inferred per-tool token reduction so you can see where the bloat is before you compress.
How it stays honest
Same selection, byte-safe, reversible
Selectability is invariant — every selection token survives byte-for-byte, so tool choice cannot regress (a conformance test proves it).
Byte-safe — a malformed or incompressible catalog passes through unchanged with ratio: 0 and no handle. The CLI forwards the original bytes rather than failing.
inferred-only — token counts come from the engine's offline counter. They are local estimates, never verified and never re-projected.
Reversible — a real shrink stores the original under a CCR handle; nothing is destroyed.