JT

jackandjac/token-saver-mcp-java

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

22 stars 0 forks 品質 61 トレンド 18

Claude Code / Codex / Wibey タスクを langchain4j と langgraph4j 経由でローカル LLM に委任する MCP サーバー.

概要

Claude Code / Codex / Wibey(またはMCP-compliant コーディングエージェント)がローカルLLMにシンプルでよくスコープ付けされたタスクを委任するMCPサーバー。コードスニペット、分離されたリファクタ、ドキュメント、コードレビュー、基本Q&A — なので、ローカルモデルが既に実行できるわけではありません。 これは、langchain4j(ローカルLLMクライアント)、langgraph4j(orchestration)、および公式MCP Java SDK(stdioサーバー)でJavaで完全な書き換えです。 元の考えとPython/FastMCPのプロトタイプのクレジットは、csabakecskemeti/cc token saver mcpに移行します。このプロジェクトは、グラフベースのclassify/delegate/escalateフロー、サーバー側のファイル読み込み、タイムアウト、および実用的なエラーでそのコンセプトに基づいて構築されます。 サーバは 2 つの MCP ツール — query local llm と query local llm with context — の Claude コードは、単純なサブタスクを最初に試すように指示されます.

概要(AI 翻訳)

Claude Code / Codex / Wibey(またはMCP-compliant コーディングエージェント)がローカルLLMにシンプルでよくスコープ付けされたタスクを委任するMCPサーバー。コードスニペット、分離されたリファクタ、ドキュメント、コードレビュー、基本Q&A — なので、ローカルモデルが既に実行できるわけではありません。

これは、langchain4j(ローカルLLMクライアント)、langgraph4j(orchestration)、および公式MCP Java SDK(stdioサーバー)でJavaで完全な書き換えです。

元の考えとPython/FastMCPのプロトタイプのクレジットは、csabakecskemeti/cc token saver mcpに移行します。このプロジェクトは、グラフベースのclassify/delegate/escalateフロー、サーバー側のファイル読み込み、タイムアウト、および実用的なエラーでそのコンセプトに基づいて構築されます。

使い方

サーバは 2 つの MCP ツール — query_local_llm と [query_local_llm_with_context] を公開します。Claude コードは、単純なサブタスクを最初に試すように指示されます。 各呼び出しは、モデルに直接転送するのではなく、小さなlanggraph4jグラフを介して実行されます。

[[`classify`]は、タスクが実際にそれのために十分であるかどうかを判断するために、ローカルモデルに安く、低温コールをします。 もしそうでなければ、 [`escalate`] は構造化された `ESCALATE: …

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

Token Saver MCP Java

An MCP server that lets Claude Code / Codex / Wibey (or any MCP-compliant coding agent) delegate simple, well-scoped tasks to your local LLM — code snippets, isolated refactors, documentation, code reviews, basic Q&A — so you spend premium tokens on coordination and architecture, not on work a local model can already do.

This is a complete rewrite in Java on langchain4j (local LLM client), langgraph4j (orchestration), and the official MCP Java SDK (stdio server).

Credit for the original idea and the Python/FastMCP prototype goes to csabakecskemeti/cc_token_saver_mcp — this project builds on that concept with a graph-based classify/delegate/escalate flow, server-side file reading, timeouts, and actionable errors.

How it works

The server exposes two MCP tools — query_local_llm and query_local_llm_with_context — that Claude Code is instructed to try first for simple subtasks. Every call runs through a small langgraph4j graph instead of just forwarding straight to the model:

START -> classify -> delegate -> END   (task judged within the local model's competence)
                  \-> escalate -> END  (task judged too complex; local LLM never called)

classify makes a cheap, low-temperature call to the local model to judge whether the task is actually simple enough for it. If not, escalate returns a structured ESCALATE: ... message telling Claude Code to handle the task itself — so a task that’s too complex for the local model comes back as a clear signal, not a low-quality answer.

Features

  • Server-side file reading. Both tools accept an optional file_paths array. The server reads the files itself and passes their content straight to the local LLM — Claude Code passes a path instead of Read()-ing the file into its own context first. This is where the real token savings on large files come from.
  • Bounded waits. Both tools accept an optional timeout_seconds (default from LOCAL_LLM_TIMEOUT_SECONDS), enforced with a hard timeout around the call so a stalled local backend can’t hang a tool call indefinitely.
  • Actionable errors. Backend failures (connection refused, unreachable host, timeout) come back as a clear message naming the configured URL and the next step — e.g. “Local LLM backend unreachable at http://127.0.0.1:8000/v1. Check that it’s running…” — with isError: true set correctly, instead of a raw exception string.
GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

"mcpServers": { "token-saver": { "type": "stdio", "command": "java", "args": ["-jar", "<path>/token-saver-mcp-java/target/token-saver-mcp-java.jar"] } }