scrape-n-search-mcp

v0.1.1
scrape-n-search-mcp Checked 3 days ago Published 1 month ago

MCP server unifying web-search and scraping providers behind a few agent tools

A lightweight MCP server that gives agents web search and scraping behind a few simple tools — web_search, web_fetch, web_browser_actions, web_screenshot, web_session, web_crawl, web_extract — backed by multiple providers and normalised into one consistent result shape. Every request is executed server-side: the provider fetches from its own IP pool, so the client's IP (including a VPN IP that many sites block) never reaches the target site. The only outbound request is an authenticated HTTPS call to the provider API.

Summary extracted from the README.

scrape-n-search

Web access for agents — from the provider's IP, not yours.

Python 3.10+ CI PyPI License: MIT

A lightweight MCP server that gives agents web search and scraping behind a few simple tools — web_search, web_fetch, web_browser_actions, web_screenshot, web_session, web_crawl, web_extract — backed by multiple providers and normalised into one consistent result shape.

Every request is executed server-side: the provider fetches from its own IP pool, so the client's IP (including a VPN IP that many sites block) never reaches the target site. The only outbound request is an authenticated HTTPS call to the provider API. Results come back LLM-friendly (markdown by default), which makes this a good fit for agentic coding and research tasks.

Quick start

pip install scrape-n-search-mcp       # or: uvx scrape-n-search-mcp
export SCRAPPEY_API_KEY=...

Add the server to your MCP client (config), then call:

web_search(query="MCP server design patterns")
→ {"query": "...", "provider": "scrappey",
   "results": [{"title": "...", "url": "...", "snippet": "..."}]}

Any configured provider works; the matrix below shows which capability each one serves.

Providers

Seven capabilities, nine providers. Scrappey is the recommended default for scraping — it is the cheapest full-browser option in the research (€0.10/1K direct requests, €1/1K full browser), pay-as-you-go with no subscription, a balance that never expires, residential proxies included, and you only pay for successful requests.

Provider search fetch browser_actions screenshot session crawl extract Requires
TinyFish ✅ ✅ TINYFISH_API_KEY
Tavily ✅ ✅ TAVILY_API_KEY
Exa ✅ ✅ EXA_API_KEY
DeepSeek ✅ ✅ DEEPSEEK_API_KEY
ZenRows ✅ ✅ ZENROWS_API_KEY
Scrappey (recommended) ✅ ✅ ✅ ✅ SCRAPPEY_API_KEY
Firecrawl ✅ ✅ ✅ ✅ FIRECRAWL_API_KEY
Serper ✅ SERPER_API_KEY
Jina ✅* ✅ JINA_API_KEY (search; fetch is keyless)

browser_actions, screenshot, and session are Scrappey-only capabilities (full-browser features). * s.jina.ai (search) now requires an API key; r.jina.ai (fetch) still works without one. DeepSeek Search & Fetch is per-request billed ($0.75 / 1k) and fetch returns Markdown only.

The router picks the first enabled provider (API key present) that supports the requested tool, in priority order, and fails over to the next one on error. Set DEFAULT_PROVIDER=scrappey in .env to make Scrappey the default for every call.

See research/ for the original provider comparison (pricing, free tiers, prepaid/credit models) that informed these choices.

Tools

Every tool returns a JSON string and accepts an optional provider parameter to force a specific provider; otherwise the default or auto-selected provider is used.

Tool Description
web_search query (required), max_results (5, 1–50), freshness, country → {query, provider, results:[{title, url, snippet, published_date?, score?}]} ^1
web_fetch url (required), format (markdown | html, enum), js_render, premium_proxy, proxy_country, session → {provider, url, title?, format, content}
web_browser_actions url + actions[] (required), format, proxy_country, session → {provider, url, format, content, javascript_return[]}
web_screenshot url (required), full_page, selector, proxy_country, session → {provider, url, format: "png", screenshot_base64}
web_session op (create | destroy) (required), session (required) → {provider, op, session, solution} — Scrappey browser-session lifecycle; pass the name to the other tools as session
web_crawl url (required), max_pages (10, 1–100), max_depth (2, 1–10) → {provider, pages:[{url, title?, content?}]} ^1
web_extract url (required), prompt → {provider, url, data}

^1 Scrappey has no search/crawl/extract endpoints. When Scrappey is the only configured provider, the first call to web_search/web_crawl/web_extract returns an explanation of the gated emulation and its drawbacks, and executes only after the follow-up flag described in that explanation. web_search uses one full-browser Bing request (€1/1K, ~20–40s — browser mode is required: live testing showed Bing serves stale cached result pages to Scrappey's basic-mode proxies); web_crawl uses per-page basic-mode fetches (€0.10/1K each); web_extract uses one Scrappey fetch plus one LLM summary call (OPENROUTER_API_KEY or HF_TOKEN; js_render=true for JS-heavy pages). Real search/crawl/extract providers are always preferred when configured.

Every response names the provider that actually served the request. When web_browser_actions runs execute_js, use format="html" — the markdown filter suppresses javascript_return results.

Requirements

  • Python 3.10+
  • An API key for at least one provider (see the table above)

One-line setup

Run this to install the MCP server into a dedicated user venv and register it with the harnesses it detects (Oh My Pi, Claude Desktop, Claude Code, Cursor, VS Code):

curl -fsSL https://raw.githubusercontent.com/hughyyy/scrape-n-search/main/install.sh | bash

The script fetches the source tarball for the pinned ref into ~/.local/share/scrape-n-search/src, creates ~/.local/share/scrape-n-search/venv, installs the package, and registers non-interactively when stdin is not a terminal. Read install.sh before piping it to a shell, and pin a tag in production: curl -fsSL <url> | bash -s -- --ref v0.2.0. After installing, add your API keys to src/mcp-server/.env (or run src/setup.sh).

Install

python3 -m venv .venv
.venv/bin/pip install -e mcp-server

# Configure — or run the interactive setup wizard
./setup.sh   # pick providers, paste+validate each API key live, then set the
             # default provider and fallback priority; writes mcp-server/.env
cp mcp-server/.env.example mcp-server/.env
# edit mcp-server/.env and set the API keys you want to use

# Run (stdio MCP server)
.venv/bin/scrape-n-search

Install & register with your agents (optional)

./install.sh (or the one-line setup above) installs the server into a dedicated user venv (~/.local/share/scrape-n-search/venv) so the interpreter path embedded in agent configs stays stable, then registers it with the MCP-aware harnesses it detects (Oh My Pi, Claude Desktop, Claude Code, Cursor, VS Code). Registration merges a scrape-n-search entry into each harness's own config file — other servers are preserved, a backup is written before any change, and writes are atomic.

./install.sh            # install + prompt to register with detected harnesses
./install.sh list       # show detection + registration state
./install.sh register   # re-register (e.g. after adding a harness)
./install.sh uninstall  # unregister, then remove the venv

Register against specific harnesses with --harness (e.g. ./install.sh register --harness omp --harness cursor). Codex is detected but not yet registered (its TOML schema is unsupported). Details: scripts/install_mcp.py.

MCP client config

Add the server to your MCP client's configuration (adjust paths to your checkout):

{
  "mcpServers": {
    "scrape-n-search": {
      "command": "/absolute/path/to/.venv/bin/python",
      "args": ["-m", "scrape_n_search"],
      "cwd": "/absolute/path/to/mcp-server"
    }
  }
}

Configuration

Configuration lives in mcp-server/.env (see mcp-server/.env.example). The server loads .env from its own project directory (override with SCRAPE_N_SEARCH_ENV_DIR) regardless of how it is launched, and existing environment variables take precedence. .env.example deliberately leaves DEFAULT_PROVIDER unset so a fresh install with any provider key boots.

Variable Effect
TINYFISH_API_KEY, TAVILY_API_KEY, EXA_API_KEY, ZENROWS_API_KEY, SCRAPPEY_API_KEY, FIRECRAWL_API_KEY, SERPER_API_KEY Enable the corresponding providers.
JINA_API_KEY Enables Jina search (fetch is keyless).
JINA_KEYLESS Set 0 to disable the keyless Jina fetch fallback (on by default).
DEFAULT_PROVIDER Soft preference for calls that omit provider; must be configured (an unconfigured default is a startup error). Tools that provider cannot serve are hidden from the client, except web_search/web_crawl/web_extract (kept visible when an enabled Scrappey can emulate them; pass force: true to execute). An explicit per-call provider pins and never fails over.
ENABLED_TOOLS Explicit tool allow-list, e.g. web_fetch,web_browser_actions,web_screenshot. Overrides the set derived from DEFAULT_PROVIDER. Unset = all; literal none = none.
DISABLED_PROVIDERS Comma list of providers switched off even though they have keys (keys are kept).
DISABLED_FEATURES JSON {"provider": ["capability"]} — features (capabilities) pruned off a provider, e.g. {"scrappey": ["screenshot"]}.
PROVIDER_PRIORITY Selection order for auto-picked providers (default: recommended stack order).
TOOL_PRIORITY JSON {"capability": ["provider", ...]} — per-feature provider order tried first for that feature only; global order covers the rest (keys: search, fetch, crawl, extract, browser_actions, screenshot, session).
HTTP_TIMEOUT HTTP timeout in seconds for provider API calls (default 60, connect 15). Raise for long Scrappey browser sequences.
OPENROUTER_API_KEY / HF_TOKEN LLM key for the emulated web_extract (fetch + LLM summary). Read from the process env first (a harness can inject them via its mcp.json env block) or from .env.
EXTRACT_MODEL Model for the emulated extract call (defaults: OpenRouter deepseek/deepseek-v4-flash-0731, HuggingFace deepseek-ai/DeepSeek-V4-Flash-0731).
EXTRACT_JSON_MODEL Model for the schema-driven emulated extract (web_extract with a schema; defaults: OpenRouter scaledown/extract, HuggingFace deepseek-ai/DeepSeek-V4-Flash-0731).
EXTRACT_MAX_CHARS Page text cap (chars) sent to the LLM per emulated extract (default 100000; invalid/non-positive values fail at startup).
CACHE_TTL TTL in seconds for cached web_fetch results (default 0 = off). Repeated identical fetches are served from the router cache instead of billing the provider.
LOG_LEVEL Log verbosity: DEBUG, INFO (default), WARNING, ERROR, CRITICAL. INFO logs which provider served each call; DEBUG adds cache hits.

There is also a screen-based configuration CLI. The launcher installs dependencies if needed and starts it: ./scripts/config.sh (or run python scripts/config_cli.py with a venv that has the package installed). Run without arguments for the interactive menu; subcommands for scripting: list, set-key, clear-key, enable/disable, enable-feature/ disable-feature, enable-tool/disable-tool, set-priority, set-tool-priority, set-default. It edits only the keys you change and never prints secrets. See mcp-server/README.md for the full command list.

How it works

The server is a small router over provider adapters (mcp-server/src/scrape_n_search/). Each tool call is translated into the active provider's API request and the response is normalised into a shared model (SearchResult, FetchedPage, CrawlPage), so results look identical whichever provider served them. If the active provider errors, the router fails over to the next available one. The server itself speaks MCP over stdio — no database, no HTTP endpoint, one process (plus an optional in-memory fetch cache when CACHE_TTL is set).

Development

.venv/bin/python -m pytest mcp-server/tests -q

# branch coverage (100% enforced by [tool.coverage] in mcp-server/pyproject.toml)
.venv/bin/python -m coverage run -m pytest mcp-server/tests -q
.venv/bin/python -m coverage report -m

# lint, types, shell
.venv/bin/ruff check --config mcp-server/pyproject.toml mcp-server/src mcp-server/tests scripts
(cd mcp-server && ../.venv/bin/mypy)
shellcheck install.sh setup.sh

Tests cover per-provider response normalisation against the documented API shapes, router selection/pinning/failover/TTL-cache/single-flight behaviour, argument validation, configuration (timeouts, cache, logging, redaction), the emulated search/crawl/extract paths (Bing SERP parsing including truncated/nested markup, crawl BFS invariants and partial failures, HTML-to-text stripping), the provider scripts (install_mcp.py, check_keys.py), and the MCP surface end-to-end — both over an in-memory transport and over a real stdio subprocess. Shape-invalid provider responses are asserted to raise ProviderError and fail over rather than crash the call. To add a provider, subclass BaseProvider (mcp-server/src/scrape_n_search/providers/base.py), declare fetch_formats, register it in build_providers, and add a normalisation test.

Releases & packaging

Status: MIT-licensed; CI (pytest on push/PR) and an automated release workflow run from GitHub (ci.yml, release.yml). Published on PyPI as scrape-n-search-mcp (trusted publishing, no tokens). Releases: v0.1.0 → v0.1.1 (first PyPI release) → v0.2.0 (audit-driven correctness pass; current). Distribution channels: PyPI (uvx scrape-n-search-mcp), the one-line setup (GitHub source), or a git checkout.

Release flow (fully automated from a tag):

git tag v0.2.0 && git push origin v0.2.0

The release workflow then: runs the tests, builds sdist + wheel, creates a GitHub Release with auto-generated notes and attaches the artifacts, and publishes to PyPI via trusted publishing (OIDC — no token). Verify after each release on a clean machine: uvx scrape-n-search-mcp (or pipx run scrape-n-search-mcp), then register it with your MCP client. The one-line installer pins releases with curl -fsSL <url> | bash -s -- --ref v0.2.0.

How MCP servers are usually distributed: JavaScript servers ship via npm and are run with npx -y <pkg> (e.g. npx -y firecrawl-mcp); Python servers via PyPI under uvx <pkg> / pipx run; heavy or bundled ones as Docker images; everything else as git clone + install script. The client config only needs a command/args line, so any of these work — npx/uvx are dominant because they need no pre-install steps.

License

MIT — see LICENSE.

The MCP collection

Part of a small set of stdio MCP servers for agent harnesses:

Server What it gives an agent
look-n-see Vision Q&A, screenshot reading, and OCR.
store-n-recall Persistent project memory in one SQLite file.
listen-n-speak STT, TTS, and a human-in-the-loop voice dialog.
weigh-n-decide Decision models and local condition evaluation.
gate-n-guard Deterministic allow/confirm/deny policy gating.