关于 Refinery MCP
Refinery MCP 是一款 MCP 服务,可将抓取的 URL 或原始 HTML 清理为适用于 Agent 和 RAG 流程的文本,并提供词数与 Token 节省估算;页面渲染和爬取由其他工具负责。
主要功能
- 01通过 Refinery Apify Actor 清理 URL
- 02清理其他工具获取的 HTML
- 03返回清理文本和词数
- 04本地估算 Token 节省
适用场景
- 01为 RAG 入库准备网页
- 02减少 LLM 上下文中的 HTML 噪声
- 03嵌入前检查预估 Token 减少量
MCP 相关
通过 MCP 工具暴露 `clean_url`、`clean_html` 和 `estimate_savings`。URL 清理调用 Refinery Apify Actor;节省量估算在本地运行。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
3收录的工具列表 · 更新于 2 周前
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| url | string | 是 | 要清理的公开 URL。 |
| removeStyles | boolean | 否 | |
| removeScripts | boolean | 否 |
详细介绍
Refinery MCP
在 Agent 消耗 token 之前清理 HTML。
Refinery MCP 将 Refinery Apify Actor 封装为 MCP 服务,让 Claude、Cursor 和其他 Agent 能够将原始 HTML 或 URL 转换为适合大模型使用的干净文本,并提供 word_count。

flowchart LR
A[Agent needs web context] --> B[Fetch URL or raw HTML]
B --> C[Refinery MCP]
C --> D[Refinery Apify Actor]
D --> E[Clean text + word_count]
E --> F[RAG / embeddings / LLM context]
问题所在
Agent 越来越擅长抓取网页。问题在于它们抓取的内容:
<html>
<head>
<script>gtag("event", "page_view")</script>
<style>.nav,.cookie,.footer{display:block}</style>
</head>
<body>
<nav>Home · Pricing · Login · Docs · Blog · Careers</nav>
<aside>Subscribe to our newsletter</aside>
<article>
<h1>How ACME cut support ticket routing time by 63%</h1>
<p>ACME routes 40,000 monthly support tickets through an AI triage system.</p>
<p>The team reduced retrieval noise by cleaning HTML before chunking.</p>
</article>
<footer>Legal · Privacy · Cookie settings · LinkedIn · X</footer>
</body>
</html>
模型并不需要其中大部分内容。它需要的是:
How ACME cut support ticket routing time by 63%
ACME routes 40,000 monthly support tickets through an AI triage system.
The team reduced retrieval noise by cleaning HTML before chunking.

Refinery MCP 为你的 Agent 提供了一个工具来完成这个中间步骤:
fetch page -> refine HTML -> send clean text to RAG / embeddings / LLM
原因
Agent 可以抓取网页,但原始 HTML 噪声多、成本高:
- 脚本、样式、跟踪标签
- 导航栏、页脚、Cookie 横幅
- 重复链接和布局标记
- 模型看到真正内容之前就消耗大量 token
Refinery 是 Agent 在将网页内容塞进提示词之前可以调用的中间步骤:
fetch/render -> clean/refine -> chunk/embed/answer
它不是爬虫。需要渲染时,请使用 Firecrawl、Crawl4AI、Playwright、浏览器自动化或你自己的抓取器。如果你已经有 URL 或原始 HTML,并希望在大模型处理前以低成本清理一遍,则使用 Refinery。
适用场景
以下情况下可使用 Refinery MCP:
- Agent 已经抓取了网页,但得到的 HTML 臃肿不堪
- 你希望在 RAG 入库之前增加一个确定性的清理步骤
- 你需要在嵌入之前估算
word_count/ 类 token 节省量 - 你希望将网页抓取与内容清理分开
不要将它用作浏览器渲染器、反机器人层或网站爬虫。
工具
clean_url
通过 Refinery Apify Actor 抓取 URL,并返回包含干净文本和元数据的数据集行。
输入示例:
{
"url": "https://docs.stripe.com/payments",
"removeScripts": true,
"removeStyles": true
}
clean_html
清理 Agent、爬虫或浏览器会话已抓取的原始 HTML。
输入示例:
{
"html": "<html><body><nav>Home Pricing Login</nav><article><h1>Vendor security update</h1><p>We now support SOC 2 exports for enterprise accounts.</p></article><footer>Legal Privacy Careers</footer></body></html>",
"extractMentions": false,
"extractHashtags": false
}
结果示例:
{
"text": "Vendor security update\n\nWe now support SOC 2 exports for enterprise accounts.",
"word_count": 10,
"content_type": "web",
"language": "en",
"processing_time_ms": 44.96,
"success": true
}
estimate_savings
本地辅助工具,用于比较原始 HTML 与清理后的文本并估算 token 节省量。此工具不会调用 Apify。
输出示例:
{
"raw_chars": 168,
"clean_chars": 41,
"estimated_raw_tokens": 42,
"estimated_clean_tokens": 11,
"estimated_token_savings": 31,
"reduction_pct": 76
}
安装
npx -y @larelabs/refinery-mcp
设置 Apify 令牌:
export APIFY_TOKEN=apify_api_xxx
export REFINERY_ACTOR_ID=larelabs/refinery-html-to-llm-cleaner
Cursor / Claude Desktop 配置
使用已发布的包:
{
"mcpServers": {
"refinery": {
"command": "npx",
"args": ["-y", "@larelabs/refinery-mcp"],
"env": {
"APIFY_TOKEN": "apify_api_xxx",
"REFINERY_ACTOR_ID": "larelabs/refinery-html-to-llm-cleaner"
}
}
}
}
或者在开发期间从源代码运行:
git clone https://github.com/LareLabs/refinery-mcp
cd refinery-mcp
npm install
npm run build
{
"mcpServers": {
"refinery": {
"command": "npm",
"args": ["run", "dev", "--prefix", "/absolute/path/to/refinery-mcp"],
"env": {
"APIFY_TOKEN": "apify_api_xxx"
}
}
}
}
冒烟测试
npm run build
APIFY_TOKEN=apify_api_xxx npm run smoke
冒烟测试会通过 stdio 启动 MCP 服务、列出工具,并调用 estimate_savings,不会消耗 Apify 额度。
Agent 提示词示例
Use Refinery MCP to clean this docs page before summarizing it:
https://docs.stripe.com/payments
Return the clean text, word_count, and a short summary. Do not summarize raw HTML.
另一个实用的提示词:
I fetched this page HTML with Playwright. Use Refinery MCP clean_html before adding it to my RAG ingestion queue. Return the cleaned text and estimated token savings.
路线图
- Glama 列表(已添加
glama.json— 在 https://glama.ai/mcp/servers 提交) - mcp.so 目录 PR(待处理)
- 托管式 HTTP/SSE MCP 传输
- 批量 URL 清理工具
- Glama / PulseMCP / FindMCP / mcp.so 列表
- 可选的 RapidAPI 直接 REST 封装
- Token 节省量基准测试页面
许可证
MIT
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。