AM

ameshkov/mcp-compress-router

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

21 stars 4 forks 质量 72 趋势 24MIT

把所有连接的MCP压缩到一个路由器MCP,能节省最多99%的令牌

概览

把所有连接的MCP压缩到一个路由器MCP,可以节省最多99%的令牌。 MCP 压缩路由器是一台面向开发者使用的单一 MCP 服务器,将多个 MCP 服务器连接到一个编码代理。直接连接后,每个请求都包含所有工具定义——三台热门服务器约需 26K 令牌,50 轮会话约为 0.93 美元。路由器会用两个工具 get_tool_schema 和 invoke_tool 替换这些列表,只有当代理请求时才返回工具的完整模式。这三台服务器压缩成约 600 个令牌的目录,开销降低了约 97.7%。关于成本模型,请参见关于令牌开销。 - 每个代理一次连接到路由器,并在同一地点管理所有下游MCP服务器。- 路由器在代理每回合发送所有定义的地方保存最多。 实际节省取决于编码代理:一些代理已经通过自己的算法将工具定义排除在请求中(见下文“可测量节省”)。

概述(AI 翻译)

把所有连接的MCP压缩到一个路由器MCP,节省高达99% 代币。

描述

MCP 压缩路由器是为连接的开发者提供的唯一 MCP 服务器 多个MCP服务器连接到一个编码代理。每个请求直接连接 携带他们所有工具定义——大约26K代币对应三个 热门服务器,50轮会话售价约0.93美元。路由器 用两个工具替换这些列表,get_tool_schema 和 invoke_tool,只有当代理请求时才返回工具的完整模式 对它来说。同样的三台服务器压缩成大约600个目录 代币,降低了大约97.7%的开销。参见 关于成本的代币开销 模特。

路由器在两种情况下最有帮助:

  • 你使用多个编码代理。 将每个代理连接到 路由器一次,管理所有下游MCP服务器。
  • 您的代理会在每个请求中加载完整的工具定义。 路由器保存最多的资源,代理会在每个节点发送所有定义 转身。

实际节省取决于编码代理:有些代理已经有 工具定义,基于他们的请求和自己的算法(参见 以下是实际的节省情况)。

先修条件

  • **节点。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

MCP Compressing Router

Compress all connected MCP into a single router MCP and save up to 99% on
tokens.

Description

MCP Compress Router is a single MCP server for developers who connect several MCP servers to a coding agent. Connected directly, each request carries all of their tool definitions — about 26K tokens for three popular servers, roughly $0.93 over a 50-turn session. The router replaces those listings with two tools, get_tool_schema and invoke_tool, and returns a tool’s full schema only when the agent asks for it. The same three servers compress to a catalog of about 600 tokens, cutting the overhead by roughly 97.7%. See About token overhead for the cost model.

The router helps most in two cases:

  • You use more than one coding agent. Connect each agent to the router once and manage every downstream MCP server in one place.
  • Your agent loads full tool definitions on every request. The router saves the most where the agent sends every definition on every turn.

The actual savings depend on the coding agent: some agents already keep tool definitions out of their requests with their own algorithms (see Measured savings below).

Prerequisites

  • Node.js 24 or later — the router runs on Node.js and is launched via npx, so no separate install step is needed.
  • A coding agent that supports stdio MCP servers — opencode, Claude Code, Codex, GitHub Copilot, Cursor, and most other modern agents.

Quick Start

The router is published on npm as mcp-compress-router. You do not need to install it — just run it with npx.

Setup is two steps: connect your coding agent to the router, then add the MCP servers you want to compress.

1. Connect your coding agent

Register the router the same way you register any other stdio MCP server, at the user scope (or your agent’s equivalent). It reads its server list from a user-wide config file, so every project shares one compressed catalog:

opencode mcp add mcp-compress-router -- npx -y mcp-compress-router@latest

See Connect your coding agent for Claude Code, Codex, GitHub Copilot (VS Code), and other agents.

2. Add downstream MCP servers

在 GitHub 查看完整 README

安装

npx mcp-compress-router@latest add playwright \
新手?先看 mcpskill.org 教程 →