mcpproxy-go
mcpproxy-go copied to clipboard
read_cache text chunks: follow-ups from the #2143 review
Non-blocking items from the review of #2143 (text-chunk mode for read_cache, issue #2142). None stops #2143; collected here so they are not lost.
- Forwarded-header scrubbing across a chunk boundary (
internal/server/mcp.gohandleReadCache→scrubResultForRecord). Withforward_headersconfigured, a forwarded value that an upstream echoes and that straddles a 1,000-byte chunk boundary is split across two JSON strings.headerfwd.ScrubRecordremoves the prefix fragment (truncated-prefix rule) but not the suffix, so the suffix can reach the read_cache activity row. Record mode never splits a string. Possible fix: forrecord_path == "(text)", scrub the page's chunks joined (plus a value-length overlap with the neighbouring chunks) before recording. - Child-page banner always suggests
limit=50(internal/truncate/truncator.gorecordBanner). When a read_cache page overflows (e.g. text chunks dense in<,>,&, escaped to 6 bytes each), the child entry's banner asks for 50 records again and an agent that follows it literally gets the same oversize page under a new key. This was already true for record pages; the child banner could suggestmax(1, count/2)instead. read_cachedoes not spotlight (spotlight_untrusted) its pages; text chunks now carry more untrusted tail text through it. This was already true for record pages.- Per-page cost:
getRecordsbuilds and boxes every chunk of the entry on each call before slicing the page;recordPagingCanRebuildmarshals every record and copies the content once more (the PR notes ~2x memory on over-limit responses). - Small items: an over-limit arrayless JSON with an out-of-range number (
1e400) still gets the plain cut with no key; the docs row does not mention the 7,024-byte minimum below which text-chunk mode is off;internal/cache/text_chunks_test.go:75trips staticcheck QF1012 locally (fmt.Fprintfinstead ofWriteString(fmt.Sprintf(...))); the server test walker does not cover resuming the parent key after a child overflow.