mcpproxy-go icon indicating copy to clipboard operation
mcpproxy-go copied to clipboard

read_cache text chunks: follow-ups from the #2143 review

Open Dumbris opened this issue 2 days ago • 0 comments

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.

  1. Forwarded-header scrubbing across a chunk boundary (internal/server/mcp.go handleReadCache → scrubResultForRecord). With forward_headers configured, a forwarded value that an upstream echoes and that straddles a 1,000-byte chunk boundary is split across two JSON strings. headerfwd.ScrubRecord removes 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: for record_path == "(text)", scrub the page's chunks joined (plus a value-length overlap with the neighbouring chunks) before recording.
  2. Child-page banner always suggests limit=50 (internal/truncate/truncator.go recordBanner). 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 suggest max(1, count/2) instead.
  3. read_cache does not spotlight (spotlight_untrusted) its pages; text chunks now carry more untrusted tail text through it. This was already true for record pages.
  4. Per-page cost: getRecords builds and boxes every chunk of the entry on each call before slicing the page; recordPagingCanRebuild marshals every record and copies the content once more (the PR notes ~2x memory on over-limit responses).
  5. 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:75 trips staticcheck QF1012 locally (fmt.Fprintf instead of WriteString(fmt.Sprintf(...))); the server test walker does not cover resuming the parent key after a child overflow.

Dumbris avatar Dec 04 '26 05:12 Dumbris