How mrkrsl/web-search-mcp works
Purpose and Entry Point
This is a Node.js/TypeScript stdio MCP server for local LLM clients. It exposes web-search and page-extraction tools without search API keys, combining browser automation and direct HTTP. src/index.ts initializes the MCP server, registers tools, validates inputs, and formats tool responses. The distributable entry is built from this source via scripts/bundle.js.
MCP Tool Orchestration
Three tool paths share the same services:
• full-web-search: search, then concurrently fetch/extract result pages.
• get-web-search-summaries: search only, returning result metadata/snippets.
• get-single-web-page-content: extract a specified URL directly.
The orchestration boundary is src/index.ts; shared result/request contracts are in src/types.ts.
Multi-Engine Search Pipeline
src/search-engine.ts implements engine selection, parsing, fallback, and optional relevance validation. Search prioritizes browser-driven Bing, then browser-driven Brave, then HTTP-based DuckDuckGo. It may evaluate multiple engines when configured, while normal operation stops after a satisfactory result set. External dependencies are Bing, Brave Search, and DuckDuckGo HTML endpoints; no authenticated search provider is required.
Browser Lifecycle and Isolation
src/browser-pool.ts owns Playwright browser provisioning, reuse/limits, per-engine isolation, and cleanup. Chromium and Firefox are material runtime dependencies, installed separately through Playwright. Browser pool behavior is controlled by environment settings such as maximum browser count, allowed browser types, headless mode, and browser-fallback threshold. This separates expensive, stateful automation from search and extraction policy.
Content Retrieval and Extraction
src/content-extractor.ts is the primary page-fetch/extract path, favoring Axios-based HTTP for speed and falling back to browser navigation after repeated failures or inaccessible pages. It handles timeout and protocol recovery, including HTTP/2-to-HTTP/1.1 fallback behavior. src/enhanced-content-extractor.ts provides the higher-level extraction path used to obtain cleaned main-page content, stripping navigation, ads, and other peripheral material.
Concurrency, Throttling, and Reliability
For full searches, page extraction is parallelized with timeout protection; one failed URL should not prevent other results from being returned. src/rate-limiter.ts constrains outbound activity, while src/utils.ts centralizes cross-cutting normalization and operational helpers. Environment-configured defaults govern request timeout, maximum extracted length, engine quality threshold, and whether all engines are queried.
Data Boundary and Deployment
src/types.ts defines the boundary between raw engine/page responses and structured MCP tool output: search result metadata, extracted content, and errors are normalized before returning to the client. The server runs under Node.js 18+ and communicates through MCP stdio, typically launched as compiled dist/index.js from an MCP client configuration (mcp.json). It depends on unrestricted outbound web access plus locally installed Playwright browser binaries.
Main entry points: search-engine.ts Search pipeline · index.ts MCP tool server · content-extractor.ts Content fetcher · browser-pool.ts Browser pool
Components 18
MCP Server
Node.js stdio tool boundary.
- Local LLM client
- Bundle build · Builds the distributable server entry.
scripts/bundle.js - MCP tool server · Registers tools, validates inputs, and formats responses.
src/index.ts - Result contracts · Normalizes search, content, and error boundaries.
src/types.ts - full-web-search · Searches then concurrently extracts result pages.
src/index.ts - get-web-search-summaries · Returns search metadata and snippets only.
src/index.ts - get-single-web-page-content · Extracts content for one URL.
src/index.ts
Search & Extraction
Shared retrieval services.
- Search pipeline · Parses engines and optionally validates relevance.
src/search-engine.ts - Browser pool · Provides isolated, bounded browser automation.
src/browser-pool.ts - Content fetcher · Uses Axios first, then browser recovery.
src/content-extractor.ts - Content extractor · Cleans page content and removes peripheral material.
src/enhanced-content-extractor.ts - Rate limiter
src/rate-limiter.ts - Operational utilities · Normalization and reliability helpers.
src/utils.ts
External Runtime
Search endpoints and browser runtime.
- Bing
- Brave Search
- DuckDuckGo HTML
- Target web pages
- Chromium / Firefox · Locally installed browser binaries.
Connections 22
- Local LLM client → MCP tool server: stdio MCP
- Bundle build → MCP tool server: builds
- MCP tool server → full-web-search: exposes
- MCP tool server → get-web-search-summaries: exposes
- MCP tool server → get-single-web-page-content: exposes
- MCP tool server → Result contracts: formats
- full-web-search → Search pipeline: searches
- full-web-search → Content extractor: parallel extraction
- get-web-search-summaries → Search pipeline: searches
- get-single-web-page-content → Content extractor: extracts
- Search pipeline → Browser pool: browser engines
- Search pipeline → Bing: primary
- Search pipeline → Brave Search: fallback
- Search pipeline → DuckDuckGo HTML: HTTP fallback
- Content extractor → Content fetcher: retrieves
- Content fetcher → Browser pool: recovery fallback
- Content fetcher → Target web pages: HTTP fetch
- Browser pool → Chromium / Firefox: provisions
- Rate limiter → Search pipeline: constrains
- Rate limiter → Content fetcher: constrains
- Operational utilities → Search pipeline: supports
- Operational utilities → Content fetcher: supports