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 分