read_news
Extract structured news content from CoinDesk articles, including title, author, publication date, and full text, using a provided URL. Simplifies article retrieval and parsing for quick insights.
Instructions
Retrieves and extracts the full content of a specific news article from CoinDesk.
Fetches the HTML content from the provided URL, processes it to extract
structured news information including title, subtitle, author, publication date,
and article content.
Args:
url (str): The complete URL of the CoinDesk news article to retrieve
Returns:
str: A formatted string containing the article's title, subtitle, author,
publication information, and content preview
Raises:
HTTPStatusError: If the URL request fails
Exception: If article parsing encounters errors
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes |
Implementation Reference
- src/cryptonewsmcp/server.py:32-45 (handler)The read_news tool handler: decorated with @mcp.tool() for registration, fetches article HTML using the helper function, converts it to Markdown using markdownify, and returns the Markdown content.@mcp.tool() async def read_news(url: str) -> str: """ Fetches article HTML from URL and converts it to Markdown. Args: url: Article URL to retrieve Returns: Markdown-formatted article content """ html = await fetch_text_from_url(url) markdown = md(html, strip=["a", "img"]) return markdown
- src/cryptonewsmcp/utils.py:4-24 (helper)Supporting utility function fetch_text_from_url used by read_news to asynchronously retrieve HTML content from the provided URL using httpx.async def fetch_text_from_url(url: str) -> str: """ Asynchronously retrieves text content from a specified URL. Makes an HTTP GET request to the provided URL and returns the response content as text. Handles connection setup and cleanup automatically. Args: url (str): The URL to fetch content from Returns: str: The text content received from the URL Raises: HTTPStatusError: If the HTTP request returns a non-2xx status code RequestError: If a network-related error occurs during the request """ async with httpx.AsyncClient() as client: response = await client.get(url) response.raise_for_status() return response.text