Claude Code 在会话开始时会提前加载所有工具定义,这会消耗大量上下文 token - 特别是对于配置了多个 MCP 服务器、插件和代理的用户。Anthropic 已发布专门为此设计的测试功能:工具搜索工具和程序化工具调用。

相关文档请查看:https://www.anthropic.com/engineering/advanced-tool-use

通过搜索 GitHub - anthropics/claude-code: Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands. 发现使用

export ENABLE_TOOL_SEARCH=1

可以体验这个功能
未使用 ENABLE_TOOL_SEARCH=1 时,上下文占用


Free space 有 47.5% 可用
使用 export ENABLE_TOOL_SEARCH=1 后


Free space 有 64.5% 可用
正常使用 cc 处理问题后,再看占用情况


只加载了 4 个工具,没有使用到的工具和 mcp 不会加载,极大了减少了下文的占用
测试使用的版本信息
claude --version
2.0.76 (Claude Code)


📌 转载信息
转载时间:
2025/12/25 15:14:39