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}" )]

Other 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/chrisboden/mcp_template'

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