The MCP Scraper Engine provides a standardized way to interact with web pages for data extraction through the Model Context Protocol (MCP). This server implementation allows you to perform web scraping operations with a simple, consistent API interface.
You can install the MCP Scraper Engine using npm:
npm install mcp-scraper-engine
Alternatively, you can clone the repository and install dependencies:
git clone https://github.com/yourusername/mcp-scraper-engine.git
cd mcp-scraper-engine
npm install
To start the MCP server, run:
npm start
By default, the server will run on port 3000. You can specify a different port using the PORT environment variable:
PORT=8080 npm start
The MCP Scraper Engine exposes endpoints that follow the Model Context Protocol specification. Here are the main ways to interact with it:
Send a POST request to the server's endpoint with your scraping parameters:
const response = await fetch('http://localhost:3000/api/scrape', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://example.com',
selectors: {
title: 'h1',
paragraphs: 'p',
links: 'a'
}
})
});
const data = await response.json();
console.log(data);
You can configure the scraper by providing additional options in your request:
const request = {
url: 'https://example.com',
selectors: {
title: 'h1',
paragraphs: 'p'
},
options: {
wait: 2000, // Wait 2 seconds for JavaScript to load
timeout: 10000, // Set a 10-second timeout
userAgent: 'Mozilla/5.0...', // Custom user agent
cookies: [ // Custom cookies
{ name: 'session', value: 'abc123', domain: 'example.com' }
]
}
};
For multi-page scraping, you can specify pagination parameters:
const request = {
url: 'https://example.com/products',
selectors: {
products: '.product-item'
},
pagination: {
nextSelector: '.pagination .next',
maxPages: 5
}
};
You can execute custom JavaScript on the target page:
const request = {
url: 'https://example.com',
execute: `
// Custom JavaScript to execute on the page
return {
scrolledContent: (() => {
window.scrollTo(0, document.body.scrollHeight);
return document.body.innerHTML;
})()
};
`
};
The API returns standard error codes with descriptive messages:
try {
const response = await fetch('http://localhost:3000/api/scrape', {...});
const data = await response.json();
if (!response.ok) {
console.error(`Error: ${data.error}`);
// Handle error appropriately
} else {
// Process successful response
}
} catch (error) {
console.error('Network or parsing error:', error);
}
To avoid overwhelming target websites, you can configure rate limiting:
const request = {
urls: [
'https://example.com/page1',
'https://example.com/page2',
'https://example.com/page3'
],
rateLimit: {
requestsPerMinute: 10,
delayBetweenRequests: 1000 // milliseconds
},
selectors: {...}
};
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "mcp-scraper-engine" '{"command":"npx","args":["-y","mcp-scraper-engine"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"mcp-scraper-engine": {
"command": "npx",
"args": [
"-y",
"mcp-scraper-engine"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"mcp-scraper-engine": {
"command": "npx",
"args": [
"-y",
"mcp-scraper-engine"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect