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 分

    請在儲存庫或註冊中心條目中宣告授權條款。