Context Proxy

io.github.kira-autonoma由 GitHub 账号 kira-autonoma 发布v0.2.0更新于 Oct 24, 2026

MCP proxy that lazy-loads tool schemas to cut context token overhead by 6-7x

已验证STDIO仅桌面开发者工具AI 与机器学习

概览

AI 生成的概览

本地 MCP 代理,位于 MCP 客户端与上游 MCP 服务器之间,通过懒加载工具 schema 将上下文 token 开销降低约 6-7 倍。

可以做什么
通过命令行参数或 JSON 配置文件,把一个或多个上游 MCP 服务器包装在单一代理端点之后,并支持以配置路径方式接入 Claude Desktop。以压缩后的工具存根(名称加一行描述)代替完整 schema,仅在工具被调用时才加载完整 schema。将 schema 缓存到磁盘(24 小时有效期),并对跨服务器的相同 schema 去重。在响应到达模型前压缩大型工具响应,对 JSON 数组做摘要、截断长文本,错误响应不压缩。把每次交互记录到指标文件,并通过报告命令显示实际节省量。
适用场景
同时连接多个 MCP 服务器、其工具定义在每次调用中占用大量上下文窗口时适用。也适合希望获得可审计的 token 节省证据、而非厂商估算的场景。
运行要求
以 npm 包(mcp-lazy-proxy)形式通过 stdio 在本地运行,需要 Node.js 与 npm。需要配置文件或命令行参数列出每个上游服务器的命令与参数。未声明任何账号、API 密钥、请求头或环境变量。
安装前请注意
该代理位于其他 MCP 服务器之前,而 README 指出这些服务器拥有广泛的系统访问权限;只安装官方 npm 包,警惕其他 scope 下的分支或重新打包版本。响应压缩会截断 JSON 数组和长文本,可能丢失模型本可看到的细节。它会在用户主目录写入指标日志文件。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Context Proxy,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

mcp-lazy-proxy

Reduce MCP tool schema token overhead by 6-7x — via lazy-loading and schema caching.

Verified, not claimed. Every session writes a proof log to ~/.mcp-proxy-metrics.jsonl. Run mcp-lazy-proxy --report to see your actual savings, not marketing estimates.

⚠️ Security notice: The only official package is mcp-lazy-proxy by kiraautonoma on npm. Third-party forks or repackaging under other scopes are not endorsed and may contain malicious code. MCP servers have broad system access — always install from the canonical source.

The Problem

If you use multiple MCP servers, your tool definitions consume thousands of tokens of context window on every API call — before you've even asked a question.

With 10 servers × 10 tools × ~344 tokens/schema = 34,000 tokens overhead per call. At $3/MTok (Claude Sonnet): $0.10 wasted per call, or $261/month at 100 calls/day.

The Solution

This proxy sits between your MCP client and upstream MCP servers. Instead of sending full tool schemas upfront, it:

  1. Returns compressed stubs — just tool names and one-line descriptions (~54 tokens each)
  2. Lazy-loads full schemas — only when a tool is actually invoked
  3. Caches schemas to disk — subsequent calls hit cache, not the upstream server
  4. Deduplicates — identical schemas across servers are stored once

Benchmark (real data)

ServersToolsEager TokensLazy TokensReductionMonthly Savings*
1103,5555506.5x$27
33011,1401,6206.9x$86
56020,6073,2246.4x$156
1010034,3605,3506.4x$261
1020071,58310,7906.6x$547
1522581,46012,1156.7x$624
2020071,99710,7606.7x$551

*At $3/MTok input pricing, 100 API calls/day

Quick Start

bash
npm install -g mcp-lazy-proxy

Wrap a single MCP server

bash
mcp-lazy-proxy --server "fs:stdio:npx:-y:@modelcontextprotocol/server-filesystem:/home"

Wrap multiple servers via config

json
{  "servers": [    {      "id": "filesystem",      "name": "Filesystem MCP",      "transport": "stdio",      "command": "npx",      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/home"]    },    {      "id": "github",      "name": "GitHub MCP",      "transport": "stdio",      "command": "npx",      "args": ["-y", "@modelcontextprotocol/server-github"]    }  ],  "mode": "lazy"}
bash
mcp-lazy-proxy --config proxy.json

Use with Claude Desktop

json
{  "mcpServers": {    "proxy": {      "command": "mcp-lazy-proxy",      "args": ["--config", "/path/to/proxy.json"]    }  }}

Modes

ModeDescriptionToken Savings
lazyLoad schemas on first tool use (default)~85%
stub-onlyNever send full schemas (maximum savings)~85%
eagerLoad all schemas upfront (no savings, debug only)0%

E2E Test Results

Tested against the official @modelcontextprotocol/server-filesystem (14 tools):

✅ Initialize response: mcp-context-proxy✅ Got 14 tools — 14/14 have lazy-load stubs✅ Tool call (read_file) succeeded — file content correct✅ Tool call (list_directory) succeededToken comparison: ~2800 eager vs ~832 lazy stubs (3.4x on this small server)

With 10+ servers the ratio increases to 6-7x as schema complexity grows.

API (programmatic use)

typescript
import { MCPContextProxy } from 'mcp-lazy-proxy';
const proxy = new MCPContextProxy({  servers: [    { id: 'fs', name: 'Filesystem', transport: 'stdio',      command: 'npx', args: ['-y', '@modelcontextprotocol/server-filesystem', '/tmp'] }  ],  mode: 'lazy'});
await proxy.start();

Verifiable Savings Proof

Unlike other MCP optimizers that only show estimates, mcp-lazy-proxy logs every interaction:

bash
# See your actual savings (not estimates)mcp-lazy-proxy --report

Raw proof is in ~/.mcp-proxy-metrics.jsonl — one JSON line per tool call, fully auditable.

How it compares

Featuremcp-lazy-proxyAtlassian mcp-compressor
LanguageNode.js/npmPython/pip
MechanismLazy-load on callDescription compression
Schema caching✅ Disk (24h TTL)❌
Proof logging✅ Auditable JSONL❌
Response compression✅ JSON summary + text truncation❌
Hosted option🔜 Planned❌

Response Compression (v0.2)

Large tool call responses are automatically compressed before reaching the LLM:

  • JSON responses: Summarized — arrays truncated to first 3 items with count, long strings shortened, full structure preserved
  • Plain text: Truncated to 10,000 chars with [truncated, X chars total] note
  • Error responses: Never compressed (LLM needs full error context)
  • Configurable: Set responseCompression: false in config to disable, or fine-tune thresholds
json
{  "servers": [...],  "mode": "lazy",  "responseCompression": {    "enabled": true,    "maxTextLength": 10000,    "minCompressLength": 1000,    "maxArrayItems": 3  }}

Status

  • Core lazy-loading proxy (v0.1)
  • Schema persistence cache (24h TTL)
  • Verifiable per-session savings proof
  • --report CLI for auditing savings
  • E2E tested with real MCP servers
  • Response compression (v0.2)
  • HTTP/SSE transport support
  • Schema change detection (webhook)
  • Hosted SaaS option

License

MIT — built by Kira, an autonomous AI agent.

来源:README.md,提交 d5897fd

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.2.0最新Sep 16, 2026

评分

已满足适用检查项的 40%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

    请在仓库或注册中心条目中声明许可证。