MCP HTTP Fetcher Server
A Model Context Protocol (MCP) server that fetches web pages and converts them to Markdown format. This server supports both SSE (Server-Sent Events) and Stdio protocols, making it suitable for web deployments, Kubernetes environments, desktop clients, and sidecar patterns.
Features
✅ Dual Protocol Support: SSE (default) and Stdio protocols
✅ HTTP/HTTPS URL fetching: Download content from any web URL
✅ HTML to Markdown conversion: Clean conversion using html2text
✅ MCP Protocol compliance: Follows MCP server standards
✅ Kubernetes ready: SSE protocol with health checks and graceful scaling
✅ Sidecar friendly: Stdio protocol for process-to-process communication
✅ Error handling: Robust error handling for network issues
✅ Docker support: Ready-to-run Docker container
✅ Async operation: Non-blocking HTTP requests
✅ Modular architecture: Clean separation of concerns for maintainability
Quick Start
SSE Protocol (Default - Web/Kubernetes Deployments)
Stdio Protocol (Desktop Clients/Sidecars)
Protocol Overview
Protocol | Use Case | Deployment | Scaling |
SSE (Default) | Web apps, APIs, Kubernetes | HTTP server with endpoints | Horizontal scaling, load balancing |
Stdio | Desktop clients, sidecars | Process communication | Single client per process |
For detailed protocol documentation, see docs/PROTOCOLS.md.
Project Structure
The project follows Python best practices with a clean, modular architecture:
Entry Points
python app/server.py- Primary entry point with full protocol supportpython server.py- Legacy entry point (limited protocol options)./run_server.sh- Convenience script with dependency management
Installation
Option 1: Direct Python Installation
Clone the repository:
Install dependencies:
Run the server:
Option 2: Docker Installation
Build the Docker image:
Run the container:
Note: Docker build may require internet access to install Python packages. In restricted environments, use the direct Python installation method.
Usage
The server exposes a single MCP tool called fetch_url that accepts a URL parameter and returns the page content converted to Markdown.
MCP Client Configuration
For SSE Protocol (Web/Kubernetes deployments)
For Stdio Protocol (Desktop clients)
Command Line Options
Available options:
--protocol {stdio,sse}- Communication protocol (default: sse)--host HOST- Host to bind SSE server (default: localhost)--port PORT- Port for SSE server (default: 8000)--endpoint ENDPOINT- SSE message endpoint (default: /messages)--server-name NAME- Server identifier--server-version VERSION- Server version
Tool Schema
Example Usage
When connected to an MCP client, you can use the tool like this:
The server will return the page content converted to Markdown format.
Testing
Run the included test scripts to verify functionality:
Testing the MCP Server
The server communicates via stdin/stdout using the MCP protocol. For basic testing:
Start the server:
python server.py(orpython app/server.py)The server will wait for MCP protocol messages on stdin
Send a list_tools request to see available tools
Send a call_tool request with the fetch_url tool
For easier testing, use an MCP client like Claude Desktop or develop a simple test client.
Configuration
The server includes the following configurable aspects:
Timeout: 30-second timeout for HTTP requests
Content types: Accepts HTML and XML content types
Markdown conversion: Preserves links and images in output
Error Handling
The server handles various error conditions:
Invalid URLs
Network connectivity issues
HTTP error responses (4xx, 5xx)
Content parsing errors
Timeout conditions
Security Considerations
The server validates URLs before processing
Runs in a non-root Docker container
Has reasonable timeout limits to prevent hanging
Does not execute or process JavaScript content
Dependencies
mcp>=1.0.0- Model Context Protocol server frameworkaiohttp>=3.9.0- Async HTTP client for fetching URLshtml2text>=2020.1.16- HTML to Markdown conversiontyping-extensions>=4.0.0- Type hints support
License
Licensed under the Apache License, Version 2.0. See the LICENSE file for details.