fuqiuluo’s blog

记录美好生活

心情随笔

TRAE突破MCP工具数量上限

#开发#逆向#TRAE
type
Post
status
Published
date
Jun 10, 2026
slug
summary
突破TRAE IDE的MCP工具数量上限,不再局限于40个工具!伟大的突破!
tags
开发
逆向
TRAE
category
心情随笔
icon
password
😀
公司内部TRAE很好用,无限的GPT 5.5 [1m],很爽,但是Trae的IDE为什么只能有40个工具 这让我很不爽!于是乎尝试分析突破工具数量上限!

📝 目标

宇宙安全声明

本文仅提供学习与交流用途!禁止用于违法用途!

🤗 定位过程

主逻辑位置

Trae CN是Electron应用:
  • Electron壳:/Applications/Trae CN.app/Contents/MacOS/Electron
  • 主进程入口:/Applications/Trae CN.app/Contents/MacOS/Resources/app/out/main.js
  • 前端Workbench/bundle:/Applications/Trae CN.app/Contents/Resources/app/node_modules/@byted-icude/ai-modules-chat/dist/index.mjs
  • AI Agent native:/Applications/Trae CN.app/Contents/Resources/app/modules/ai-agent/libai_agent.dylib
  • MCP/toolhost native:/Applications/Trae CN.app/Contents/Resources/app/modules/ai-agent/bin/agent-tool-host

默认配置

product.json 内存在默认限制:
已改为:
实测发现,仅修改 product.json 不足以解除 UI 限制,因为运行时动态配置仍可能覆盖为 40

前端限制点

前端 bundle 中原始表达式:
该值参与:
  • MCP tools 总数统计
  • 超限提示
  • 选择阻断
已 patch 为:
效果:
  • 当前组件内上限 A 固定为 1000
  • 同时写回 productService.iCubeApp.aiFeatures.mcpToolLimit=1000
  • 前端显示和后续同对象读取都使用 1000

后端动态配置点

agent-tool-host 字符串和 IDA 分析确认其支持:
IDA 中确认字段映射:

补丁详情

product.json

目标:
修改:
修改后权限:

前端 bundle

目标:
修改:
语法校验:
结果:通过。

agent-tool-host wrapper

原始 Mach-O 已移动为:
当前 wrapper:
文件类型:

start.sh

目标:
已在正式启动分支加入:
这样即使 toolhost 不是直接通过 wrapper 子进程继承,也能从 ai-agent 启动环境继承配置路径。

动态配置文件

目标:
注意:最初只写:
会失败:
改成:
又继续失败:
最终使用 product.json 中完整 iCubeApp 结构,并覆盖:
同时补齐:

验证证据

配置文件未被覆盖

检查结果:

当前 Agent 实际可用 MCP tools 数

当前会话实际暴露:
已实际调用成功:

后端动态配置注入验证

独立启动 toolhost 到临时端口 9199
成功日志:
该验证证明:
  • wrapper 生效
  • AGENT_TOOL_HOST_IDE_DYNAMIC_CONF_FILE 被读取
  • 动态配置 JSON 结构被 toolhost 接受
  • 后端本地配置注入链路可用

重启后验收

完整退出并重新打开 Trae CN 后执行:
期望看到:
如果仍看到:
说明当前启动链路没有经过 wrapper/start.sh 注入,需要继续查 ai-agent 启动方式或父进程环境。

已知限制

本地破限覆盖的是:
  • 前端 UI 选择限制
  • 本地 agent-tool-host 可读取的动态配置
  • 本地 toolhost 中 DynamicConfigAiFeatures.mcpToolLimit
但如果最终限制发生在云端,例如:
那么本地前端和本地 toolhost 只能绕过 UI 与本地配置,不能保证云端策略也接受超过 40 个 tools。
判断云端限制的方式:
  • 前端 UI 不再提示 40
  • 本地日志显示 ide dynamic config load from file
  • 发起 agent 任务仍失败,且错误来自 agent/v3 或 cloud agent endpoint
若出现该情况,需要继续分析请求 payload 或云端返回配置。

回滚方式

回滚 product.json

9.2 回滚前端 bundle

9.3 回滚 agent-tool-host

或直接恢复 .real

9.4 回滚 start.sh

10. 当前状态摘要

当前本地状态:
下一步建议:
  • 完整重启 Trae CN
  • 检查最新 ai-agent_*_stdout.log
  • 确认 ide dynamic config load from file
  • 发起超过 40 tools 的 MCP agent 流程做实测
Loading...