Dynamic MCP Tool Loading to Reduce Context Window Consumption
- 主要语言
- 没有语言数据
- 星标
- 2.1k
- 派生
- 153
- PR 合并指标
- 30 天内没有已合并 PR
描述
### Feature summary
Currently, all MCP tool definitions from all connected servers are included in the context window on every turn, regardless of whether they are relevant to the current task
### What problem are you trying to solve?
---
### Problem
All MCP tool definitions from all connected servers are included in the context window on every turn, regardless of whether they are relevant to the current task. In environments with multiple MCP servers, this can result in **hundreds of tool schemas consuming tens of thousands of tokens** before any conversation content is processed.
This means:
- Significantly reduced capacity for actual code, diffs, file content, and conversation history
- Earlier context truncation in long sessions
- Wasted tokens on tools that will never be invoked in a given session
- Degraded quality on complex tasks that need deep context
---
### Proposed solution
### Proposed Solution
Provide mechanisms to selectively load/unload MCP tools to minimize context window usage:
1. **Per-session tool profiles** — Allow users to define named profiles (e.g., "code-review", "incident-triage", "deployment") that only load relevant MCP servers/tools.
2. **Lazy/on-demand tool loading** — Only include a tool's full schema in context when it's first needed. Use a lightweight tool registry (name + one-line description) for discovery, expanding the full schema only when invoked.
3. **Session-scoped enable/disable** — A command to toggle MCP servers on/off mid-session without restarting.
4. **Task-based auto-selection** — Intelligently infer which MCP servers are relevant based on the user's first message and only load those.
5. **Tool grouping within servers** — Allow disabling subsets of a server's tools rather than all-or-nothing per server.
### Impact
- Frees significant context capacity for actual work content
- Improves response quality on context-heavy tasks (large code reviews, multi-file changes)
- Reduces latency (fewer tokens to process per turn)
- Better user control over their tool environment
### Workflow impact
_No response_
### Installation context
_No response_
### Additional context
_No response_
贡献指南
调研方向
该 issue 未指定任何文件、测试或入口点。首先定位现有的 MCP 工具注册和上下文组装,然后将提案收敛为一种机制,并为上下文窗口的使用和会话行为制定明确的验收标准。
由索引模型根据 Issue 内容生成。
评估
- 领域
- ai, desktop
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 活跃
- 描述清晰度
- 需要澄清
- 新手友好度
- 30/100