Polycracker Guides · MCP & Payloads
Fix LLM Input/Output Bloat (MCP)
Model Context Protocol servers made it trivial to plug databases, browsers, and repos into agents—and equally trivial to attach megabyte-scale JSON to every turn. This guide audits MCP bloat on both input and output sides, shows token math for obese tool schemas, and explains how Polycracker ECU rewrites payloads at the wire while Polydyno proves you did not break tool fidelity.
Input bloat vs output bloat
Input bloat arrives before the model answers: tool definitions duplicated on every request, giant
tools arrays in chat completions, pasted file trees, and prior tool results replayed verbatim.
Output bloat is what the model and tools emit back: stack traces, HTML dumps, thousand-line JSON arrays,
and overly chatty assistant preambles. MCP intensifies both—it standardizes connectivity but not payload discipline. Fixing
bloat requires treating tool IO like API design with pagination, field masks, and budgets.
Start by classifying a single agent turn with the measurement steps in how to test LLM token usage. If tool definitions alone exceed three thousand tokens, schema diet comes before AST pruning. If completion tokens dominate, tighten response templates and forbid echoing full tool payloads in assistant text.
Token cost of an obese MCP mounting
A typical IDE session mounts twelve MCP tools across Git, Postgres, browser, and custom internal APIs. Each tool ships a JSON
Schema with nested properties, examples, and enums. Those definitions ride along on every model call,
not once per session.
| MCP surface | Schema tokens (per call) | After ECU trim | Savings |
|---|---|---|---|
| Git (4 tools) | 1,840 | 620 | −66% |
| Postgres (3 tools) | 2,200 | 580 | −74% |
| Browser (2 tools) | 1,100 | 310 | −72% |
| Internal CRM (3 tools) | 3,400 | 950 | −72% |
| Total definitions | 8,540 | 2,460 | −71% |
At two hundred agent calls per engineer per day, that definition delta alone is 1.2M tokens daily per seat before anyone runs a query. Multiply across a department and MCP schemas become a line item comparable to model upgrades.
// Bloated tool result returned to the model (truncated)
{
"tool": "postgres_query",
"content": [
{
"type": "text",
"text": "[{ \"id\": 1, \"payload\": { ... 4000 chars ... }}, ... 200 rows ]"
}
]
}
// After ECU result cap + field mask
{
"tool": "postgres_query",
"content": [
{
"type": "text",
"text": "{\"rows\": 200, \"sample\": [{\"id\":1,\"status\":\"open\"}], \"next_page\": \"cursor://abc\"}"
}
]
}
Schema diet without breaking agents
Never delete required fields the model must set—shrink metadata instead. Collapse redundant enums, move lengthy descriptions to server-side docs, split mega-tools into focused operations, and lazy-mount tool groups per workflow profile in The Tuning House. ECU can strip decorative schema keys at the proxy while preserving validation hashes so clients still know what was removed.
For dynamic tools, version schemas and pin models to a schema revision in your tune map. That prevents silent drift when a platform team ships a “helpful” three-page tool description overnight.
Output-side caps and summarization
Tool outputs should obey byte and token ceilings. Return previews plus cursors, not full datasets. Summarize HTML to headings and form fields relevant to the task. Strip base64 blobs unless the user explicitly requested media. On the assistant side, disallow repeating entire tool JSON in natural language—models love to narrate what they just fetched, doubling output tokens for zero gain.
When outputs must be large, stream them to local disk via ECU and pass the model a stable handle. The IDE reads the full artifact; the frontier model sees a pointer. That pattern alone can cut output fifty percent on browser and log tools.
Worked session: MCP + AST combined bloat
| Layer | Stock prompt tokens | Tuned prompt tokens |
|---|---|---|
| System + developer messages | 1,200 | 1,200 |
| MCP tool definitions | 8,540 | 2,460 |
| Prior tool results in history | 12,600 | 2,800 |
| Source AST attachments | 9,400 | 3,100 |
| Total input | 31,740 | 9,560 |
| Completion tokens (same task) | 1,280 | 620 |
Combined input shred here is about seventy percent; output fell because the model stopped parroting entire query results. Verify both sides with Polydyno profiles so you do not trade bloat for broken tool use.
Wire-level fixes with Polycracker ECU
Polycracker ECU integrates at MCP and HTTP proxy layers. It can prune AST attachments, compress history, rewrite tool lists to the active subset for the workflow, truncate tool results, and log before/after token estimates for auditors. Maps from The Tuning House define which MCP servers are eligible per project and which field masks apply to each tool name.
Because ECU runs locally, sensitive query results never need to be expanded back into the cloud for the model to reason about them—you control what crosses the wire.
Checklist before shipping a new MCP server
- Measure schema token weight in isolation; target under four hundred tokens per tool.
- Document long prose in README, not in
descriptionfields the model reads every call. - Implement pagination on every list/search tool; default page size under fifty records.
- Add server-side field masks; reject unbounded SELECT * patterns.
- Run Polydyno tool-invariant tests; fail CI if prompt tokens exceed signed caps.
- Register the server in a Tuning House profile—do not mount all tools globally.
Interaction with thrash and shred programs
MCP bloat often triggers agent thrashing: the model drowns in prior tool output and retries identical queries. Fixing schemas and caps lowers growth rates so circuit breakers fire less often. Pair MCP hygiene with AST shred from decreasing token usage fifty to seventy percent for compounding savings.
Enterprise rollouts should treat MCP registration like production API gateways—only approved tools, signed maps, and periodic Polydyno audits. Questions on compliance or custom MCP middleware: contact via ECU intake.
Caching, duplicates, and prompt prefix tricks
Some providers discount repeated prompt prefixes. That helps static system prompts but rarely covers MCP definitions that change daily. Do not confuse cache hits with structural efficiency—you might still ship eight thousand tokens of tools on every call even if the system prompt is free. Deduplicate identical tool results in history instead of relying on vendor caching to bail out sloppy orchestration. ECU can hash tool outputs and replace duplicates with a one-line reference while keeping enough context for the model to continue reasoning.
Anti-patterns in popular MCP templates
Copy-paste MCP starters often include verbose JSON Schema examples for every field “to help the model.” Move examples into eval fixtures, not live schemas. Browser tools that return full DOM trees should default to accessibility snapshots under two kilobytes. Database tools should forbid free-form SQL strings in favor of parameterized queries with explicit column allowlists—both for security and because wide result sets balloon tokens instantly. Git tools that return entire diffs for megabyte merges should stream patch summaries with expandable handles in the IDE, not in the model context.
# ECU tool manifest snippet (workflow: incident-triage)
allowed_tools:
- postgres.query_masked
- logs.tail
- git.diff_summary
deny_tools:
- browser.full_dom
- postgres.raw_export
max_tool_result_tokens: 1200
Measuring output bloat separately
Track completion tokens per tool class. Browser and log tools frequently cause the model to echo huge payloads in assistant prose even after you trimmed inputs. Add system-level instructions forbidding verbatim repeats, and enforce post-processors in ECU that collapse known patterns. If output tokens remain high while inputs are lean, the problem is prompt discipline, not MCP wiring— revisit agent templates before mounting more tools.