copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

Too many MCP servers results in continuous compaction

Open adithyabsk opened this issue 7 months ago • 3 comments

Describe the bug

The CLI agent can end up in a degenerate state when you enable too many MCP servers that expand past the available context window of the model in question supporting the harness.

The CLI should detect this state and warn the user. In my case, I ended up with 94k / 128k context window consumed by tools

Affected version

GitHub Copilot CLI 1.0.37.

Steps to reproduce the behavior

No response

Expected behavior

No response

Additional context

No response

adithyabsk avatar Apr 28 '26 22:04 adithyabsk

Real-world case: 20+ MCP servers configured in ~/.copilot/

Had a Technical PM hit this exact problem with ~20+ MCP servers configured globally. The symptoms were:

  1. Session startup took extremely long — spawning and handshaking with all MCP servers sequentially
  2. CLI crashes — likely from process/timeout exhaustion during initialization
  3. Severe hallucinations — using Claude Opus 4.6 (200K context), the tool definitions consumed so much of the context window that the model struggled to focus on the actual task

The root issue is that there's no guardrail or feedback — no warning at startup like "You have N tools loaded, consuming ~Xk tokens (Y% of context window)". Inexperienced users can install plugins/MCPs freely and silently degrade their experience without understanding why.

Suggestions:

  • Warn at startup when tool definitions exceed a threshold (e.g., >50% of context window)
  • Show tool token overhead in /env or /context
  • Support MCP profiles (#2235) so users can activate subsets per project instead of loading everything globally

andrii-z4i avatar May 16 '26 07:05 andrii-z4i

Every server loads its full tool definitions into context up front, so the block grows without limit as you add servers.

Disclosure, I build an open-source gateway (Toolport) that fronts your servers with a couple of meta-tools and loads each tool's schema on demand. That 94k tool block drops to a few hundred tokens no matter how many servers you connect.

Rough math if useful, https://toolport.app/calculator

btsouth avatar Jul 10 '26 02:07 btsouth

This appears to be resolved as of GitHub Copilot CLI v1.0.93. Please update to that release or a newer stable version. We're closing this as completed. If it still happens, please comment with your version and reproduction steps.

copilot-cli-bot[bot] avatar Oct 08 '26 10:10 copilot-cli-bot[bot]