# ⚡ Universal AI Web Markdown & Schema Extractor \[MCP] (`datalabs/universal-ai-markdown-mcp-extractor`) Actor

Sub-200ms ultra-clean web content extractor for AI agents. Converts websites to token-dense Markdown, extracts JSON-LD schemas, meta data, and contacts.

- **URL**: https://apify.com/datalabs/universal-ai-markdown-mcp-extractor.md
- **Developed by:** [Jayshree Jain](https://apify.com/datalabs) (community)
- **Categories:** Agents, AI, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.01 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## ⚡ Universal AI Web Markdown & Structured Data Extractor for LLMs & MCP

> **The Sub-200ms, Token-Dense Alternative to Heavy Headless Crawlers**\
> Engineered specifically for Autonomous AI Agents (Claude Desktop, Cursor, LangChain, CrewAI, LlamaIndex, MCP) and High-Volume Data Pipelines.

***

### 🚀 Architectural Comparison: Token-Dense AI Extractor vs. Heavyweight Headless Crawlers

| Architectural Feature | Traditional Headless Browser Crawlers | **Universal AI Markdown & Schema Extractor \[MCP]** |
| :--- | :---: | :---: |
| **Extraction Architecture** | Full Browser DOM / JavaScript Engine (High Compute & Memory Overhead) | ⚡ **Async HTTP Stream Parser (Lightweight, Sub-Second Execution)** |
| **Output Payload** | Raw HTML DOM, Inline CSS, Scripts, Navigation Boilerplate | 🎯 **Token-Budgeted Clean Markdown (Noise & Ad Elements Stripped)** |
| **LLM Context Safeguard** | Unbounded Payloads (Prone to Context Window Overflow) | 🛡️ **Hard-Capped 8,000 Token Ceiling with Truncation Indicator** |
| **Structured Schema.org** | ❌ None (Requires Custom Extraction Rules) | ✅ **Auto-Extracted JSON-LD (Products, FAQs, Articles, Orgs)** |
| **B2B Contact Intelligence** | ❌ None | ✅ **Auto-Harvests Emails, Phone Numbers & Social Links** |
| **Token Usage Tracking** | ❌ None | ✅ **Integrated `cl100k_base` Token & Character Metrics** |
| **Model Context Protocol (MCP)**| ⚠️ High Timeout & Memory Overhead Risk | ✅ **Native MCP Support for Claude Desktop, Cursor & Agents** |
| **Pricing Model** | Variable Compute Unit Charges | 💰 **Pay-Per-Event: $0.01 / 1,000 Pages ($0.00001/page)** |

***

### 🤖 1-Click AI Framework Integrations

#### 1. Claude Desktop & Cursor (Model Context Protocol - MCP)

Add this directly to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "web-markdown-extractor": {
      "command": "npx",
      "args": ["-y", "@apify/mcp-server", "--token", "YOUR_APIFY_TOKEN"]
    }
  }
}
```

#### 2. LangChain (Python)

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("datalabs/universal-ai-markdown-mcp-extractor").call(
    run_input={"startUrls": [{"url": "https://example.com"}]}
)
dataset_items = client.dataset(run["defaultDatasetId"]).list_items().items
clean_markdown = dataset_items[0]["markdown"]
print(f"Extracted {dataset_items[0]['tokenMetrics']['cl100kTokenCount']} tokens.")
```

#### 3. CrewAI Custom Tool

```python
from crewai.tools import tool
from apify_client import ApifyClient

@tool("Web Content Extractor")
def extract_web_content(url: str) -> str:
    """Extracts ultra-clean markdown, JSON-LD schemas, and contact info from any URL."""
    client = ApifyClient("YOUR_APIFY_TOKEN")
    run = client.actor("datalabs/universal-ai-markdown-mcp-extractor").call(
        run_input={"startUrls": [{"url": url}]}
    )
    items = client.dataset(run["defaultDatasetId"]).list_items().items
    return items[0]["markdown"] if items else "No content extracted."
```

***

### 🛠️ Input Parameters

```json
{
  "startUrls": [
    { "url": "https://news.ycombinator.com" },
    { "url": "https://apify.com" }
  ],
  "maxConcurrency": 10,
  "timeoutSecs": 15
}
```

***

### 📊 Output Dataset Fields

- `url`: Final resolved URL (after redirects)
- `success`: `true` / `false`
- `statusCode`: HTTP response code (e.g. 200)
- `markdown`: Clean, token-dense Markdown stripped of scripts, navs, footers, and cookie banners
- `tokenMetrics`: Character count and estimated `cl100k` token usage
- `meta`: Title, description, OpenGraph image, canonical URL, language
- `jsonLd`: Structured Schema.org JSON-LD objects
- `contacts`: Verified emails, phone numbers, and social URLs (LinkedIn, Twitter, GitHub, etc.)

# Actor input Schema

## `startUrls` (type: `array`):

List of webpage URLs to convert into clean markdown and extract structured metadata from.

## `maxConcurrency` (type: `integer`):

Maximum number of HTTP requests executing concurrently.

## `timeoutSecs` (type: `integer`):

Individual request timeout limit in seconds.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://news.ycombinator.com"
    },
    {
      "url": "https://apify.com"
    }
  ],
  "maxConcurrency": 10,
  "timeoutSecs": 15
}
```

# Actor output Schema

## `results` (type: `string`):

Contains extracted token-dense markdown, token metrics, JSON-LD schemas, and contact info.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "startUrls": [
        {
            "url": "https://news.ycombinator.com"
        },
        {
            "url": "https://apify.com"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("datalabs/universal-ai-markdown-mcp-extractor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "startUrls": [
        { "url": "https://news.ycombinator.com" },
        { "url": "https://apify.com" },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("datalabs/universal-ai-markdown-mcp-extractor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "startUrls": [
    {
      "url": "https://news.ycombinator.com"
    },
    {
      "url": "https://apify.com"
    }
  ]
}' |
apify call datalabs/universal-ai-markdown-mcp-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,datalabs/universal-ai-markdown-mcp-extractor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/PFih0VAPT2VHsDtcf/builds/sfQao4vI47ItJ1MDy/openapi.json
