claw-tsaver
claw-tsaver
OpenClawユーザー向けのトークン節約MCPプロキシ。遅延展開(lazy expansion)により、ツール呼び出しのペイロードを90%以上削減します。
なぜ必要なのか
MCPのツール呼び出しは、1回のレスポンスで数千トークンものHTMLやJSONを返すことがよくありますが、モデルが実際に使用するのはそのうちの5%程度です。残りの95%はコンテキストウィンドウを無駄に消費し、コストを増大させます。claw-tsaverはOpenClawとダウンストリームのMCPサーバーの間に配置され、過大なレスポンスをインターセプトして、モデルにはコンパクトなプレビューとオンデマンドのハンドルを提供します。
Related MCP server: TokenSaver MCP
仕組み
sequenceDiagram
participant U as OpenClaw (Claude)
participant C as claw-tsaver proxy
participant F as fetch / puppeteer / etc.
U->>C: call_tool("fetch", url)
C->>F: forward call
F-->>C: 11,507 tokens of HTML
Note over C: tiktoken count > threshold
C->>C: store full content in SQLite
C-->>U: {preview_head, preview_tail, expand_handle}<br/>(only 104 tokens)
Note over U: model decides if it needs full text
U->>C: expand_content(handle)
C-->>U: full 11,507 tokens実測値
テスト | 元のトークン数 | 返されたトークン数 | 削減率 |
Wikipedia「トークン化(データセキュリティ)」の取得 | 11,507 | 104 | 99.1% |
OpenClaw + Claude Sonnet 4.6 + mcp-server-fetchにて検証(2026年4月25日)。
生データ: benchmarks/mvp-day1-fetch.jsonl。
クイックスタート
1. 前提条件
uvをインストールしてください(初回のみ設定):
curl -LsSf https://astral.sh/uv/install.sh | shclaw-tsaverのインストールは不要です。uvxがオンデマンドで取得して実行します。
2. ダウンストリームMCPサーバーの設定
~/.claw-tsaver/config.jsonを編集します(claw-tsaver-mcpを初回実行するとテンプレートが自動作成されます):
{
"downstream_servers": [
{"name": "fetch", "command": "uvx", "args": ["mcp-server-fetch"]}
],
"compression_threshold_tokens": 500
}3. OpenClawへの登録
~/.openclaw/openclaw.jsonのトップレベルに以下のブロックを追加します:
"mcp": {
"servers": {
"claw-tsaver": {
"command": "uvx",
"args": ["--from", "git+https://github.com/Yang1Bai/claw-tsaver",
"claw-tsaver-mcp"]
}
}
}その後、OpenClawゲートウェイを再起動します: openclaw gateway restart
ダッシュボード
オプション:リアルタイムのトークン節約統計を表示するローカルWeb UI。
uvx --from git+https://github.com/Yang1Bai/claw-tsaver claw-tsaver-dashboardブラウザで http://localhost:7878 を開いてください。
ロードマップ
[x] モジュールA: 遅延展開プロキシ(今回のリリース)
[x] モジュールD: ローカルダッシュボード(今回のリリース)
[ ] モジュールB: ツールルーティング(ターンごとに必要なMCPのみを自動ロード)
[ ] モジュールC: 会話履歴の圧縮(アトミックな事実カード)
ライセンス
MIT — LICENSEファイルを参照してください。
コントリビューション
IssueやPRを歓迎します。
Available Tools
1 toolexpand_contentA
Retrieve the full content of a previously compressed tool result. Pass the expand_handle returned in the compressed envelope.
| Name | Required | Description | Default |
|---|---|---|---|
| handle | Yes | The expand_handle from a compressed result. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided; description implies a read operation but does not detail any side effects, auth requirements, or handle expiration.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two efficient sentences front-load the purpose with no wasted words.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a single-parameter tool with no output schema, the description sufficiently guides usage, though output format is unstated.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description adds context that the handle comes from a compressed envelope, complementing the schema's parameter description.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool retrieves the full content of a compressed result, using specific verb and resource.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description instructs to pass the expand_handle from a compressed envelope, implying the usage context, but lacks explicit conditions or exclusions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
v0.0.1- First observed
expand_content
TDQS
Scored across 1 tool
Only one tool exists, so there is no potential for confusion between different tools.
With a single tool, there is no naming inconsistency to evaluate; the name 'expand_content' is clear and descriptive.
A single tool for expanding compressed results is very thin; the server likely needs additional tools (e.g., for listing handles) to be useful as an MCP server.
The tool covers its stated purpose of retrieving full content, but the server lacks any supporting tools for compression or handle management, leaving a minor gap in the overall surface.
Maintenance
Related MCP Connectors
An MCP memory server. One memory your agents share — across models, devices and apps.
MCP server for building and testing AI agents with multi-model experimentation and insights.
Persistent memory for AI agents to retain, retrieve, and recall conversation context through MCP.
Cloud-hosted MCP server for durable AI memory
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server that helps AI agents reduce token usage by converting data to TOON format and stripping comments and unnecessary whitespace from code files.31 PyPIMIT
- AlicenseAqualityDmaintenanceAn MCP server that reduces AI API costs by up to 97% through token measurement, compression, caching, and pruning, all without changing prompts.101Apache 2.0
- AlicenseAqualityBmaintenanceAn MCP server that intelligently filters and compresses tool outputs to reduce context window usage, saving up to 90% of tokens by removing noise such as passing tests and redundant information.512 npmMIT
- AlicenseNot gradedqualityCmaintenanceMCP server that reduces AI agent token usage by up to 90% through intelligent context compression. Enables efficient code exploration, multi-file refactoring, and debugging by providing tools for smart reading, searching, and managing code context.4MIT