mcp-web

geehexx/mcp-web

3.2

If you are the rightful owner of mcp-web and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

MCP-Web is a server designed to facilitate various web operations using the Model Context Protocol.

mcp-web

MCP Server for Intelligent Web Summarization

A powerful Model Context Protocol (MCP) server that provides intelligent URL summarization with content extraction, smart chunking, and LLM-based summarization.

Features

  • ๐Ÿš€ Fast & Robust Fetching: httpx primary with Playwright fallback for JS-heavy sites
  • ๐ŸŽฏ Intelligent Content Extraction: trafilatura-powered main content extraction
  • ๐Ÿ“Š Smart Chunking: Hierarchical and semantic text splitting with configurable overlap
  • ๐Ÿค– LLM Summarization: Map-reduce strategy for long documents with streaming output
  • ๐Ÿ  Local LLM Support: Ollama, LM Studio, LocalAI, or cloud providers (OpenAI, Anthropic)
  • ๐Ÿ’พ Persistent Caching: Disk-based cache with TTL and LRU eviction
  • ๐Ÿ“ˆ Metrics & Logging: Comprehensive observability with structured logging
  • ๐Ÿ”— Link Following: Optional recursive link following for deeper context
  • ๐Ÿ“ Markdown Output: Well-formatted summaries with citations and metadata
  • ๐Ÿงช Comprehensive Testing: Unit, integration, security, golden, and benchmark tests

Quick Start

Installation

# Clone the repository
git clone https://github.com/geehexx/mcp-web.git
cd mcp-web

# Install Taskfile (recommended)
# macOS: brew install go-task/tap/go-task
# Linux: snap install task --classic
# Or see: https://taskfile.dev/installation/

# Setup complete environment (recommended)
task dev:setup

# Or manual installation
pip install -e ".[dev]"
playwright install chromium
```bash

### Configuration

#### Cloud LLM (OpenAI)

```bash
export OPENAI_API_KEY="sk-..."
export MCP_WEB_SUMMARIZER_PROVIDER=openai
export MCP_WEB_SUMMARIZER_MODEL=gpt-4o-mini
Local LLM (Ollama - Recommended)
# Install Ollama: https://ollama.com
# Start: ollama serve
# Pull model: ollama pull llama3.2:3b

export MCP_WEB_SUMMARIZER_PROVIDER=ollama
export MCP_WEB_SUMMARIZER_MODEL=llama3.2:3b

# Or use task commands
task llm:ollama:pull # Pull recommended models
task llm:ollama:start # Start Ollama server

See for complete local LLM setup.

Other Settings
# Cache settings
export MCP_WEB_CACHE_DIR="~/.cache/mcp-web"
export MCP_WEB_CACHE_TTL=604800 # 7 days

# Fetcher settings
export MCP_WEB_FETCHER_TIMEOUT=30
export MCP_WEB_FETCHER_MAX_CONCURRENT=5

# Summarizer settings
export MCP_WEB_SUMMARIZER_TEMPERATURE=0.3
export MCP_WEB_SUMMARIZER_MAX_TOKENS=2048

Usage

As an MCP Server

Add to your MCP client configuration (e.g., Claude Desktop):

{
 "mcpServers": {
 "mcp-web": {
 "command": "python",
 "args": ["-m", "mcp_web.mcp_server"]
 }
 }
}
Programmatic Usage
from mcp_web import create_server, load_config

# Create server
config = load_config()
mcp = create_server(config)

# Use the pipeline directly
from mcp_web.mcp_server import WebSummarizationPipeline

pipeline = WebSummarizationPipeline(config)

# Summarize URLs
async for chunk in pipeline.summarize_urls(
 urls=["https://example.com"],
 query="What are the key features?",
):
 print(chunk, end="")

Tools

summarize_urls

Summarize content from one or more URLs with optional query focus.

Parameters:

  • urls (List[str], required): URLs to summarize
  • query (str, optional): Question or topic to focus the summary on
  • follow_links (bool, default=False): Follow relevant outbound links
  • max_depth (int, default=1): Maximum link following depth

Example:

result = await summarize_urls(
 urls=["https://docs.python.org/3/library/asyncio.html"],
 query="How do I create async tasks?",
 follow_links=True
)

get_cache_stats

Get cache and metrics statistics.

Returns: Dictionary with cache size, hit rates, and processing metrics

clear_cache

Clear the entire cache.

prune_cache

Remove expired cache entries.

Architecture

Pipeline Flow

URLs โ†’ Fetch (httpx/Playwright) โ†’ Extract (trafilatura) โ†’
Chunk (hierarchical/semantic) โ†’ Summarize (LLM map-reduce) โ†’
Markdown Output (streaming)

Key Design Decisions

  1. DD-001: httpx primary, Playwright fallback for robustness
  2. DD-002: Trafilatura with favor_recall=True for maximum content extraction
  3. DD-003: Hierarchical + semantic chunking preserves document structure
  4. DD-004: 512-token chunks with 50-token overlap balances context
  5. DD-006: Map-reduce summarization handles arbitrarily long documents
  6. DD-007: 7-day disk cache with LRU eviction
  7. DD-008: OpenAI GPT-4o-mini default (configurable)
  8. DD-009: Streaming output for better UX

See for full design documentation.

Project Structure

mcp-web/
โ”œโ”€โ”€ src/mcp_web/
โ”‚ โ”œโ”€โ”€ mcp_server.py # MCP tool entry point & orchestration
โ”‚ โ”œโ”€โ”€ fetcher.py # URL fetching (httpx + Playwright)
โ”‚ โ”œโ”€โ”€ extractor.py # Content extraction (trafilatura)
โ”‚ โ”œโ”€โ”€ chunker.py # Text chunking strategies
โ”‚ โ”œโ”€โ”€ summarizer.py # LLM summarization (map-reduce)
โ”‚ โ”œโ”€โ”€ cache.py # Disk cache manager
โ”‚ โ”œโ”€โ”€ metrics.py # Logging & metrics collection
โ”‚ โ”œโ”€โ”€ config.py # Configuration management
โ”‚ โ””โ”€โ”€ utils.py # Token counting, formatting
โ”œโ”€โ”€ tests/ # Unit & integration tests
โ”œโ”€โ”€ docs/ # Architecture & API documentation
โ”œโ”€โ”€ examples/ # Example usage scripts
โ””โ”€โ”€ pyproject.toml # Dependencies & project metadata

Development

Using Taskfile (Recommended)

# Show all available tasks
task --list

# Complete setup
task dev:setup

# Run tests
task test # All tests except live
task test:fast # Unit + security + golden
task test:coverage # With coverage report
task test:parallel # Parallel execution

# Code quality
task lint # All linting
task format # Auto-format code
task security # Security scans
task analyze # Complete analysis

# CI simulation
task ci # Full CI pipeline
task ci:fast # Quick check

See for complete task reference.

Running Tests

# With Taskfile
task test # Recommended
task test:unit
task test:security
task test:golden # With local/cloud LLM

# Or with pytest directly
pytest -m "not live"
pytest -m unit
pytest -m golden

Code Quality

# With Taskfile (recommended)
task lint
task format
task security

# Or directly
ruff check src/ tests/
ruff format src/ tests/
mypy src/
bandit -r src/

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes with tests
  4. Run linting and tests
  5. Commit your changes (git commit -m 'Add amazing feature')
  6. Push to the branch (git push origin feature/amazing-feature)
  7. Open a Pull Request

Configuration Reference

See for complete configuration options.

Key Settings

SettingDefaultDescription
FETCHER_TIMEOUT30HTTP request timeout (seconds)
FETCHER_MAX_CONCURRENT5Max parallel fetches
CHUNKER_CHUNK_SIZE512Target tokens per chunk
CHUNKER_OVERLAP50Overlap between chunks (tokens)
SUMMARIZER_MODELgpt-4o-miniLLM model to use
SUMMARIZER_TEMPERATURE0.3LLM temperature
CACHE_TTL604800Cache TTL (7 days)
CACHE_MAX_SIZE1GBMaximum cache size

Performance

Benchmarks

  • Single URL: ~5-10 seconds (with cache)
  • Multiple URLs (5): ~15-30 seconds (parallel fetching)
  • Large document (10k+ tokens): ~30-60 seconds (map-reduce)

Optimization Tips

  1. Enable caching for repeated queries
  2. Adjust chunk_size based on content type
  3. Use gpt-4o-mini for cost-effective summaries
  4. Limit max_depth for link following
  5. Prune cache periodically

Troubleshooting

Common Issues

"No module named 'playwright'"

  • Run pip install playwright && playwright install chromium

"OPENAI_API_KEY not set"

  • Export your API key: export OPENAI_API_KEY="sk-..."

"Cache permission denied"

  • Check ~/.cache/mcp-web permissions or set custom CACHE_DIR

"Extraction returned empty content"

  • Site might be JS-heavy; fetcher will auto-fallback to Playwright
  • Some sites block scrapers; check robots.txt

Debug Mode

Enable debug logging:

export MCP_WEB_METRICS_LOG_LEVEL="DEBUG"
python -m mcp_web.mcp_server

Roadmap

v0.2.0 (Current)

  • Local LLM support (Ollama, LM Studio, LocalAI)
  • Comprehensive testing infrastructure
  • Security testing (OWASP LLM Top 10)
  • Taskfile for better tooling
  • Golden tests with deterministic verification

v0.3.0

  • PDF OCR support for scanned documents
  • Multi-language translation
  • Anthropic Claude integration
  • Vector embeddings for semantic search

v0.4.0

  • Per-domain extraction rules
  • Image/diagram extraction
  • Incremental summarization
  • Prometheus metrics export

See for full roadmap.

License

MIT License - see file for details.

Acknowledgments

Support