Tool-result size governor for MCP
By TextForAgents LLC. MCP defines no limit on tool-result size, so one unbounded result from a third-party server you don't control can blow your agent's entire context window — or deadlock its stdio transport. Every published fix is server-side — useless across the third-party servers you cannot patch. This governor is a client-side proxy you point your agent at once, in front of any MCP server.
Quickstart
pip install tool-result-size-governor
# run your MCP client against the proxy instead of the server:
tool-result-governor-proxy -- python3 your_mcp_server.py
State (spill artifacts, your receipt-signing key, the denial
registry) lives under $TRSG_HOME (default
~/.tool-result-size-governor).
Demo against the bundled fixture server (the CARD-051 failure population — an unpaginated list tool and a big log tool):
tool-result-governor-proxy -- python3 -m tool_result_governor.fixture_server
Call list_papers with {"count": 500}: the proxy returns a bounded
50-record window plus an in-band signed omission receipt; re-fetch a
narrower slice byte-exact with the proxy's local
governor_fetch_slice tool; re-firing the identical query is denied
while the spill lives.
What it does
- Per-route ceilings in bytes / records / tokens; structure-aware windowing (array slices with total/returned/omitted counts, log head+tail, prose sectioning).
- The full payload spilled to a checksummed expiring artifact with a fetch-narrower-slice route.
- An HMAC-signed omission receipt on every shaped result proving what
was held back — never silent truncation. Receipt
expires_atis an upper bound: bounded-store eviction can retire an artifact earlier, in which case a fetch returns a cleanunknown_artifacterror and the identical query re-opens exactly once. - A repeat-everything denial that lives exactly as long as its spill.
- Backpressure-safe forwarding so a 2 MB result cannot SIGPIPE the session (lab: 2,112,780-byte result, client bytes bounded at 24,469, no deadlock).
Hosted form
The same governor is available as a hosted per-result API ($0.001/result, x402; Operator $9/mo, Fleet $29/mo; first 100 shaped results free, one time per operator) at https://textforagents.com/products/tool-result-size-governor/ — support: support@textforagents.com.
License: MIT (see LICENSE). Copyright (c) 2026 TextForAgents LLC.
Metadata
Release files for tool-result-size-governor 1.0.0
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 | |
|---|---|---|---|---|
| tool_result_size_governor-1.0.0.tar.gz | 13.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tool_result_size_governor-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.8 kB
Release files / tool_result_size_governor-1.0.0.tar.gz
| Download URL | tool_result_size_governor-1.0.0.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1e7fbdff7b371702ab02569a131740caa077c63dbda2db2aba80ff1c4021a96d
|
|
BLAKE2b-256 checksum How to use checksums |
24a42af66939e88a2122c796179ed93282e16578d340b390753fbc1a7b8ee253
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / tool_result_size_governor-1.0.0-py3-none-any.whl
| Download URL | tool_result_size_governor-1.0.0-py3-none-any.whl |
|---|---|
| Size | 13.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
51afa663cc9a9cce2bec37896138465c414df656aeb8b394ca8960dc0e625fac
|
|
BLAKE2b-256 checksum How to use checksums |
20cd9f9b642fb0da57f7ad7136530bfff320481a7f00439ec469c5795bbe497a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for tool-result-size-governor 1.0.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.