r/ClaudeAI 的一篇文章推出了 PullMD,以修复 Claude 代码中的 HTML 令牌膨胀问题。相同的修复通过 Scavio 的 /extract 端点运行,无需基础设施。本教程介绍了交换。
前置条件
- 安装克劳德代码
- Scavio API 密钥
操作指南
步骤 1: 识别当前代理中的令牌燃烧 HTML
寻找获取原始 HTML 并将其传递给 LLM 的工具调用。
Python
# Before:
# fetch(url) -> raw HTML -> LLM context
# 60KB HTML = ~30K tokens步骤 2: 连接 Scavio MCP
克劳德代码中的一行配置。
Bash
claude mcp add scavio https://mcp.scavio.dev/mcp --header "x-api-key: $SCAVIO_API_KEY"步骤 3: 将获取工具替换为提取 MCP 工具
代理调用 extract(url) 而不是 fetch。
Python
# Agent prompt now uses extract tool:
# 'Use extract to read the markdown of $URL'
# Returns ~3K tokens of clean markdown.步骤 4: 在令牌计数之前/之后运行
比较同一任务上的令牌使用情况。
Text
# Before: 30K input tokens / call
# After: 3K input tokens / call
# 10x reduction at the input layer.步骤 5: 决定每次通话的费用
Scavio 提取费用为 1 个积分/通话。 PullMD 自托管是免费的+您的基础设施。
Text
# Scavio: $0.0043/call hosted
# PullMD: $0/call + server you maintain
# Pick based on infra preference.Python 示例
Python
# Direct API alternative if not using MCP:
import os, requests
resp = requests.post('https://api.scavio.dev/api/v1/extract',
headers={'x-api-key': os.environ['SCAVIO_API_KEY']},
json={'url': url, 'format': 'markdown'}).json()
markdown = resp.get('markdown', '')JavaScript 示例
JavaScript
// Same shape in TS.
const resp = await fetch('https://api.scavio.dev/api/v1/extract', {
method: 'POST',
headers: { 'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({ url, format: 'markdown' })
}).then(r => r.json());预期输出
JSON
Claude Code agent's HTML-related tool calls drop from ~30K input tokens to ~3K. Per-task LLM cost drops accordingly.