mcptoon 0.8.12 — one release, closing out the "promises not kept" family
Added
mcptoon retrieve <handle>— the CLI's half of compression. Every--smartoutput can end
withfull text: mcptoon_retrieve handle=<id>, but that handle was only redeemable from an MCP
session:mcptoon_retrieveis a native MCP tool and the CLI had no counterpart. A shell user (or
an agent driving the CLI, which is how most of mcptoon is used) was told exactly how to get their
data back and then had no command to run. Nowmcptoon retrieve <handle>reads the same store and
prints the same original;mcptoon retrieve --listshows what the store holds. A miss exits 1
with the specific reason (bad-handle/never-stored/expired/unreadable), so
mcptoon retrieve <typo> && …cannot look like it worked.- The failure sentences now live in one place (
ccr.RETRIEVE_NOTICES+ccr.retrieve_notice).
The MCP tool and the CLI answer the same question, so a second copy would be a drift waiting to
happen — and the empty-handle path innative_toolsalready had one, which is how the new
agreement test caught it.
Fixed
--jsonis never char-truncated. The 4,000-character default cap lived in
output.renderand applied to every format, so a JSON payload past it came back with
... [truncated, N chars total, use --full]glued on — which is not a shorter
document, it is invalid JSON. Measured:mcptoon install --list --jsonwas 4,048
bytes andjson.loadsraisedJSONDecodeError;mcptoon install --list --json | jq
fails outright. The default cap now applies only to the formats a human reads in a
terminal (compact/mcptoon/slim/raw);--jsonand--toonare returned
whole, sojson.loadsandtoon_decodeboth round-trip. An explicit--max-chars N
still truncates anything, because there the user asked.--head N,--max-chars Nand--fullare no longer silently ignored. These are
documented global output flags, but several handlers never received them and
output.head()only understood lists — so on a mapping-shaped payload it did nothing.
Measured before the fix:install --list --head 1printed all 3 servers,skills list --head 2printed all 421 skills,install --list --max-chars 500changed nothing.
head()now caps a mapping of records too (first N keys in sorted order, so "the
first N servers" is deterministic rather than file-order), and every handler that
renders a record collection —install,skills list,health,discover,import,
config,stats,report,usage,footer-facts,retrieve— accepts and forwards
the flags.--head Nis now the format-agnostic way to shrink a large payload: it cuts
records, not bytes, so the result stays valid in every format.--fullwas a lie formcptoon install._cmd_installnever receivedfull, so the
truncation notice "use --full" pointed at a flag that changed nothing. Measured:install --list
with and without--fullproduced byte-identical stdout (4,048 bytes, notice still present);
with the fix the same command returns 49,876 bytes and no notice.--rawwas never wired to the safety screen. TheCREDENTIAL_LEAK/TOOL_POISONINGfix
hint says "use --raw to bypass" verbatim, but--rawonly set the output format — the screen
still blocked the result, so the advertised escape hatch did nothing.--rawnow reaches the
router asskip_poisoning_check=True, on both thecallandcall --autopaths; the default
call still screens.--smartonmcptoon installprinted a compressed view with no way back.output.render
was a second compression entry point next tocompressor.compress_with_ccr, and the two had
drifted: the formatter discarded the stats, so a payload could come back cut with no retrieve
handle and nothing saying it had been cut. Measured on this machine,mcptoon install --list
is 32,835 bytes and does compress, so this was a reachable path, not a theoretical one.
_cmd_install's six render sites now go through_render_result— the same pathmcptoon call
uses — so the compressed view carriesfull text: mcptoon_retrieve handle=<id>.output.render(fmt="smart")no longer compresses. It has noserver:toolto key a handle
on, so it cannot honour the contract that makes compression safe: whatever it hides must be
fetchable. It previously compressed and appended an "original not stored" admission — honest
about the loss, but still a loss, and a second entry point. There is one entry point now:
callers that want compression callcompress_with_ccr; callers that reach the formatter get
their payload whole. Anyone relying onrender(fmt="smart")to shrink a payload should call
compress_with_ccrinstead.
Tests
- New
tests/test_machine_readable_output.pypins the two promises above. It checks that
--json/--toonare not char-truncated whilecompact/slim/mcptoonstill are, that an
explicit--max-charsstill wins, thathead()caps a mapping of records in sorted order
without reshaping a mapping of lists, that the CLI's--jsonactually parses, and that
--head/--max-charsshrink the payload. The flag-forwarding rule is checked
structurally — it enumerates everyoutput.render(site incli.py, walks back to the
enclosingdef, and fails if any site drops a global flag — because reading the code to
answer the equivalent reachability question was wrong twice in this repo. - New
tests/test_next_step_works.pypins the three promises above, grouped by the promise rather
than by module: what the output tells the user to do next, and whether doing it works. It checks
that_cmd_installaccepts and forwardsfull, that--rawreachesskip_poisoning_checkon
both routing paths while a normal call still screens, thatmcptoon retrievereturns the original
byte-identically, and that the CLI and the MCP tool answer every failure status with the same
sentence. - New
tests/test_smart_reachability.pypins the rule structurally rather than by inspection:
it enumerates everyrender(call site in the package, walks back to the enclosingdef, and
fails if afmt=fmtcall has nofmtguard in between — i.e. if anything can hand"smart"
to a formatter that cannot return what it dropped. It also assertsoutput.renderis not a
compression entry point and thatcompress_with_ccris. This exists because reachability was
stated wrongly twice from reading the code (first missing thatauto_smart_enabled()makes
calldefault to smart, then missing theelif fmt == "json"branches); the third answer came
from a script, so the script is the durable form.