MCP HubMCP Hub
modelcontextprotocol

fetch

by: modelcontextprotocol

A Model Context Protocol server that provides web content fetching capabilities. This server enables LLMs to retrieve and process content from web pages, converting HTML to markdown for easier consumption.

0created 19/11/2024
Visit
LLM
web

📌Overview

Purpose: To provide web content fetching capabilities for Large Language Models (LLMs) by enabling retrieval and processing of web pages.

Overview: The Fetch MCP Server is designed to facilitate the extraction and conversion of web page content into markdown format, making it more accessible for LLMs. It allows users to specify content extraction parameters, such as starting index and maximum length, enabling efficient retrieval of information from web pages.

Key Features:

  • Content Fetching: The fetch tool retrieves content from specified URLs and converts it to markdown, allowing easy consumption by LLMs.

  • Flexible Parameters: Users can customize the fetching process with options like max_length for character limits and start_index for controlling content extraction points, optimizing information retrieval.


Fetch MCP Server

A Model Context Protocol server that provides web content fetching capabilities. This server enables LLMs to retrieve and process content from web pages, converting HTML to markdown for easier consumption.

The fetch tool truncates the response, but by using the start_index argument, you can specify where to start the content extraction. This allows models to read a webpage in chunks until they find the information they need.

Available Tools

  • fetch - Fetches a URL from the internet and extracts its contents as markdown.
    • url (string, required): URL to fetch
    • max_length (integer, optional): Maximum number of characters to return (default: 5000)
    • start_index (integer, optional): Start content from this character index (default: 0)
    • raw (boolean, optional): Get raw content without markdown conversion (default: false)

Prompts

  • fetch
    • Fetch a URL and extract its contents as markdown
    • Arguments:
      • url (string, required): URL to fetch

Installation

Optionally, install node.js to use a more robust HTML simplifier with the fetch server.

Using uv (recommended)

When using uv, no specific installation is needed. We use uvx to directly run mcp-server-fetch.

Using PIP

Alternatively, you can install mcp-server-fetch via pip:

pip install mcp-server-fetch

After installation, run it as a script using:

python -m mcp_server_fetch

Configuration

Configure for Claude.app

Add to your Claude settings:

Using uvx
"mcpServers": {
  "fetch": {
    "command": "uvx",
    "args": ["mcp-server-fetch"]
  }
}
Using docker
"mcpServers": {
  "fetch": {
    "command": "docker",
    "args": ["run", "-i", "--rm", "mcp/fetch"]
  }
}
Using pip installation
"mcpServers": {
  "fetch": {
    "command": "python",
    "args": ["-m", "mcp_server_fetch"]
  }
}

Customization - robots.txt

By default, the server obeys a website’s robots.txt file if the request came from the model (via a tool), but not if the request was user-initiated (via a prompt). This can be disabled by adding the argument --ignore-robots-txt to the args list in the configuration.

Customization - User-agent

The server uses one of two user-agent strings by default, depending on request origin:

  • For model requests:
    ModelContextProtocol/1.0 (Autonomous; +https://github.com/modelcontextprotocol/servers)
    
  • For user-initiated requests:
    ModelContextProtocol/1.0 (User-Specified; +https://github.com/modelcontextprotocol/servers)
    

This can be customized by adding the argument --user-agent=YourUserAgent to the args list in the configuration.

Customization - Proxy

Configure the server to use a proxy by using the --proxy-url argument.

Debugging

Use the MCP inspector to debug the server.

For uvx installations:

npx @modelcontextprotocol/inspector uvx mcp-server-fetch

Or, if developing locally:

cd path/to/servers/src/fetch
npx @modelcontextprotocol/inspector uv run mcp-server-fetch

Contributing

Contributions to expand and improve mcp-server-fetch are welcome. Whether adding new tools, enhancing existing functionality, or improving documentation, your input is valuable.

For examples of other MCP servers and implementation patterns, see:
https://github.com/modelcontextprotocol/servers

Pull requests are encouraged to improve mcp-server-fetch.

License

mcp-server-fetch is licensed under the MIT License. You are free to use, modify, and distribute the software under the terms of this license. See the LICENSE file in the project repository for details.