Web Scraper MCP server

Extracts clean text content from web pages using BeautifulSoup and HTTPX with proper error handling for failed requests and connection issues.
Back to servers
Setup instructions
Provider
un4ckn0wl3z
Release date
Apr 08, 2025
Language
Python
Stats
1 star

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.

Installation

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

Usage

Starting the Server

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

Basic API Interaction

The MCP Scraper Engine exposes endpoints that follow the Model Context Protocol specification. Here are the main ways to interact with it:

Making Scraping Requests

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);

Configuration Options

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' }
    ]
  }
};

Handling Pagination

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
  }
};

Advanced Features

JavaScript Execution

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;
      })()
    };
  `
};

Error Handling

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);
}

Rate Limiting

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: {...}
};

How to install this MCP server

For Claude Code

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.

For Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.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

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later