Skip to main content
Glama

Refract

CI

Refract MCP server

AIエージェントがMCPツールに費やすトークンを最大98%削減——何も失うことなく。


実際の変化

サーバー

ツール数

圧縮前

圧縮後

削減率

filesystem (Anthropic)

14

1,892 tok

236 tok

−88%

sequential-thinking

1

926 tok

20 tok

−98%

Google Calendar

5

5,010 tok

660 tok

−87%

Enterprise (Cal + Gmail + Drive)

12

8,649 tok

882 tok

−90%

sample_app.js (JavaScript)

799 tok

284 tok

−64.5%

sample_app.ts (TypeScript)

378 tok

266 tok

−29.6%

ast_extractor.py (Python)

3,633 tok

890 tok

−75.5%

送信トークンが減れば、APIコストの低下と応答の高速化。そして何も失われません。すべての確認で、圧縮後もツールは100%使用可能な状態が保たれています。

これらの数値はご自身でも再現可能です。すべての入力はリポジトリ内の静的フィクスチャであり、トークンはtiktoken cl100k_baseでカウントしています。

python benchmarks/run_benchmark.py            # the table above
python benchmarks/run_benchmark.py --json     # machine-readable
python benchmarks/run_benchmark.py --fixture path/to/your_schemas.json

Related MCP server: Bifrost-MCP Gateway

インストール

ワンライナー(macOS / Linux)——パッケージをインストールし、Claude Desktopを設定します。

curl -sSL https://raw.githubusercontent.com/LoudiliMed/Refract/main/install-refract.sh | sh

インターネットからシェルにスクリプトをパイプで流し込む前に、一読をお勧めします:install-refract.shをGitHubで確認。sudoは使用しません。

pipで直接インストールする場合:

pip install refract-mcp

オプションの追加パッケージ:

pip install refract-mcp[semantic]   # semantic tool routing with embeddings
pip install refract-mcp[multilang]  # JavaScript, TypeScript, JSX, TSX support

2つのモード

モード1 — MCPプロキシ

エージェントと任意のMCPサーバーの間に配置されます。ツールスキーマをオンザフライで圧縮し、エージェントが毎回すべてのカタログを読み込む必要をなくします。

ローカルサブプロセス(stdio):

refract-proxy --target "npx @modelcontextprotocol/server-filesystem /tmp" --verbose

リモートHTTP/SSEサーバー:

# --url implies SSE transport (explicit, recommended for remote endpoints)
refract-proxy --url https://my-mcp-server.com/sse

# or with --transport flag (auto-detection can be overridden)
refract-proxy --target https://my-mcp-server.com/sse --transport sse

プロキシフラグ:

フラグ

デフォルト

説明

--target URL

必須

MCPターゲット:stdioコマンド、HTTP URL、またはJSONファイル

--stdio-cmd CMD

stdioコマンド用の--targetのエイリアス

--url URL

リモートSSE/HTTPエンドポイント——--transport sseを暗黙指定

--transport {stdio,sse,http}

auto

ターゲットへのトランスポートを強制:stdiosse(レガシー)、http(Streamable HTTP)

--sse-timeout SECONDS

30

SSEターゲットの接続タイムアウト(3回リトライ)

--mode {stdio,http}

stdio

プロキシがエージェントにサービスを提供する方法

--port PORT

8080

--mode http時のプロキシ待受ポート

--verbose

off

リクエストごとのトークン数を表示

--log-level

WARNING

DEBUG / INFO / WARNING / ERROR

Claude Desktopに追加:

{
  "mcpServers": {
    "my-server-via-refract": {
      "command": "/path/to/refract-proxy",
      "args": [
        "--target",
        "npx @modelcontextprotocol/server-filesystem /path/to/folder",
        "--verbose"
      ]
    }
  }
}

リモートMCPサーバー(SSE)の場合:

{
  "mcpServers": {
    "remote-via-refract": {
      "command": "/path/to/refract-proxy",
      "args": ["--url", "https://my-mcp-server.com/sse"]
    }
  }
}

refract-wrap-all — すべてのサーバーを一度にラップ

エントリを一つずつ編集する代わりに(またはサーバーごとにrefract-installを実行する代わりに)、refract-wrap-allclaude_desktop_config.json内のすべてのstdioサーバーを一度のコマンドでrefract-proxy経由に書き換えます:

# Preview what would change — writes nothing
refract-wrap-all --dry-run

# Wrap every stdio server not already going through refract
refract-wrap-all

# Restore the original commands
refract-wrap-all --unwrap

例:このエントリ

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["@modelcontextprotocol/server-filesystem", "/tmp"],
      "env": {"MY_VAR": "1"}
    }
  }
}

は次のようになります:

{
  "mcpServers": {
    "filesystem": {
      "command": "/path/to/refract-proxy",
      "args": ["--stdio-cmd", "npx @modelcontextprotocol/server-filesystem /tmp"],
      "env": {"MY_VAR": "1"}
    }
  }
}

保証事項:

  • 設定ファイルのバックアップは書き込み前に必ず作成されます(claude_desktop_config.json.bak、次に.bak2.bak3……既存のバックアップは上書きされません)。

  • envcwdおよびその他のサーバーフィールドは保持されます。

  • すでにrefract-proxyまたはrefract-server経由のサーバーはスキップされます(already wrapped)。

  • リモートSSE/HTTPサーバー(urlエントリ)はスキップされます——ラップされるのはstdioサーバーのみです。

  • --unwrapは完全なラウンドトリップです:ラップしてからアンラップすると、元のコマンド、引数、およびすべてのフィールドが復元されます。

refract-proxyがサポートするトランスポート

フラグ

説明

--transport http

Streamable HTTP

現在の標準(MCP仕様 2025-03-26)。リモートMCPサーバーで使用します。

--transport sse

SSE

レガシートランスポート、互換性のために維持。Streamable HTTPをサポートしないサーバーで使用。

--transport stdio

stdio subprocess

ローカルコマンド(--targetがコマンドの場合のデフォルト)。

(省略)

自動検出

--targetから推測:HTTP URL→SSE、コマンド→stdio。

ssehttpの両方とも、--targetにHTTP(S) URLが必要です。

# Connect to a remote MCP server via Streamable HTTP (recommended)
refract-proxy --target "https://my-mcp-server.com/mcp" --transport http

# Connect via SSE (legacy)
refract-proxy --target "https://my-mcp-server.com/sse" --transport sse

# Local subprocess (auto-detected, --transport stdio optional)
refract-proxy --target "npx @modelcontextprotocol/server-filesystem /tmp"

モード2 — MCPサーバー

コードベースをMCPサーバーとして公開します。エージェントはリポジトリのインデックス作成、圧縮ファイルコンテキストの取得、特定の関数の展開、影響分析、破壊的変更の検出、セキュリティリスクのマッピングが可能です。

refract-server --root /path/to/your/repo

Claude Desktopに追加:

{
  "mcpServers": {
    "refract-code": {
      "command": "/path/to/refract-server",
      "args": ["--root", "/path/to/your/repo"]
    }
  }
}

仕組み(専門用語なし)

50冊の本がある図書館を想像してください。

Refractなし:エージェントは、答えにたった1冊しか必要ない場合でも、すべての質問に対して50冊すべての本の詳細な要約を受け取ります。

Refractあり:エージェントは最初にタイトルのリスト(インデックス)を取得します。どの本が必要か分かると、その本の内容だけを受け取ります。

技術的には:

インデックス(常に送信):ツール名と各ツールの短い説明のみ。

詳細(必要なときのみ送信):実際に使用されるツールの完全な説明、それを正しく使用するために必要なすべての情報、それ以上は何もありません。

検証:圧縮後、Refractは自動的に重要な情報が削除されていないかを確認します。疑わしい場合は、リスクを冒さずに完全版を送信します。

このプロセスにはAIモデルは関与しません。完全に自動化、高速、かつ決定論的です。


MCPプロキシツール

ツール

機能

圧縮

ツールスキーマをオンザフライで最大98%削減

シグナルチェック

圧縮後、呼び出し可能な契約を検証

セマンティックルーティング

埋め込みを使用して適切なツールを特定(オプトイン)

プロンプトキャッシング

繰り返しリクエストに対してAnthropic cache_controlを注入

MCPサーバーツール

ツール

入力

出力

index_repo

リポジトリパス

すべてのPython、JS、TSファイルの集約インデックス

get_compressed

ファイルパス

圧縮された構造+トークン統計

expand

ファイルパス+関数名

逐語的なソース+依存関係コンテキスト

blast_radius

ファイルパス+関数名

ターゲットが変更された場合に壊れるすべての関数

semantic_diff

ファイルパス+旧ソース+新ソース

破壊的変更 vs 本体のみの変更

semantic_diff_branches

リポジトリパス+ファイル+関数+ベース/ヘッドgit参照

2つのブランチ/コミット間の1関数のsemantic_diff

security_surface

リポジトリパス

危険な呼び出しのマップ(subprocess、eval、pickle、requests)


リポジトリ健全性チェック

refract-status --root /path/to/repo
refract-status --root /path/to/repo --json

フラグ

説明

--root PATH

分析するパス(デフォルト:カレントディレクトリ)

--json

機械可読な出力

表示内容:言語別ファイル数、生トークンと圧縮トークンの比較、インデックス化された関数/クラス、カテゴリ別の危険な呼び出し、tree-sitter未対応の言語。


blast_radius

ターゲット関数を変更した場合に壊れる関数をClaudeに問い合わせます。

結果の例:

{
  "target": "authenticate",
  "direct_callers": ["login_user"],
  "all_impacted": ["login_user", "verify_session", "admin_access"],
  "impacted_count": 3,
  "risk_level": "MEDIUM"
}

リスクレベル:LOW(影響0〜2)、MEDIUM(3〜5)、HIGH(6以上)。


semantic_diff

本体ではなく関数インターフェースを比較することで、破壊的なAPI変更を検出します。CIゲートとして使用できます。

結果の例:

{
  "breaking": ["authenticate"],
  "body_only": ["logout"],
  "added": ["new_function"],
  "removed": [],
  "unchanged": ["hash_password"],
  "is_breaking": true
}

is_breakingがtrueの場合、PRは公開APIを変更しているため、レビューが必要です。


security_surface

リポジトリ全体で、危険なプリミティブを呼び出すすべての関数をマッピングします。

HIGHリスク:subprocess、os.system、eval、exec、pickle、ctypes

MEDIUMリスク:open(書き込みモード)、socket、requests、httpx、urllib

結果の例:

{
  "high_risk": [
    {
      "file": "src/llm_client.py",
      "function": "run_command",
      "calls": ["subprocess.run"]
    }
  ],
  "summary": {
    "high_risk_count": 1,
    "medium_risk_count": 3,
    "total_functions_scanned": 87,
    "clean_files": 8
  }
}

対応言語

Python(astモジュール経由)、JavaScript、TypeScript、JSX、TSX(tree-sitter経由、pip install refract-mcp[multilang]でオプトイン)。

言語はファイル拡張子から自動検出されます。tree-sitterがインストールされていない場合は、適切にフォールバックします。


組み込みAnthropicキャッシング

RefractはAnthropicのプロンプトキャッシングと統合されています。as_anthropic_tools()は自動的に圧縮カタログをキャッシュ可能としてマークし、繰り返しリクエストのコストをさらに削減します。

30日間、1日100リクエスト、5,000トークンのスキーマの場合の例:

シナリオ

コスト

Refractなし、キャッシュなし

$45.00

Refract + キャッシュあり

$1.49


トラブルシューティング

Claude Desktopで「Failed to spawn process: No such file or directory」

Claude DesktopがPATH内でrefract-proxyを見つけられません。絶対パスを特定して直接使用してください:

which refract-proxy

その後、claude_desktop_config.jsonでフルパスを使用します:

{
  "mcpServers": {
    "my-tool-via-refract": {
      "command": "/full/path/to/refract-proxy",
      "args": [
        "--target",
        "npx @modelcontextprotocol/server-filesystem /path/to/folder"
      ]
    }
  }
}

対応クライアント

Claude Desktop、Cursor、MCP標準に準拠した任意のクライアント、既存の任意のMCPサーバー。


ライセンス

MIT — 商用利用を含め、自由に使用できます。

Install Server
A
license - permissive license
A
quality
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Related MCP Servers

  • A
    license
    Not graded
    quality
    A
    maintenance
    A proxy server that wraps existing MCP servers to significantly reduce token consumption by compressing tool descriptions into a two-step interface. It enables users to integrate extensive toolsets without exceeding context limits or incurring high API costs.
    106
    Apache 2.0
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enterprise-grade dynamic MCP proxy that eliminates token bloat by lazy-loading tool schemas based on semantic intent, enabling efficient orchestration of multiple backend tools from a single endpoint.
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    An MCP proxy that minifies tool schemas to reduce context tokens, supporting minify and defer modes for efficient tool access.
  • A
    license
    A
    quality
    A
    maintenance
    MCP server and local proxy that compresses LLM prompts, tool output, and replies to cut token cost, with a quality gate that reverts any step that does not save. Exposes llmtrim_compress, llmtrim_compress_text, and llmtrim_stats.
    3
    213
    Mozilla Public 2.0

View all related MCP servers

Related MCP Connectors

  • Hosted MCP server for LLM cost estimation, model comparison, and budget-aware routing.

  • Free public MCP for AI agents — 193 tools, 44 workflows. No API key.

  • SaaS intelligence for AI agents. 5 unified tools cover 1,000+ services with 91-96% token savings.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/LoudiliMed/Refract'

If you have feedback or need assistance with the MCP directory API, please join our Discord server