This is a solid approach. The head/tail truncation pattern is elegant — keeping the context where errors usually surface while dropping the noisy middle. I've been thinking about a similar problem from a different angle: when you're running long scraping jobs via MCP, the log output can get massive. A token-aware middleware like mcp-headroom could slot right into that pipeline.
Curious — have you tested this with Docker build outputs? Those tend to be the worst offenders for context bloat.