Claude Token Saver Mcp

io.github.BlackFoilPublished by GitHub account BlackFoilv0.3.2Updated Oct 24, 2026

MCP server that offloads routine coding tasks to local LLM (Ollama) to save Claude API tokens

The publisher's own server: Claude Platform Docs

Overview

AI-generated overview

Local MCP server that routes routine coding and text tasks from Claude Code to a local Ollama model to save cloud API tokens.

What you can do
Generate and refactor code, and batch several tasks, on a local model via offload_work and batch_offload. Summarize or compress long text locally with compress_context. Set up models automatically: recommend, download and preload a model sized to available RAM. Inspect savings and usage through cost_dashboard and server metrics. Manage Ollama models directly: list loaded models, pull and preload models, and configure the model selector.
When to use it
Useful when you run Claude Code on a machine with Ollama and want boilerplate generation, unit tests, summaries or simple refactors handled locally instead of spending cloud tokens. Less suited to architecture design or complex debugging, which the README says should stay in the cloud.
Requirements
Runs as a local stdio process via npx or a built server file. Needs Node.js 20+ and a running Ollama instance (ollama serve). Model downloads are several GB (about 2.5 to 18 GB depending on RAM tier) and require disk space and network access.
Before you install
Downloads and preloads large models automatically, consuming disk, RAM and VRAM. It processes your code and text through a local model, so output quality is lower than Claude's. It claims local-only processing and built-in output redaction, but review before sending sensitive code.

Installation

In SourceWeft

  1. Open Claude Token Saver Mcp in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

README

English | 日本語

[CI] [npm] [Coverage] [License]

claude-token-saver-mcp

[claude-token-saver-mcp banner]

Beta — 個人利用向け。736 テスト / カバレッジ 97%。

Claude Code の「それ、ローカルでよくない?」を自動化する MCP サーバー。

ボイラープレート生成、テスト作成、テキスト要約 — Cloud API に投げるまでもない定型タスクを、手元の Ollama でさばきます。セキュリティ対策込み。

モチベーション

Claude Code の API 利用を分析してみたら、リクエストの約 40% は定型的なコード生成やテキスト処理でした。この手のタスクは 7B クラスのローカルモデルでも実用的な品質が出ます。「推論は Cloud、作業は Local」— この振り分けを MCP で自動化したのがこのツールです。

ローカル LLM はどこまで来たか

ローカル LLM の進化は速いです。2024 年の Llama 3 から 2025 年の Qwen3 まで、わずか 1 年でコード生成ベンチマーク (HumanEval) のスコアは 60% → 85% に跳ね上がりました。

この調子なら、Agent ワークフローにローカル LLM が当たり前に組み込まれる日もそう遠くないでしょう。claude-token-saver-mcp は Cloud と Local を使い分けるための土台を提供します。

しくみ

MCP (Model Context Protocol) は Claude Code が外部ツールを呼び出すための標準プロトコルです。このサーバーを登録すると、Claude Code がタスクの内容を見て、定型的な処理を自動的にローカル LLM へ回します。

text
Claude Code ──MCP──▶ token-saver ──HTTP──▶ Ollama (ローカル)     │                                         │     │  「定型タスクだ → ローカルに振ろう」        │     │                                         │     └─── 高度な推論・設計判断は Cloud で継続 ───┘

Ollama が落ちていたり応答が遅い場合は Cloud API にフォールバック可能です。

30 秒セットアップ

前提: Node.js 20+ と Ollama がインストール済みであること。

0. Ollama を起動

bash
ollama serve

1. プロジェクトルートに .mcp.json を作成

json
{  "mcpServers": {    "token-saver": { "command": "npx", "args": ["-y", "claude-token-saver-mcp"] }  }}

2. Claude Code を起動して、こう頼む

text
コーディング用にローカルLLMをセットアップして

RAM に応じた最適モデルが推奨 → ダウンロード(約 4GB)→ プリロードまで自動で走ります。

3. 動作確認

text
TypeScript で配列をシャッフルする関数を書いて

「ローカルLLM(qwen2.5-coder:…)で生成しました」のようにローカルモデル名が表示されれば OK。 出ない場合は ollama list でモデルを確認し、トラブルシューティング を参照してください。

ソースからビルドする場合
bash
git clone https://github.com/BlackFoil/claude-token-saver-mcp.gitcd claude-token-saver-mcpnpm ci && npm run build

プロジェクトルートの .mcp.json に追加:

json
{  "mcpServers": {    "token-saver": {      "command": "node",      "args": ["/path/to/claude-token-saver-mcp/dist/server.js"]    }  }}

特徴

  • ローカル完結 — 定型タスクは Cloud API を使わずに処理できる
  • 自動モデル選択 — RAM を検出して最適なモデルを推奨・DL・プリロード(auto_setup)
  • セキュリティ内蔵 — プロンプトインジェクション検知 + 出力サニタイズ
  • コスト可視化 — 節約額をリアルタイムで追跡(定型タスク比率 40% なら月 $50〜80 程度の削減が目安)
  • Cloud フォールバック — Ollama が落ちても Cloud に自動切り替え可能

使用例

text
あなた: 「ソート関数を書いて」    → offload_work がローカルで生成     💰 $0.02 節約あなた: 「このログを要約して」    → compress_context がローカルで圧縮  💰 $0.05 節約あなた: 「コスト節約を見せて」    → cost_dashboard: 累計 $47.89 節約あなた: 「3つのAPIを一括実装して」 → batch_offload: 3 タスクを順次処理

ローカル品質の実際

ローカル 7B モデルの出力は Claude に及びません。それは前提です。ただ、定型タスクに限れば十分実用的です。

タスクローカル品質向き不向き
ボイラープレート生成★★★★☆✅ 得意
ユニットテスト作成★★★★☆✅ 得意
テキスト要約★★★★☆✅ 得意
単純なリファクタリング★★★☆☆✅ 実用的
アーキテクチャ設計★★☆☆☆❌ Cloud に任せるべき
複雑なデバッグ★★☆☆☆❌ Cloud に任せるべき

Claude Code がタスクの複雑さを判断して自動で振り分けます。ローカルの品質が足りなければ Cloud で処理されます。

自動ティアリング

RAMTierモデルDL サイズ
< 16 GBLightphi4:latest~2.5 GB
16–48 GBStandardqwen2.5-coder:7b~4.7 GB
> 48 GBUltraqwen2.5-coder:32b~18 GB

ツール一覧

ツール説明
offload_workコード生成・リファクタリングをローカルで実行
compress_context長大なテキストをローカルで要約
auto_setup最適モデルの推奨 → DL → プリロードをワンステップで
batch_offload複数タスクを一括投入(順次 / 並列)
cost_dashboard累計節約額・モデル使用統計
その他のツール(6 件)
ツール説明
get_metricsサーバーメトリクス(JSON / Prometheus)
recommend_modelタスクカテゴリ別の最適モデル推奨
pull_modelOllama モデルのダウンロード
preload_modelVRAM へのプリロード
list_loaded_modelsロード中モデルの一覧
configure_model_selectorモデルセレクターのランタイム設定

セキュリティ

ローカル LLM への入出力を自動で保護します。

  • プロンプトインジェクション検知 — 5 カテゴリ・20 パターンで悪意ある入力をブロック
  • 出力サニタイズ — API キー・パスワード・JWT など 11 パターンを [REDACTED] に置換
  • データプライバシー — 全処理がローカル完結。外部への送信なし

ドキュメント

クイックスタート5 分で始める
ユースケース集具体的な活用例
設定リファレンス全設定項目
FAQよくある質問
トラブルシューティングエラー対応

アーキテクチャ

text
src/├── server.ts          # MCP エントリポイント(11 ツール登録)├── tools/             # offload_work, compress_context, auto_setup, batch_offload 等├── ollama/            # Ollama クライアント & マルチノードロードバランサー├── queue/             # FIFO キュー & 優先度キュー(URGENT/HIGH/NORMAL/LOW)├── model-selector/    # モデル推奨エンジン, ベンチマーク DB, 実行トラッカー├── validators/        # 入力バリデーション & プロンプトインジェクション検知├── cost/              # コスト計算 & レポーター├── metrics/           # Prometheus メトリクス収集├── persistence/       # ExecutionTracker / BenchmarkStore のファイル永続化├── config/            # Zod 設定スキーマ & ローダー├── tiering/           # RAM ベースの自動ティアリング├── logging/           # 構造化ログヘルパー└── errors.ts          # CTS-XXXX エラー体系

開発

bash
npm cinpm test             # 736 テスト(カバレッジ 97%)npm run typecheck    # 型チェックnpm run lint         # ESLintnpm run build        # プロダクションビルド

対応プラットフォーム: macOS / Linux / Windows(Ollama が動く環境)

コントリビューション歓迎です → CONTRIBUTING.md

ライセンス

Apache License 2.0

Source: README.md at commit dab51e3

Tools

0
SourceWeft has not started this package in its sandbox yet, so its tools are not known.

Version history

1
  1. v0.3.2LatestSep 16, 2026

Score

50% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts

    Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.

  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listed15 pts

    Answer tools/list without a credential, or ship a package that starts in a sandbox without one.

  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts

Other Claude integrations