Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

I was paying to send 27 unused tools to Claude. So I filtered them.

说明与用途

作者发现 Claude Code 每次请求都会发送 27 个工具定义,导致高昂的令牌成本。他们构建了一个基于正则表达式的本地代理,过滤掉未使用的工具,将令牌使用量降低了 75%,并将月度成本从 $200 降至 $50。

问题

Claude Code sends 27 tool definitions with every single request, consuming ~1,200 tokens of JSON schemas even for simple tasks like fixing a typo. This results in paying for unused tool definitions, causing high API costs.

结果

By implementing a local proxy that filters tool definitions based on message content, the author reduced token usage by 75% (from 1,200 to 300 tokens per request) and cut monthly API costs from $200 to $50. The solution uses simple regex matching and requires no LLM calls for classification.

工作流

  • Clone the Dynamic Tool Proxy repository from GitHub.
  • Install required dependencies (fastapi, httpx, uvicorn).
  • Run the standalone proxy script on port 8090.
  • Configure the Claude Code client to use the proxy as the base URL (ANTHROPIC_BASE_URL=http://localhost:8090).
  • The proxy analyzes the user's message using regex to determine the required tool category.
  • The proxy forwards only the relevant tools to the API provider.
  • The provider processes the request and returns the result.
  • The proxy passes the response back to the client.

证据

Cost went from $200 to $50. Same code. Same quality.

来源

WITHOUT proxy: 27 tools ~1,200 tokens WITH proxy: 6 tools ~300 tokens Saved: ~900 tokens per request (75%)

来源

I tracked it for a week. Here's what I saw: Monthly cost saved $150

来源

  • 记录日期: 2026-09-06T17:22:19.694Z