Skip to main content
Glama
aelaguiz

URL Fetch MCP

by aelaguiz

fetch_image

Retrieve images from any web URL and return them in a displayable format. Integrates with AI models to access and process images directly from the web.

Instructions

Fetch an image from a URL and return it as an image.

This tool allows Claude to retrieve images from any accessible web URL.
The image is returned in a format that Claude can display.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
timeoutNoRequest timeout in seconds
urlYesThe URL to fetch the image from

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'fetch_image' tool. It fetches the image using httpx, validates the content-type, base64-encodes the image data, and returns it in a format compatible with MCP image types.
    @app.tool()
    async def fetch_image(
        url: Annotated[AnyUrl, Field(description="The URL to fetch the image from")],
        timeout: Annotated[int, Field(description="Request timeout in seconds")] = 10,
        ctx: Context = None,
    ) -> Union[str, Dict[str, Any]]:
        """Fetch an image from a URL and return it as an image.
        
        This tool allows Claude to retrieve images from any accessible web URL.
        The image is returned in a format that Claude can display.
        """
        if ctx:
            await ctx.info(f"Fetching image from URL: {url}")
        
        request_headers = {
            "User-Agent": "URL-Fetch-MCP/0.1.0",
        }
        
        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", "")
                
                if not content_type.startswith("image/"):
                    error_message = f"URL did not return an image (content-type: {content_type})"
                    if ctx:
                        await ctx.error(error_message)
                    return error_message
                
                image_data = base64.b64encode(response.content).decode("utf-8")
                
                if ctx:
                    await ctx.info(f"Successfully fetched image ({len(response.content)} bytes, type: {content_type})")
                
                # Return image directly - FastMCP handles conversion to MCP types
                return {
                    "type": "image",
                    "data": image_data,
                    "mimeType": content_type
                }
            
            except Exception as e:
                error_message = f"Error fetching image from URL {url}: {str(e)}"
                if ctx:
                    await ctx.error(error_message)
                return error_message
  • Input schema defined via Annotated types and Field descriptions for URL (AnyUrl) and timeout (int, default 10). Output is Union[str, Dict[str, Any]] for success/error or image data.
    async def fetch_image(
        url: Annotated[AnyUrl, Field(description="The URL to fetch the image from")],
        timeout: Annotated[int, Field(description="Request timeout in seconds")] = 10,
        ctx: Context = None,
    ) -> Union[str, Dict[str, Any]]:
  • The tool is registered using the @app.tool() decorator on the FastMCP instance.
    @app.tool()
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions the tool fetches from 'any accessible web URL' and returns in a 'format that Claude can display,' but lacks details on error handling, authentication needs, rate limits, or what 'accessible' entails. For a network tool with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured with two sentences that directly address purpose and usage. It avoids redundancy and is front-loaded with the core functionality. However, the second sentence could be slightly more informative.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which handles return values) and high schema coverage, the description is minimally adequate. However, for a network-based tool with no annotations, it should provide more behavioral context like error cases or accessibility constraints to be fully complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters (url and timeout). The description adds no additional parameter semantics beyond what the schema provides, such as URL format constraints or timeout implications. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Fetch an image from a URL and return it as an image.' It specifies the verb (fetch), resource (image), and outcome (return as image). However, it doesn't explicitly differentiate from sibling tools like fetch_json and fetch_url, which likely handle different data types.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides minimal usage guidance: 'This tool allows Claude to retrieve images from any accessible web URL.' It implies use for image retrieval but offers no explicit when-to-use vs. alternatives, no prerequisites, and no mention of sibling tools for comparison.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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