Skip to main content
Glama
aelaguiz

URL Fetch MCP

by aelaguiz

fetch_url

Retrieve web content from any URL and convert it into text format. Ideal for accessing HTML, plain text, and other text-based resources directly for processing or analysis.

Instructions

Fetch content from a URL and return it as text.

This tool allows Claude to retrieve content from any accessible web URL. The content is returned as text, making it suitable for HTML, plain text, and other text-based content types.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
headersNoAdditional headers to send with the request
timeoutNoRequest timeout in seconds
urlYesThe URL to fetch

Implementation Reference

  • The core handler function for the 'fetch_url' tool. It performs an HTTP GET request using httpx, handles errors, logs via context, and returns the response text. The @app.tool() decorator registers it with the FastMCP server. Input schema is defined inline via Annotated types and Field descriptions.
    @app.tool() async def fetch_url( url: Annotated[AnyUrl, Field(description="The URL to fetch")], headers: Annotated[ Optional[Dict[str, str]], Field(description="Additional headers to send with the request") ] = None, timeout: Annotated[int, Field(description="Request timeout in seconds")] = 10, ctx: Context = None, ) -> str: """Fetch content from a URL and return it as text. This tool allows Claude to retrieve content from any accessible web URL. The content is returned as text, making it suitable for HTML, plain text, and other text-based content types. """ if ctx: await ctx.info(f"Fetching content from URL: {url}") request_headers = { "User-Agent": "URL-Fetch-MCP/0.1.0", } if headers: request_headers.update(headers) async with httpx.AsyncClient(follow_redirects=True, timeout=timeout) as client: try: response = await client.get(str(url), headers=request_headers) response.raise_for_status() content_type = response.headers.get("content-type", "text/plain") if ctx: await ctx.info(f"Successfully fetched content ({len(response.text)} bytes, type: {content_type})") return response.text except Exception as e: error_message = f"Error fetching URL {url}: {str(e)}" if ctx: await ctx.error(error_message) return error_message
Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aelaguiz/mcp-url-fetch'

If you have feedback or need assistance with the MCP directory API, please join our Discord server