ShrinkWrap
ShrinkWrap is a local compaction proxy for text returned by MCP tools. It replaces large text blocks with a bounded summary and a sw-ref: handle. The full, redacted payload is kept in a local buffer for later retrieval.
The command line provides a working stdio MCP proxy. The Python package also exposes an HTTP response transformer; it does not start an HTTP listener or intercept arbitrary shell commands.
Install and configure
python3 -m venv ~/.local/share/shrinkwrap/venv
~/.local/share/shrinkwrap/venv/bin/python -m pip install shrinkwrap-cli
export PATH="$HOME/.local/share/shrinkwrap/venv/bin:$PATH"
shrinkwrap install --dry-run
shrinkwrap install
The virtual environment works with a system Python that restricts direct package installs. Put its bin directory on PATH in future shells to use the shrinkwrap command there.
install wraps local stdio server commands in supported MCP client configuration files. It supports Codex's ~/.codex/config.toml and JSON configurations for Claude Desktop, Cursor, Gemini, and Antigravity. Remote URL servers are left alone. For each modified file, ShrinkWrap saves a .swbak copy. You can restore it with:
shrinkwrap rollback ~/.codex/config.toml
For a single server, use shrinkwrap wrap <config-file> --server <name> [--dry-run]. Without --server, wrap handles all local servers in the file. Auto-wrapping uses the Python executable running ShrinkWrap, so a desktop client does not need shrinkwrap on its own PATH. Codex's MCP documentation describes the config.toml server format.
You can also run the proxy directly:
shrinkwrap wrap-stdio -- npx -y @modelcontextprotocol/server-filesystem /path/to/files
What gets compacted
ShrinkWrap examines MCP tool result text blocks. JSON arrays and objects get a count, a bounded sample, and a reference handle. Long text gets bounded head and tail excerpts; tracebacks get selected error lines. Small output passes through after redaction. A candidate summary is used only when its estimated token count is smaller than the redacted output.
Tool results may also contain structuredContent. ShrinkWrap redacts strings in that field but does not compact it, since clients may validate it against a tool's output schema. Redaction can change values in a way that strict schema validators reject. Images, audio, and other non-text content blocks pass through. These cases can limit total response savings. See the MCP tool result documentation for the distinction between content and structuredContent.
Retrieve a payload
shrinkwrap fetch sw-ref:0123456789ab
shrinkwrap fetch sw-ref:0123456789ab --pointer /rows/10
shrinkwrap fetch sw-ref:0123456789ab --pointer /rows --offset 0 --limit 4000
The handle retrieves the redacted payload. --pointer selects a JSON value using RFC 6901; --offset and --limit return a bounded character chunk with next_offset for paging. Chunks of an object or array are fragments of its serialized JSON and can be joined before parsing.
The stdio proxy also advertises a shrinkwrap_fetch MCP tool when the wrapped server does not already use that name. An agent can call it with ref_handle and optional pointer, offset, and limit arguments. It returns up to 4,000 characters by default, with a 16,000-character maximum per call. Follow next_offset to read more. The HTTP transformer does not advertise this tool. The MCP tools specification defines the discovery and call messages used here.
Files live in ~/.shrinkwrap/buffer/ by default. Set SHRINKWRAP_STATE_DIR before launching the proxy and CLI to put the buffer and analytics in another directory. Large entries that compress well are stored as gzip JSON; existing plain JSON entries remain readable. Entries expire after one hour by default and are removed during periodic cleanup or when an expired handle is fetched. Set SHRINKWRAP_TTL_SECONDS to a positive number to change the TTL. Buffer directories and new files are owner-only.
Redaction handles common token formats, private key blocks, bearer values, and named credential fields. It is best effort. Check outputs before using ShrinkWrap with unusually sensitive data. ShrinkWrap itself sends no payloads or analytics to a remote service.
Measure your workload
shrinkwrap benchmark
shrinkwrap gain
shrinkwrap session --markdown
benchmark runs seven synthetic payloads, including single-line and large-field cases that previously expanded. The current corpus shows roughly 98.9% reduction by a character and word heuristic, not a model tokenizer. The corpus and local execution time do not predict savings or latency for your tools. Benchmark runs use a temporary buffer and do not add events to your analytics.
gain and session report estimated tokens saved by actual proxy calls. Financial figures use a fixed $3.00 / 1M tokens assumption and are estimates, not billing data.
Commands
| Command | Purpose |
|---|---|
shrinkwrap install [--dry-run] |
Discover and wrap supported local MCP configs |
shrinkwrap wrap <file> [--server name] [--dry-run] |
Wrap a config file or one named server |
shrinkwrap rollback <file> |
Restore its .swbak backup |
shrinkwrap wrap-stdio -- <command> [args] |
Proxy a stdio MCP server |
shrinkwrap fetch <sw-ref:handle> |
Retrieve a buffered redacted payload |
shrinkwrap benchmark |
Run the synthetic compaction suite |
shrinkwrap gain [--history] [--json] |
Show cumulative estimated savings |
shrinkwrap session [--markdown] [--json] |
Show session estimated savings |
shrinkwrap status |
Show installed version and available components |
Development
See Contributing for tests and releases, the architecture guide for message and buffer behavior, and the changelog for release notes.
python3 -m venv .venv
.venv/bin/python -m pip install -e . pytest
.venv/bin/python -m pytest -q
License
MIT. See LICENSE.
Metadata
Release files for shrinkwrap-cli 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| shrinkwrap_cli-0.1.5.tar.gz | 35.0 kB | With provenance | Details for shrinkwrap_cli-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| shrinkwrap_cli-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for shrinkwrap_cli-0.1.5-py3-none-any.whl |
Total release size: 64.3 kB
Release files / shrinkwrap_cli-0.1.5.tar.gz
| Download URL | shrinkwrap_cli-0.1.5.tar.gz |
|---|---|
| Size | 35.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0cc481d3bf16d226b2e5e63853dacdd335906c6743ae180b4fba6171bec53d66
|
|
BLAKE2b-256 checksum How to use checksums |
6d5ad9d283f7a012fac2cecd95215e4a394a8e2d9673d39c80081841c9218496
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logRelease files / shrinkwrap_cli-0.1.5-py3-none-any.whl
| Download URL | shrinkwrap_cli-0.1.5-py3-none-any.whl |
|---|---|
| Size | 29.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
706c6bd92872dfa6966a97bab7dcb63624d48102f5abaac5fb176ac6136310d8
|
|
BLAKE2b-256 checksum How to use checksums |
31e6b732919e323f0b31b617f6cbbc453d7a4fec2f925f86ea2bdefd8cf039f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logSecurity for shrinkwrap-cli 0.1.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for shrinkwrap_cli-0.1.5.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.