refinery-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@refinery-mcp Clean the HTML from https://docs.stripe.com/payments"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Refinery MCP
Clean HTML before your agent burns tokens.
Refinery MCP wraps the Refinery Apify Actor as an MCP server so Claude, Cursor, and other agents can turn raw HTML or URLs into clean LLM-ready text plus 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]The Problem
Agents are getting good at fetching web pages. The problem is what they fetch:
<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>The model does not need most of that. It needs this:
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 gives your agent a tool for that middle step:
fetch page -> refine HTML -> send clean text to RAG / embeddings / LLMRelated MCP server: readdown-mcp
Why
Agents can fetch pages, but raw HTML is noisy and expensive:
scripts, styles, tracking tags
nav, footers, cookie banners
repeated links and layout markup
huge token burn before the model sees the real content
Refinery is the middle step your agent can call before it stuffs web context into a prompt:
fetch/render -> clean/refine -> chunk/embed/answerIt is not a crawler. Use Firecrawl, Crawl4AI, Playwright, browser automation, or your own fetcher when you need rendering. Use Refinery when you already have a URL or raw HTML and want a cheap cleanup pass before the LLM.
When To Use It
Use Refinery MCP when:
your agent already fetched a page but got bloated HTML
you want a deterministic cleanup step before RAG ingestion
you need
word_count/ token-ish savings before embeddingyou want to separate crawling from content cleanup
Do not use it as your browser renderer, anti-bot layer, or site crawler.
Tools
clean_url
Fetches a URL through the Refinery Apify Actor and returns dataset rows with clean text and metadata.
Example input:
{
"url": "https://docs.stripe.com/payments",
"removeScripts": true,
"removeStyles": true
}clean_html
Cleans raw HTML your agent, crawler, or browser session already fetched.
Example input:
{
"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
}Example result:
{
"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
Local helper that compares raw HTML vs cleaned text and estimates token savings. This does not call Apify.
Example output:
{
"raw_chars": 168,
"clean_chars": 41,
"estimated_raw_tokens": 42,
"estimated_clean_tokens": 11,
"estimated_token_savings": 31,
"reduction_pct": 76
}Install
npx -y @larelabs/refinery-mcpSet your Apify token:
export APIFY_TOKEN=apify_api_xxx
export REFINERY_ACTOR_ID=larelabs/refinery-html-to-llm-cleanerCursor / Claude Desktop config
Use the published package:
{
"mcpServers": {
"refinery": {
"command": "npx",
"args": ["-y", "@larelabs/refinery-mcp"],
"env": {
"APIFY_TOKEN": "apify_api_xxx",
"REFINERY_ACTOR_ID": "larelabs/refinery-html-to-llm-cleaner"
}
}
}
}Or run from source during development:
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"
}
}
}
}Smoke Test
npm run build
APIFY_TOKEN=apify_api_xxx npm run smokeThe smoke test starts the MCP server over stdio, lists tools, and calls estimate_savings without spending Apify credits.
Example Agent Prompt
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.Another useful prompt:
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.Roadmap
Glama listing (
glama.jsonadded — submit at https://glama.ai/mcp/servers)mcp.so directory PR (pending)
Hosted HTTP/SSE MCP transport
Batch URL cleanup tool
Glama / PulseMCP / FindMCP / mcp.so listings
Optional direct REST wrapper for RapidAPI
Token savings benchmark page
License
MIT
Available Tools
3 toolsclean_htmlB
Clean raw HTML that your agent, crawler, or browser session already fetched.
Inputs: html (required), extractHashtags, extractMentions.
clean_urlC
Fetch a URL with the Refinery Apify actor and return clean LLM-ready text plus word_count.
Inputs: url (required), removeStyles, removeScripts.
estimate_savingsA
Estimate token savings from raw HTML vs cleaned text without making an Apify call.
Inputs: raw (required), cleaned (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 3 tools
Each tool targets a distinct input source: raw HTML, URL, or estimation, with no functional overlap.
All tools use consistent verb_noun snake_case pattern (clean_html, clean_url, estimate_savings).
Three tools is ideal for this narrow domain of HTML cleaning and token savings estimation.
The tool set covers all core operations: cleaning input text, fetching and cleaning a URL, and estimating token savings without a call.
Maintenance
Related MCP Connectors
Turn any web page URL or HTML into clean Markdown or plain text for an LLM to read.
Clean web data for agents: any URL to Markdown or JSON, plus search, crawls and company brand data.
Clean Markdown and AI-readability scoring for any URL. Built for AI agents.
Any URL to clean text, markdown, or JSON for LLM/RAG pipelines.
Related MCP Servers
AlicenseAqualityBmaintenanceConverts any URL to clean, token-efficient Markdown for AI agents. Strips ads, navigation, and scripts. Supports CSS selectors, batch processing (10 URLs), token counting, and smart caching.33 npmMIT- AlicenseAqualityDmaintenanceConverts web pages and HTML strings into clean, LLM-optimized Markdown with metadata extraction and token estimation. It uses a lightweight, browserless approach to provide token-efficient output for more effective LLM processing.2MIT
- AlicenseAqualityDmaintenanceConverts URLs and raw HTML to clean Markdown, enabling AI assistants to read web pages for summarization, analysis, or ingestion.22 npm1MIT
- FlicenseNot gradedqualityBmaintenanceEnables LLM agents to convert bloated webpages into clean token-dense plain text, stripping HTML, CSS, scripts, and layout elements while reducing context-window costs and supporting x402 micro-pay-based autonomous requests.-