Skip to main content
Glama
chrisboden

MCP Server Template for Cursor IDE

by chrisboden

mcp_fetch

Fetch website content directly within Cursor IDE to access and analyze web data for development workflows.

Instructions

Fetches a website and returns its content

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to fetch

Implementation Reference

  • Core handler function that implements the logic for the 'mcp_fetch' tool: fetches website content using httpx, follows redirects, handles timeouts, HTTP errors, and other exceptions, returning formatted TextContent.
    async def fetch_website(
        url: str,
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        headers = {
            "User-Agent": "MCP Test Server (github.com/modelcontextprotocol/python-sdk)"
        }
        try:
            timeout = httpx.Timeout(10.0, connect=5.0)
            async with httpx.AsyncClient(
                follow_redirects=True, 
                headers=headers,
                timeout=timeout
            ) as client:
                response = await client.get(url)
                response.raise_for_status()
                return [types.TextContent(type="text", text=response.text)]
        except httpx.TimeoutException:
            return [types.TextContent(
                type="text",
                text="Error: Request timed out while trying to fetch the website."
            )]
        except httpx.HTTPStatusError as e:
            return [types.TextContent(
                type="text",
                text=(f"Error: HTTP {e.response.status_code} "
                      "error while fetching the website.")
            )]
        except Exception as e:
            return [types.TextContent(
                type="text",
                text=f"Error: Failed to fetch website: {str(e)}"
            )]
  • Registration of the 'mcp_fetch' tool in the list_tools() function, including name, description, and input schema.
    types.Tool(
        name="mcp_fetch",
        description="Fetches a website and returns its content",
        inputSchema={
            "type": "object",
            "required": ["url"],
            "properties": {
                "url": {
                    "type": "string",
                    "description": "URL to fetch",
                }
            },
        },
    ),
  • Input schema definition for the 'mcp_fetch' tool, specifying an object with a required 'url' string property.
    inputSchema={
        "type": "object",
        "required": ["url"],
        "properties": {
            "url": {
                "type": "string",
                "description": "URL to fetch",
            }
        },
    },
  • Dispatch logic within the general call_tool handler that routes 'mcp_fetch' calls to the fetch_website function after validating the 'url' argument.
    if name == "mcp_fetch":
        if "url" not in arguments:
            return [types.TextContent(
                type="text",
                text="Error: Missing required argument 'url'"
            )]
        return await fetch_website(arguments["url"])
  • The @app.call_tool()-decorated handler function that implements dispatching for all tools, including 'mcp_fetch'.
    @app.call_tool()
    async def fetch_tool( # type: ignore[unused-function]
        name: str, arguments: dict
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        if name == "mcp_fetch":
            if "url" not in arguments:
                return [types.TextContent(
                    type="text",
                    text="Error: Missing required argument 'url'"
                )]
            return await fetch_website(arguments["url"])
        elif name == "mood":
            if "question" not in arguments:
                return [types.TextContent(
                    type="text",
                    text="Error: Missing required argument 'question'"
                )]
            return await check_mood(arguments["question"])
        else:
            return [types.TextContent(
                type="text",
                text=f"Error: Unknown tool: {name}"
            )]

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool fetches and returns content, but lacks details on error handling, rate limits, authentication needs, or response format. For a tool with no annotations, this is a significant gap in transparency about its operational behavior.

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

Conciseness5/5

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

The description is extremely concise and front-loaded, consisting of a single, clear sentence: 'Fetches a website and returns its content'. Every word earns its place, with no redundant or unnecessary information, making it efficient and easy to parse.

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

Completeness2/5

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

Given the tool's complexity (a fetch operation with potential behavioral nuances), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what 'content' includes (e.g., HTML, text), error cases, or limitations, leaving gaps in understanding how the tool behaves in practice.

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?

The schema description coverage is 100%, with the parameter 'url' fully documented in the schema. The description adds no additional meaning beyond the schema, such as URL format constraints or examples. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't enhance parameter understanding.

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 action ('fetches') and resource ('a website'), specifying what the tool does. It distinguishes from most siblings (e.g., 'apply_prompt_' tools, 'mood') by focusing on web content retrieval, though it doesn't explicitly differentiate from 'fetch_railway_docs' tools. The purpose is specific but lacks sibling comparison.

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 no guidance on when to use this tool versus alternatives. It doesn't mention scenarios for usage, prerequisites, or exclusions, and offers no comparison to sibling tools like 'fetch_railway_docs' or 'fetch_railway_docs_optimized'. Usage is implied only by the action 'fetches', with no explicit context.

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

Deploy Server

Other Tools