A copyable MCP tool-cost check for CI, with passing and failing examples
说明与用途
在 CI 中检查 MCP 工具定义的 token 增长的自动化检查,包含通过和失败的示例。
问题
Tool definitions can shrink while schemas grow, hiding regressions in total token counts.
结果
The check passes when definitions shrink and fails when they grow beyond the 10% threshold, providing a CI gate for tool-definition token growth.
工作流
- Create isolated directory and Python 3.11 virtualenv
- Install aimarket-histor[cost]==0.3.1 and tiktoken==0.14.0
- Run fetch_textokit.py to download before and after tool lists
- Run histor tool-cost snapshot to create baseline JSON
- Run histor tool-cost check with --max-increase 10% to validate passing case
- Run histor tool-cost check in reverse to demonstrate failure
- Integrate check into CI by installing tool-cost checker and running histor tool-cost check with --stdio or --tools
证据
HISTOR change 28848 records a change to textokit's remote MCP endpoint observed on 24 October 2026 at 19:52 UTC.
Expected exit code: 0. The total, descriptions and input schemas all became smaller.
Expected exit code: 1, with three reported problems: Full definitions: +1,789 tokens / +47.4%.
- 记录日期: 2026-10-25T09:12:27.961Z