WebSearchAndCrawl
Click on "Deploy 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., "@WebSearchAndCrawlCrawl the documentation site and extract all API endpoints."
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.
WebSearchAndCrawl
An MCP Server for Authenticated Web Crawling, Searching, and Document Processing
---.
š Purpose
WebSearchAndCrawl is an MCP (Model Context Protocol) server designed to:
Crawl websites (including authenticated ones) using Firefox session tokens or browser automation.
Search crawled content for regex matches and store results in a structured index.
Download and parse documents (PDF, DOCX, XLSX, etc.) from crawled sites.
Stream results in real-time via HTTP for integration with MCP clients.
Respect
robots.txtand enforce rate limits (5 requests/sec, 5 threads max).
This tool is ideal for:
Researchers who need to scrape authenticated or dynamic websites.
Developers building AI agents that require web data.
Automation of repetitive web tasks (e.g., monitoring, data extraction).
Related MCP server: Scout MCP Server
š§ Features
Feature | Description |
Authenticated Crawling | Uses Firefox session tokens to access logged-in pages. |
Browser Automation | Falls back to Playwright for dynamic content or login forms. |
Domain Whitelisting | Only crawls URLs matching a comma-delimited list of domains. |
Depth-limited Crawling | Configurable crawl depth (1-9 layers). |
Regex Search | Search crawled content or index for regex patterns. |
Document Parsing | Extracts text from PDF, DOCX, XLSX, and TXT files. |
Real-time Streaming | Results are streamed as JSONL (chunked by page). |
Indexing | Stores results in JSON files per domain for later search. |
Rate Limiting | Enforces 5 requests/sec and 5 threads max. |
Resume Support | Can resume interrupted crawls from checkpoints. |
Session Validation | Validates token scopes to prevent misuse. |
š¦ Installation
Prerequisites
Python 3.9+ (recommended: 3.11+).
Firefox (required for browser automation).
System Libraries (for document parsing):
PDF:
poppler-utils(Linux) orpdfminer.six(cross-platform).DOCX/XLSX:
python-docx,openpyxl.
Steps
1. Clone the Repository
git clone https://github.com/bpweatherill/WebSearchAndCrawl.git
cd WebSearchAndCrawl2. Set Up a Virtual Environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# OR
venv\Scripts\activate # Windows3. Install Dependencies
pip install -r requirements.txt4. Install Playwright Browsers
playwright install firefox5. (Optional) Configure Environment Variables
Create a .env file in the project root:
# Server
MCP_PORT=8808
MCP_HOST=0.0.0.0
# Crawler
MAX_DEPTH=9
MAX_THREADS=5
RATE_LIMIT=5
REQUEST_TIMEOUT=10
MAX_MEMORY_MB=1024
# Firefox
FIREFOX_PROFILE=my_profile # Optional: Specific Firefox profile
DEFAULT_SEARCH_ENGINE=google
# Directories
INDEX_DIR=./index
DOWNLOADS_DIR=./downloads
CHECKPOINTS_DIR=./checkpointsš Usage
1. Start the MCP Server
python -m server.mainThe server will start on http://localhost:8808 (or the port specified in .env).
2. MCP Tools (HTTP Endpoints)
All tools return JSON responses and support streaming for real-time results.
Endpoint | Method | Description | Request Body |
| POST | Crawl a website and stream results. | |
| POST | Search the local index for regex matches. | |
| POST | Download documents matching a regex. | |
| POST | Use Firefox's search engine to fetch results. | |
| GET | List all domains with indexed content. | - |
| GET | Health check. | - |
Request/Response Schemas
CrawlRequest
{
"url": "https://www.nasa.gov",
"whitelist_domains": "nasa.gov",
"max_depth": 3,
"use_token": false,
"firefox_profile": "my_profile"
}url: Starting URL for the crawl.whitelist_domains: Comma-delimited list of allowed domains (e.g.,"nasa.gov,spacex.com").max_depth: Maximum crawl depth (1-9).use_token: Use Firefox session token if available.firefox_profile: Firefox profile name (optional).
Streamed Response (JSONL):
{
"excerpt": "NASA's Perseverance Rover lands on Mars...",
"full_text": "Full article text here...",
"url": "https://www.nasa.gov/mars2020",
"timestamp": "2024-05-20T12:00:00Z",
"domain": "nasa.gov"
}---.
SearchIndexRequest
{
"domain": "nasa.gov",
"regex": ".*Mars.*",
"max_results": 10
}domain: Domain to search (e.g.,"nasa.gov").regex: Regex pattern to match.max_results: Maximum number of results to return.
Response:
[
{
"url": "https://www.nasa.gov/mars2020",
"excerpt": "NASA's Perseverance Rover lands on Mars...",
"timestamp": "2024-05-20T12:00:00Z"
}
]---.
DownloadRequest
{
"domain": "nasa.gov",
"regex": ".*\\.pdf$",
"output_dir": "./downloads/nasa.gov"
}domain: Domain to download from.regex: Regex pattern for files to download (e.g.,"*.pdf").output_dir: Custom output directory (optional).
Streamed Response (JSONL):
{
"filename": "./downloads/nasa.gov/mars_rover.pdf",
"url": "https://www.nasa.gov/pdf/mars_rover.pdf",
"parsed_text": "Extracted text from PDF..."
}---.
WebSearchRequest
{
"query": "NASA Mars missions",
"search_engine": "google",
"use_token": false,
"firefox_profile": "my_profile"
}query: Search query.search_engine: Search engine (default: Firefox default).use_token: Use Firefox session token if available.firefox_profile: Firefox profile name (optional).
Streamed Response (JSONL):
{
"title": "Mars 2020 Mission - NASA",
"url": "https://www.nasa.gov/mars2020",
"snippet": "Learn about the Perseverance Rover..."
}š Examples
1. Crawl NASA.gov and Index Results
curl -X POST http://localhost:8808/crawl_website \
-H "Content-Type: application/json" \
-d '{
"url": "https://www.nasa.gov",
"whitelist_domains": "nasa.gov",
"max_depth": 2,
"use_token": false
}'2. Search Indexed Content for "Mars"
curl -X POST http://localhost:8808/search_index \
-H "Content-Type: application/json" \
-d '{
"domain": "nasa.gov",
"regex": ".*Mars.*",
"max_results": 5
}'3. Download PDFs from NASA.gov
curl -X POST http://localhost:8808/download_documents \
-H "Content-Type: application/json" \
-d '{
"domain": "nasa.gov",
"regex": ".*\\.pdf$"
}'4. Use Firefox to Search Google
curl -X POST http://localhost:8808/get_search_results \
-H "Content-Type: application/json" \
-d '{
"query": "NASA Mars missions",
"search_engine": "google"
}'š Project Structure
WebSearchAndCrawl/
ā
āāā server/ # Core server logic
ā āāā __init__.py
ā āāā main.py # FastAPI app + MCP tools
ā āāā config.py # Configuration settings
ā āāā schemas.py # Pydantic request/response models
ā ā
ā āāā firefox/ # Firefox browser automation
ā ā āāā __init__.py
ā ā āāā controller.py # Playwright Firefox management
ā ā āāā token_manager.py # Session token handling
ā ā
ā āāā crawler/ # Web crawling logic
ā ā āāā __init__.py
ā ā āāā crawler.py # Main crawling logic
ā ā āāā rate_limiter.py # Thread/rate limiting
ā ā
ā āāā indexer/ # Indexing and search
ā ā āāā __init__.py
ā ā āāā indexer.py # JSON index management
ā ā āāā search_engine.py # Regex search
ā ā
ā āāā downloader/ # Document downloading and parsing
ā ā āāā __init__.py
ā ā āāā downloader.py # Download logic
ā ā āāā parsers/ # File type parsers
ā ā āāā __init__.py
ā ā āāā pdf_parser.py
ā ā āāā docx_parser.py
ā ā āāā xlsx_parser.py
ā ā
ā āāā streamer.py # Chunked JSON streaming
ā
āāā tests/ # Unit and integration tests
ā āāā __init__.py
ā āāā test_firefox.py
ā āāā test_crawler.py
ā
āāā index/ # Index files (auto-generated)
ā āāā nasa.gov.json
ā āāā ...
ā
āāā downloads/ # Downloaded documents (auto-generated)
ā āāā nasa.gov/
ā ā āāā document1.pdf
ā ā āāā ...
ā āāā ...
ā
āāā checkpoints/ # Crawl checkpoints (auto-generated)
ā āāā ...
ā
āāā requirements.txt # Python dependencies
āāā .env.example # Example environment variables
āāā README.md # This fileāļø Configuration
Environment Variables
Variable | Default | Description |
|
| HTTP server port. |
|
| HTTP server host. |
|
| Maximum crawl depth (1-9). |
|
| Maximum concurrent threads. |
|
| Maximum requests per second. |
|
| Timeout for requests (seconds). |
|
| Maximum memory usage (MB). |
|
| Firefox profile name (optional). |
|
| Default search engine. |
|
| Directory for index files. |
|
| Directory for downloaded files. |
|
| Directory for crawl checkpoints. |
š”ļø Security Considerations
Session Tokens:
Tokens are only stored in memory (not persisted to disk).
Token scopes are validated to prevent misuse (e.g., a token for
nasa.govcannot be used forevil.com).
Input Sanitization:
All inputs (URLs, regex, etc.) are sanitized to prevent injection attacks.
Rate Limiting:
Enforces 5 requests/sec and 5 threads max to avoid overwhelming servers.
robots.txtCompliance:The crawler respects
robots.txtand skips disallowed URLs.
Whitelisting:
Only URLs matching the whitelisted domains are crawled.
š Enhancements (Roadmap)
Enhancement | Description | Priority |
Persistent Tokens | Store tokens in an encrypted file for persistence across restarts. | Medium |
Full | Properly parse | Medium |
Advanced Pagination Handling | Detect and follow pagination links (e.g., "Next" buttons). | High |
Lazy-Loading Support | Detect and trigger lazy-loaded content (e.g., infinite scroll). | High |
Checkpointing | Save crawl state to resume interrupted crawls. | High |
Full-Text Search | Support full-text search in addition to regex. | Low |
Database Backend | Replace JSON files with SQLite/PostgreSQL for scalability. | Low |
Distributed Crawling | Support horizontal scaling with multiple workers. | Low |
Docker Support | Add a | Medium |
Authentication Helpers | Built-in support for common auth methods (OAuth, SAML). | Medium |
Proxy Support | Add proxy support for crawling behind firewalls. | Low |
Custom Headers | Allow users to specify custom headers for requests. | Medium |
Webhook Notifications | Notify a webhook URL when new results are found. | Low |
š¤ Contributing
Fork the repository.
Create a feature branch (
git checkout -b feature/your-feature).Commit your changes (
git commit -m "Add your feature").Push to the branch (
git push origin feature/your-feature).Open a Pull Request.
š License
This project is licensed under the MIT License. See LICENSE for details.
š Support
Issues: Report bugs or request features in the GitHub Issues tab.
Discussions: Join the GitHub Discussions for Q&A.
š Acknowledgments
Playwright: For browser automation.
FastAPI: For the HTTP server.
pdfminer.six: For PDF parsing.
python-docx/openpyxl: For Office file parsing.
This server cannot be deployed
Maintenance
Related MCP Connectors
Stealth web browser for agents: search, fetch, click, download and type in persistent MCP sessions.
One MCP for the Web. Easily search, crawl, navigate, and extract websites without getting blocked.ā¦
Scrape, crawl and search the web for AI agents via MCP.
Web MCP: scrape/crawl sites, web search, brand assets, app stores, YouTube, Reddit, Hacker News.
Related MCP Servers
- AlicenseCqualityCmaintenanceProvides browser automation and web scraping as MCP tools, enabling autonomous URL ingestion, crawling, extraction, and anti-bot handling with interactive browser control.625MIT

Scout MCP Serverofficial
AlicenseNot gradedqualityDmaintenanceEnables web search, scraping, extraction, and crawling through an MCP interface, allowing coding agents to access real-time web data.1MIT- AlicenseNot gradedqualityCmaintenanceA read-only Python MCP server for authorized website research, structured data extraction, downloadable-document analysis, and content auditing inside OpenCode. It crawls authorized public domains with safety constraints including robots.txt respect, SSRF defenses, bounded concurrency, and content-type allowlists.MIT
- AlicenseNot gradedqualityBmaintenanceEnables web search and scraping through MCP, running locally with courtesy rate limiting and caching.1 npmISC