refinery-mcp
Click on "Install 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-mcpClean 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.
| Name | Required | Description | Default |
|---|---|---|---|
| html | Yes | Raw HTML to strip and normalize. | |
| extractHashtags | No | ||
| extractMentions | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must disclose behavioral traits. It only states 'Clean' and from the parameter description 'strip and normalize.' It does not detail what cleaning entails (e.g., removal of scripts, styles), side effects, or error conditions, leaving significant gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single concise sentence, front-loaded with the key action. It avoids verbosity, though it could include more detail without becoming overly long. Still, it is efficient.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool has three parameters, no output schema, and low schema coverage, the description is insufficient. It provides no information about return values, default behaviors of boolean parameters, or any preconditions, making it incomplete for an agent to use confidently.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is only 33% (only the 'html' parameter has a description). The description fails to explain the purpose of the 'extractHashtags' and 'extractMentions' boolean parameters, leaving the agent to guess. With such low coverage, the description should compensate but does not.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states 'Clean raw HTML' with a specific verb and object, and specifies the source (agent, crawler, browser session). It distinguishes this tool from sibling tools like clean_url and estimate_savings by focusing on HTML cleaning.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description tells when to use this tool: when you have raw HTML from fetching. It does not provide explicit exclusions or alternatives, but the context of 'already fetched' implies a specific scenario, which is helpful.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
clean_urlC
Fetch a URL with the Refinery Apify actor and return clean LLM-ready text plus word_count.
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | The public URL to clean. | |
| removeStyles | No | ||
| removeScripts | No |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description must bear the full burden. It omits behavioral traits such as whether fetching is destructive, authentication requirements, rate limits, or error handling (e.g., invalid URL). The mention of 'Refinery Apify actor' is ambiguous.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is concise (one sentence) and front-loaded with the primary action, but it is too brief, sacrificing necessary detail. It could be expanded without becoming verbose.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the lack of output schema and low parameter coverage, the description is incomplete. It does not explain the return format, how cleaning is performed, or the role of each parameter. A user cannot fully understand the tool's usage.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is only 33% (only 'url' has a description). The description adds no meaning for 'removeStyles' and 'removeScripts' parameters, leaving their purpose unclear. It does not compensate for the schema's lack of detail.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool fetches a URL via the Refinery Apify actor and returns clean LLM-ready text plus word count. This distinguishes it from siblings like clean_html (likely HTML input) and estimate_savings (cost estimation).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No usage guidance is provided. The description does not specify when to use this tool versus alternatives like clean_html, nor does it mention prerequisites or scenarios where it should not be used.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
estimate_savingsA
Estimate token savings from raw HTML vs cleaned text without making an Apify call.
| Name | Required | Description | Default |
|---|---|---|---|
| raw | Yes | Original raw HTML or noisy text. | |
| cleaned | Yes | Cleaned text to compare against raw input. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description must disclose behavioral traits. It states the tool does not make an Apify call, indicating it is a local computation. However, it does not mention any other side effects, required permissions, or return behavior, leaving some gaps.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, well-structured sentence that front-loads the primary purpose. Every word is necessary, and there is no redundant information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
The tool has no output schema, so the description should explain the return value (e.g., type of savings, format). It fails to do so, leaving the agent uncertain about what the tool returns. The description is too minimal for a tool with this simplicity level.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already defines each parameter. The description adds minimal additional meaning beyond the schema, maintaining a baseline score of 3.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb 'estimate token savings' and identifies the resource ('raw HTML vs cleaned text'). The phrase 'without making an Apify call' distinguishes it from sibling tools like clean_html and clean_url, which likely involve API calls.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies usage context (estimating savings before deciding to clean) but does not provide explicit guidance on when to use this tool versus alternatives, nor does it state any prerequisites or exclusions.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v0.1.6- First observed
clean_html - First observed
clean_url - First observed
estimate_savings
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
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Clean Markdown and AI-readability scoring for any URL. Built for AI agents.
Web scraping for AI agents. Converts URLs to clean, LLM-ready Markdown with anti-bot bypass.
Fetch any URL and get clean Markdown. Web scraping for AI agents.
Web page or HTML to clean LLM-ready Markdown or JSON. x402 pay-per-call, $0.005, no API key.
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.33MIT- 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.2101MIT
- AlicenseNot gradedqualityCmaintenanceConverts URLs into clean, LLM-ready markdown, respecting robots.txt and never bypassing anti-bot measures or paywalls.MIT