最新资讯
reddit.com OpenAI 称 Astra 仅满足 10% 安全任务标准 dev.to FreeToken:在自有 GPU 上运行前沿 MoE 模型及其内存需求 dev.to 当 AI Agent 说“完成”时,究竟完成了什么? dev.to 部署 Underdog Bark 3.0 Pro:逐字转写、自定义后端与分块设置 dev.to 为艰难对话构建 AI:五个 Agent、一条安全正则与一位盲评监督者 techcrunch.com Palo Alto Networks 洽谈以 5 亿美元收购 AI Agent 安全初创公司 Clutch theinformation.com 黄仁勋被要求就涉华间谍指控向国会作简报 www.infoq.com Edera 推出 Object Capability Bounded Authority,试图将凭证与 AI Agent 工作负载隔离 wechat 这波杀疯了!旗舰级模型不限量、1个月视频额度免费领 bloomberg.com AI 抛售蔓延至信用市场,软银领跌亚洲美元债 dev.to 如何在专用 GPU 服务器上用 OpenAI 兼容 API 部署 LLM dev.to 审计 153 份 Claude Code 与 Codex 会话记录:User-Agent 与 URL 中的邮箱泄露
多元动态
登录 注册
AI编码 dev.to · @Thomas Tartrau

MCP RTK:削减 90% 的 MCP 服务器 token

原文 我的收藏

作者日常使用 Claude Code 并接入 GitLab、Grafana、Sentry 等 MCP 服务器,指出每次 MCP 调用都会向上下文注入数万 token,成本快速上升。为此其开发了 MCP RTK——一个用 Rust 编写的 MCP 代理,位于 Claude Code 与 MCP 服务器之间,在响应到达模型前进行过滤。作者称在 38000+ 次命令中节省了超过 2.67 亿 token。文章还列举了 MCP 响应过大的原因:空值或 null 字段、内部时间戳与分页 ID 等元数据、超长日志/HTML/完整 diff,以及远超所需的数组条目。

AI推荐理由 针对 MCP 调用注入大量 token 的实际痛点,作者提出用 Rust 编写的 MCP 代理 MCP RTK,在 Claude Code 与 MCP 服务器之间过滤响应,并给出 38000+ 次命令、节省超 2.67 亿 token 的自述数据。问题描述具体、方案方向明确,对使用 MCP 的开发者有参考价值;但数据来自作者个人使用,无第三方验证,标题中的“削减 90%”属作者主张,需谨慎看待。

66

正文

I use Claude Code every day for development. Like many developers, I've connected several MCP servers (GitLab, Grafana, Sentry...) to give Claude direct access to my tools. The problem: every MCP call injects tens of thousands of tokens into the context, and the bill spirals fast. I built MCP RTK to fix this. It's an MCP proxy written in Rust that sits between Claude Code and MCP servers, filtering responses before they reach the model. Result: over 267 million tokens saved across my 38,000+ commands. The problem: oversized MCP responses The MCP protocol (Model Context Protocol) lets Claude interact with external tools. When Claude calls an MCP tool, the server returns a JSON response. The issue is that these responses often contain: empty or null fields that add nothing technical metadata (internal timestamps, pagination IDs, HTTP headers) very long values (full logs, HTML descriptions, entire diffs) arrays with dozens of entries when 5 would suffice A single list_issues call on GitLab can consume over 180,000 tokens. Claude only needs a fraction to answer the question. The rest is pure waste. Over a typical work session with 50 to 100 MCP calls, that easily adds up to 500,000 wasted tokens injected into the context. The solution: an 8-step filtering proxy MCP RTK sits transparently between Claude Code and MCP servers. No workflow change needed: Claude keeps calling the same tools, but responses pass through a filtering pipeline before reaching the context. The pipeline has 8 steps: Remove null and empty fields - fields without values are stripped Truncate long strings - values exceeding a configurable threshold are cut Field whitelist - only useful fields are kept Field blacklist - known useless fields are removed Deduplication - identical entries are merged Array compression - long arrays are sampled Technical metadata removal - API-internal fields are stripped Normalization - output format is standardized Each step is independently configurable. You can enable or disable each filter, adjust thresholds, and define server-specific rules. Configuration with presets Configuration uses a TOML file. MCP RTK ships with community presets for popular servers: [servers.gitlab] preset = "gitlab" [servers.grafana] preset = "grafana" [servers.sentry] preset = "sentry" Enter fullscreen mode Exit fullscreen mode Each preset defines which fields to keep, which to exclude, and appropriate truncation thresholds for the server. For custom servers, you define rules directly: [servers.my-api] whitelist = ["id", "name", "status", "created_at"] max_string_length = 500 max_array_length = 10 Enter fullscreen mode Exit fullscreen mode MCP RTK auto-detects installed MCP servers and offers to configure them. Results Across my 38,000+ commands, MCP RTK has saved 267 million tokens with an average reduction rate of 87%. On Opus 4.6 ($15/M input tokens), that's roughly $4,000 in savings: Useful information is preserved. Claude responds with the same accuracy, but consumes far fewer tokens per session. The mcp-rtk gain command lets you track savings in real time: Tokens saved: 267.1M (86.7%) Efficiency meter: █████████████████████░░░ 86.7% Enter fullscreen mode Exit fullscreen mode Installation MCP RTK is distributed as a single binary: cargo install mcp-rtk Enter fullscreen mode Exit fullscreen mode One line change in your Claude Code config - wrap the existing MCP command with mcp-rtk --: { "mcpServers": { "gitlab": { "command": "mcp-rtk", "args": ["--", "npx", "-y", "@nicepkg/gitlab-mcp"], "env": { "GITLAB_PERSONAL_ACCESS_TOKEN": "glpat-..." } } } } Enter fullscreen mode Exit fullscreen mode MCP RTK detects the upstream server from the command and loads the matching preset automatically. Why Rust? Rust was a deliberate choice. The proxy must process every MCP response with minimal latency to avoid slowing down the workflow. Rust provides: near-instant startup (no JVM, no runtime) minimal memory footprint (a few MB) a single binary with no dependencies to install compile-time memory safety guarantees The code is open source MCP RTK is published under the MIT license on GitLab (mirror on GitHub). Community presets are maintained by users: anyone can contribute their own configurations for new MCP servers. The project is part of a tooling ecosystem I'm building around Claude Code, alongside Skill Radar (detecting repetitive patterns in sessions) and Claude Deck (multi-workspace for parallel sessions). To learn how to write your own skills, see the guide on effective skills. The project page has installation links and documentation.

来源报道 · 1 篇 · 以下链接均前往原始媒体

Thomas Tartrau MCP RTK:削减 90% 的 MCP 服务器 token 09-12 · 原文发布
← 返回精选动态 原文

更多内容