Token Enhancer

io.github.xelektron由 GitHub 帳號 xelektron 發布v0.2.1更新於 Oct 24, 2026

Cuts AI web-fetching costs up to 99.9% by stripping page junk before it reaches your LLM.

概覽

AI 產生的概覽

讓助理以純文字方式抓取網頁,去除 HTML 雜訊並快取結果,藉此減少 token 用量。

可以做什麼
Token Enhancer 以本機 MCP 伺服器方式執行,提供三個工具:fetch_clean 抓取指定網址並回傳去除 HTML、JSON 與指令碼雜訊後的乾淨文字;fetch_clean_batch 一次抓取多個網址;refine_prompt 可選擇性精簡提示詞中的冗餘措辭,並同時顯示兩個版本。它會快取抓取結果,讓重複請求更快速。README 舉例指出某財經頁面從 704,760 個 token 降至 2,625 個。
適用情境
適合助理經常閱讀網頁、而原始 HTML 佔用大量上下文或推高成本的場景。適用於只需可讀正文的文章、財經頁面、新聞網站或程式碼倉庫頁面抓取。
執行需求
本機需安裝 Python 3.10+;透過 PyPI 安裝 xelektron-token-enhancer 套件,並以本機 MCP 伺服器程序啟動。不需要 API 金鑰、LLM 或 GPU。抓取網頁需要網路存取。部分 Linux 主機可能需要透過 REQUESTS_CA_BUNDLE 環境變數指定 SSL CA 憑證路徑。
安裝前請注意
此伺服器會代助理抓取任意網址,網頁內容會進入模型上下文,請求由使用者本機發出。它會在本機快取抓取的頁面。可選的提示詞精簡功能會改寫提示文字,但會同時顯示兩個版本供確認。README 建議在 Linux 上設定 REQUESTS_CA_BUNDLE,這會改變憑證驗證行為。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Token Enhancer,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Token Enhancer

A local proxy that strips web pages down to clean text before they enter your AI agent's context window.

One fetch of Yahoo Finance: 704,760 tokens → 2,625 tokens. 99.6% reduction.

No API key. No LLM. No GPU. Just Python.

The Problem

AI agents waste most of their token budget loading raw HTML pages into context. A single Yahoo Finance page is 704K tokens of navigation bars, ads, scripts, and junk. Your agent pays for all of it before any reasoning happens.

The Solution

Token Enhancer sits between your agent and the web. It fetches the page, strips the noise, caches the result, and returns only clean data.

SourceRaw TokensAfter ProxyReduction
Yahoo Finance (AAPL)704,7602,62599.6%
Wikipedia article154,44019,47987.4%
Hacker News8,66285990.1%
GitHub repo page171,2346,97695.9%

Install

bash
pip install xelektron-token-enhancer

Quick Start (from source)

git clone https://github.com/xelektron/token-enhancer.gitcd token-enhancerchmod +x install.sh./install.shsource .venv/bin/activatepython3 test_all.py --live

Usage

As a standalone proxy

source .venv/bin/activatepython3 proxy.py

Then in another terminal:

curl -s http://localhost:8080/fetch \  -H "content-type: application/json" \  -d '{"url": "https://finance.yahoo.com/quote/AAPL/"}' \  | python3 -m json.tool

As an MCP Server (Claude Desktop, Cursor, OpenClaw)

This is the plug and play option. Your AI agent discovers the tools automatically and uses them on its own.

bash
pip install xelektron-token-enhancer

Claude Desktop: Add to your config file

Mac: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

json
{  "mcpServers": {    "token-enhancer": {      "command": "python3",      "args": ["-m", "mcp_server"],      "env": {        "REQUESTS_CA_BUNDLE": "/etc/ssl/certs/ca-certificates.crt"      }    }  }}

On Linux hosts where SSL verification fails, the env block above overrides the default CA bundle. Remove it on macOS/Windows.

Cursor: Add to .cursor/mcp.json in your project:

json
{  "mcpServers": {    "token-enhancer": {      "command": "python3",      "args": ["-m", "mcp_server"]    }  }}

Once connected, your agent gets three tools:

fetch_clean fetches any URL and returns clean text (86 to 99% smaller)

fetch_clean_batch fetches multiple URLs at once

refine_prompt optional prompt cleanup, shows both versions so you decide

As a LangChain Tool

python
from langchain.tools import toolimport requests
@tooldef fetch_clean(url: str) -> str:    """Fetch a URL and return clean text with HTML noise removed."""    r = requests.post("http://localhost:8080/fetch", json={"url": url})    return r.json()["content"]

Add fetch_clean to your agent's tool list. Start python3 proxy.py first.

Features

Data Proxy (Layer 2) Fetches any URL, strips HTML/JSON noise, returns clean text. Caches results so repeat fetches are instant. Handles HTML, JSON, and plain text.

Prompt Refiner (Layer 1, opt in) Strips filler words and hedging while protecting tickers, dates, money values, negations, and conversation references. You see both versions and choose.

MCP Server Plug into Claude Desktop, Cursor, OpenClaw, or any MCP client. Agent discovers the tools and uses them automatically.

API Endpoints (proxy mode)

EndpointMethodDescription
/fetchPOSTFetch URL, strip noise, return clean data
/fetch/batchPOSTFetch multiple URLs at once
/refinePOSTOpt in prompt refinement
/statsGETSession statistics

Run Tests

python3 test_all.py           # Layer 1 only (offline)python3 test_all.py --live    # Layer 1 + Layer 2 (needs internet)

Roadmap

  • Layer 1: Prompt refiner
  • Layer 2: Data proxy with caching
  • MCP server integration
  • LangChain tool example
  • Browser fallback (Playwright) for bot blocked sites
  • Authenticated session management
  • Layer 3: Output/history compression
  • CLI tool
  • Dashboard UI

Requirements

Python 3.10+. No API keys. No GPU.

License

MIT

來源:README.md,提交 7291cfe

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.2.1最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分