markdownify
Convert any webpage into clean, formatted markdown with automatic extraction. Simplifies web content transformation for easy integration into markdown-based workflows.
Instructions
Convert a webpage into clean, formatted markdown.
Args:
website_url: URL of the webpage to convert
Returns:
Dictionary containing the markdown result
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| website_url | Yes |
Implementation Reference
- src/scrapegraph_mcp/server.py:1365-1406 (handler)MCP handler function for the 'markdownify' tool. It retrieves the API key from context, creates a ScapeGraphClient instance, calls its markdownify method with the provided website_url, and returns the result or an error dictionary.@mcp.tool(annotations={"readOnlyHint": True, "destructiveHint": False, "idempotentHint": True}) def markdownify(website_url: str, ctx: Context) -> Dict[str, Any]: """ Convert a webpage into clean, formatted markdown. This tool fetches any webpage and converts its content into clean, readable markdown format. Useful for extracting content from documentation, articles, and web pages for further processing. Costs 2 credits per page. Read-only operation with no side effects. Args: website_url (str): The complete URL of the webpage to convert to markdown format. - Must include protocol (http:// or https://) - Supports most web content types (HTML, articles, documentation) - Works with both static and dynamic content - Examples: * https://example.com/page * https://docs.python.org/3/tutorial/ * https://github.com/user/repo/README.md - Invalid examples: * example.com (missing protocol) * ftp://example.com (unsupported protocol) * localhost:3000 (missing protocol) Returns: Dictionary containing: - markdown: The converted markdown content as a string - metadata: Additional information about the conversion (title, description, etc.) - status: Success/error status of the operation - credits_used: Number of credits consumed (always 2 for this operation) Raises: ValueError: If website_url is malformed or missing protocol HTTPError: If the webpage cannot be accessed or returns an error TimeoutError: If the webpage takes too long to load (>120 seconds) """ try: api_key = get_api_key(ctx) client = ScapeGraphClient(api_key) return client.markdownify(website_url) except Exception as e: return {"error": str(e)}
- src/scrapegraph_mcp/server.py:93-115 (helper)Core helper method in ScapeGraphClient class that implements the markdownify logic by making an HTTP POST request to the ScrapeGraph API endpoint '/markdownify' with the website_url, handling the response, and raising exceptions on errors.def markdownify(self, website_url: str) -> Dict[str, Any]: """ Convert a webpage into clean, formatted markdown. Args: website_url: URL of the webpage to convert Returns: Dictionary containing the markdown result """ url = f"{self.BASE_URL}/markdownify" data = { "website_url": website_url } response = self.client.post(url, headers=self.headers, json=data) if response.status_code != 200: error_msg = f"Error {response.status_code}: {response.text}" raise Exception(error_msg) return response.json()
- src/scrapegraph_mcp/server.py:1365-1365 (registration)The @mcp.tool decorator registers the markdownify function as an MCP tool with annotations indicating it's read-only, non-destructive, and idempotent.@mcp.tool(annotations={"readOnlyHint": True, "destructiveHint": False, "idempotentHint": True})