recent_news
Stay updated on cryptocurrency and blockchain news by retrieving the latest articles from CoinDesk's RSS feed. Returns formatted entries with titles, links, timestamps, and summaries.
Instructions
Retrieves the latest cryptocurrency and blockchain news articles from CoinDesk's RSS feed.
Fetches the current RSS feed from CoinDesk, parses it to extract information about
recent articles, and returns a formatted list of news items including titles,
links, publication timestamps, and summary content.
Returns:
str: A formatted string containing multiple news entries separated by '---',
with each entry showing title, URL, publication time, and summary
Raises:
HTTPStatusError: If the RSS feed request fails
Exception: If RSS parsing encounters errors
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/cryptonewsmcp/server.py:48-67 (handler)The main handler function for the 'recent_news' tool. It fetches the RSS feed for the specified site (coindesk or decrypt), parses it using feedparser, and returns a formatted string of recent news entries separated by ---.@mcp.tool() async def recent_news(site: Literal["coindesk", "decrypt"]) -> str: """ Gets latest crypto news from specified site. Args: site: Site to fetch news from ("coindesk" or "decrypt") Returns: Formatted list of news entries with titles, links, dates and summaries """ url = RSS_URLS.get(site) if url is None: raise ValueError(f"Unsupported site: {site}") text = await fetch_text_from_url(url) feed = feedparser.parse(text) return "\n---\n".join( f"{entry['title']}\n{entry['link']}\n{entry['updated']}\n{entry['summary']}" for entry in feed["entries"] )
- src/cryptonewsmcp/server.py:48-48 (registration)The @mcp.tool() decorator registers the recent_news function as an MCP tool.@mcp.tool()
- src/cryptonewsmcp/server.py:10-13 (helper)Constant dictionary mapping site names to their RSS feed URLs, used by the recent_news handler.RSS_URLS = { "coindesk": "https://www.coindesk.com/arc/outboundfeeds/rss", "decrypt": "https://decrypt.co/feed", }
- src/cryptonewsmcp/utils.py:4-24 (helper)Async utility function to fetch text content from a URL using httpx. Called by recent_news to retrieve the RSS feed data.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