Are you the author? Sign in to claim
MCP spider server using crawl4ai for web crawling and content extraction
An MCP (Model Context Protocol) server that provides web crawling capabilities using crawl4ai. Supports multiple content formats output (HTML, JSON, PDF, screenshots, Markdown) and browser interaction features.
To launch the server, you have several options:
python launch_server.py
./launch_server.sh
launch_server.bat
python mcp_server/server.py
To configure this server with MCP, you have multiple options depending on your setup:
This is the recommended approach as it handles virtual environment setup and dependency installation automatically:
{
"mcpServers": {
"dev-tool-mcp": {
"command": "/bin/bash",
"args": [
"-c",
"cd /absolute/path/to/your/dev-tool-mcp && ./launch_server.sh"
],
"description": "MCP development tool server providing web crawling, browser automation, content extraction, and real-time page analysis capabilities"
}
}
}
Make sure to replace /absolute/path/to/your/dev-tool-mcp with the actual absolute path to your project directory.
If you prefer to run the server directly with the virtual environment:
{
"mcpServers": {
"dev-tool-mcp": {
"command": "/absolute/path/to/your/dev-tool-mcp/launch_server.sh",
"args": [],
"description": "MCP development tool server providing web crawling, browser automation, content extraction, and real-time page analysis capabilities"
}
}
}
If the package is installed in the virtual environment, you can use the console script:
{
"mcpServers": {
"dev-tool-mcp": {
"command": "/absolute/path/to/your/dev-tool-mcp/launch_server.sh",
"args": [],
"description": "MCP development tool server providing web crawling, browser automation, content extraction, and real-time page analysis capabilities"
}
}
}
For Windows systems, use the batch script:
{
"mcpServers": {
"dev-tool-mcp": {
"command": "cmd",
"args": [
"/c",
"cd /d C:\\absolute\\path\\to\\your\\dev-tool-mcp && launch_server.bat"
],
"description": "MCP development tool server providing web crawling, browser automation, content extraction, and real-time page analysis capabilities"
}
}
}
Note: The launch scripts (Methods 1-3 on Unix/Linux/Mac and Method 4 on Windows) are recommended because they will:
- Check if the virtual environment exists
- Create it if needed
- Install dependencies from pyproject.toml
- Activate the environment
- Start the server with all necessary dependencies
This ensures a consistent and reliable setup for the MCP server.
The MCP server is structured into the following modules:
mcp_server/
├── server.py # Main MCP server definition and tool handling
├── utils.py # Utility functions for file operations
├── browser/ # Browser automation functionality
│ ├── browser_service.py # Playwright-based browser service
│ └── README.md # Browser module documentation
└── crawl/ # Web crawling functionality
└── crawl.py # Core crawling implementation with crawl4ai
Clone the repository:
git clone <repository-url>
cd mcp-server
Install the package and dependencies:
pip install -e .
Install Playwright browsers:
python -m playwright install chromium
The server requires the following dependencies (automatically installed via pip):
crawl4ai>=0.7.7: Web crawling librarypydantic>=2.0.0: Data validationmcp==1.0.0: Model Context Protocol implementationhttpx[socks]: HTTP clientlitellm: LLM interfacebeautifulsoup4>=4.12.2: HTML parsinglxml>=4.9.3: XML/HTML processingsentencepiece: Text processingplaywright>=1.40.0: Browser automationThe server uses the following environment variables (optional):
TEST_URL: URL for testing (used in test files)The server exposes the following tools via MCP:
name (string, optional): The name to greet, defaults to "World"message (string, required): The message to echo backurl (string, required): The URL of the web page to crawlsave_path (string, required): The base file path to save the crawled content and downloaded filesinstruction (string, optional): The instruction to use for the LLM (default: "")save_screenshot (boolean, optional): Save a screenshot of the page (default: false)save_pdf (boolean, optional): Save a PDF of the page (default: false)generate_markdown (boolean, optional): Generate a Markdown representation of the page (default: false)url (string, required): The URL of the web page to get content fromwait_for_selector (string, optional): Optional CSS selector to wait for before getting contentwait_timeout (integer, optional): Wait timeout in milliseconds, default 30000url (string, required): The URL of the web page to get console messages fromwait_for_selector (string, optional): Optional CSS selector to wait for before getting console messageswait_timeout (integer, optional): Wait timeout in milliseconds, default 30000url (string, required): The URL of the web page to get network requests fromwait_for_selector (string, optional): Optional CSS selector to wait for before getting network requestswait_timeout (integer, optional): Wait timeout in milliseconds, default 30000The server can be started using the console script defined in pyproject.toml:
dev-tool-mcp
Or directly via Python:
python -m mcp_server.server
The server uses stdio for MCP communication, making it compatible with MCP clients.
To crawl a web page and save content in multiple formats:
{
"name": "crawl_web_page",
"arguments": {
"url": "https://example.com",
"save_path": "/path/to/save",
"save_screenshot": true,
"save_pdf": true,
"generate_markdown": true
}
}
This will create a timestamped subdirectory with:
output.html - Page HTML contentoutput.json - Page content in JSON formatoutput.png - Screenshot of the page (if requested)output.pdf - PDF of the page (if requested)raw_markdown.md - Markdown representation of the page (if requested)downloaded_files.json - List of downloaded filesfiles/ - Directory containing downloaded filesTo retrieve page content:
{
"name": "get_page_content",
"arguments": {
"url": "https://example.com",
"wait_for_selector": "#main-content",
"wait_timeout": 10000
}
}
To capture console messages from a page:
{
"name": "get_console_messages",
"arguments": {
"url": "https://example.com",
"wait_for_selector": ".app",
"wait_timeout": 15000
}
}
To monitor network requests made by a page:
{
"name": "get_network_requests",
"arguments": {
"url": "https://example.com",
"wait_for_selector": "[data-loaded]",
"wait_timeout": 20000
}
}
The project includes comprehensive tests for both browser and crawler functionality:
# Run all tests
pytest
# Run specific test files
python -m pytest test/test_crawler.py
python -m pytest test/test_browser.py
# Run browser tests directly
python -m test.test_browser
test_crawler.py: Tests the complete crawler functionality, including file saving and format generationtest_browser.py: Tests browser service functions for page content, console messages, and network requestsThe crawler test specifically verifies:
Install the package in your production environment:
pip install dev-tool-mcp
Install Playwright browsers:
python -m playwright install chromium --with-deps
Run the server:
dev-tool-mcp
Create a Dockerfile for containerized deployment:
FROM python:3.11-slim
WORKDIR /app
COPY pyproject.toml .
COPY mcp_server/ ./mcp_server/
RUN pip install -e .
RUN python -m playwright install chromium --with-deps
CMD ["dev-tool-mcp"]
The server includes security measures to prevent malicious URLs:
If you encounter browser-related errors:
python -m playwright install chromium
Ensure the server has write permissions to the specified save paths:
mkdir -p /path/to/save
chmod 755 /path/to/save
For network-related crawling issues, verify:
Large page crawls can consume significant memory. For large-scale crawling:
Enable verbose logging to troubleshoot issues:
# Check the server logs for error messages
# Monitor file system permissions
# Verify network connectivity to target URLs
This project is licensed under the terms specified in the pyproject.toml file. See the project repository for full license details.
Run Claude Code as an MCP server so any agent can delegate coding tasks to it
Browser automation using accessibility snapshots instead of screenshots
Google's universal MCP server supporting PostgreSQL, MySQL, MongoDB, Redis, and 10+ databases
Official GitHub integration for repos, issues, PRs, and CI/CD workflows