mcp_fetch
Fetch website content directly by providing a URL, enabling quick access to web data for integration or analysis within Cursor IDE. Simplify web content retrieval with this MCP server tool.
Instructions
Fetches a website and returns its content
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to fetch |
Implementation Reference
- mcp_simple_tool/server.py:8-39 (handler)Core implementation of the mcp_fetch tool: fetches website content from the given URL using httpx, handles timeouts, HTTP errors, and other exceptions, returning 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_simple_tool/server.py:72-78 (handler)Dispatch logic in the call_tool handler: checks for mcp_fetch 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_simple_tool/server.py:99-107 (schema)Input schema definition for mcp_fetch: requires a 'url' string property."type": "object", "required": ["url"], "properties": { "url": { "type": "string", "description": "URL to fetch", } }, },
- mcp_simple_tool/server.py:96-108 (registration)Tool registration in list_tools(): defines name, description, and schema for mcp_fetch.name="mcp_fetch", description="Fetches a website and returns its content", inputSchema={ "type": "object", "required": ["url"], "properties": { "url": { "type": "string", "description": "URL to fetch", } }, }, ),
- mcp_simple_tool/server.py:68-69 (registration)Registration of the tool handler via @app.call_tool() decorator on fetch_tool function that dispatches mcp_fetch.@app.call_tool() async def fetch_tool( # type: ignore[unused-function]