mcp_fetch
Retrieve website content by inputting a URL using this tool, designed for extending Cursor IDE functionality with custom server-based tools.
Instructions
Fetches a website and returns its content
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to fetch |
Implementation Reference
- mcp_hitchcode/server.py:19-55 (handler)Core handler function that fetches the website content asynchronously using httpx, handles various errors (timeout, HTTP, general), and returns 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)}" ) ]
- mcp_hitchcode/server.py:417-424 (handler)Dispatch logic in the @app.call_tool() handler: checks for mcp_fetch tool name, validates 'url' argument, and invokes fetch_website.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"])
- mcp_hitchcode/server.py:564-573 (schema)Input schema definition for mcp_fetch: requires 'url' as string.inputSchema={ "type": "object", "required": ["url"], "properties": { "url": { "type": "string", "description": "URL to fetch", } }, },
- mcp_hitchcode/server.py:561-574 (registration)Tool registration in @app.list_tools(): defines name, description, and inputSchema for mcp_fetch.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", } }, }, ),