get_rss_feed
Retrieve and format cryptocurrency RSS feed content into Markdown with titles, links, dates, and summaries for up to 10 latest entries.
Instructions
Retrieve the content of the specified RSS feed.
Parameters:
feed_url (str): The URL of the RSS feed to fetch (e.g., 'https://cointelegraph.com/rss').
ctx (Context, optional): MCP context for logging or progress reporting.
Returns:
str: A formatted Markdown string containing the feed title and up to 10 latest entries with titles, links, publication dates, and summaries converted from HTML to plain text.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| feed_url | Yes |
Implementation Reference
- src/crypto_rss_mcp/cli.py:63-100 (handler)The @mcp.tool()-decorated handler function implementing the get_rss_feed tool. Fetches RSS feed using helper, processes up to 10 entries, converts HTML summaries to plain text, and returns formatted Markdown output. Includes input/output schema in docstring and type annotations.@mcp.tool() async def get_rss_feed(feed_url: str, ctx: Context = None) -> str: """ Retrieve the content of the specified RSS feed. Parameters: feed_url (str): The URL of the RSS feed to fetch (e.g., 'https://cointelegraph.com/rss'). ctx (Context, optional): MCP context for logging or progress reporting. Returns: str: A formatted Markdown string containing the feed title and up to 10 latest entries with titles, links, publication dates, and summaries converted from HTML to plain text. """ ctx.info(f"Fetching RSS feed from {feed_url}") feed = await fetch_rss_feed(feed_url) entries = feed.entries[:10] # Limit to the latest 10 entries # Initialize html2text converter h = html2text.HTML2Text() h.body_width = 0 # Disable line wrapping h.ignore_links = True # Ignore links in summary h.ignore_images = True # Ignore images in summary h.inline_links = False # Ensure links are not embedded in text h.mark_code = False # Disable code block markers h.use_automatic_links = False # Disable automatic link references h.skip_internal_headers = True # Ignores <h1>-<h6> tags result = f"# Feed: {feed.feed.title}\n\n" for i, entry in enumerate(entries): # Convert HTML summary to plain text summary_text = h.handle(entry.summary).strip() # Post-process to demote ## headers to ### in summary summary_text = re.sub(r'^\s*##\s+(.+)$', r'### \1', summary_text, flags=re.MULTILINE) result += f"## Entry {i + 1}\n" result += f"- **Title**: {entry.title}\n" result += f"- **Link**: [{entry.link}]({entry.link})\n" result += f"- **Published**: {entry.published}\n" result += f"- **Summary**: {summary_text}\n\n" return result
- src/crypto_rss_mcp/cli.py:55-60 (helper)Supporting helper function that asynchronously fetches the RSS feed content via httpx and parses it using feedparser, used by the main get_rss_feed handler.async def fetch_rss_feed(url: str) -> feedparser.FeedParserDict: """Fetch and parse an RSS feed from the specified URL.""" async with httpx.AsyncClient() as client: response = await client.get(url) response.raise_for_status() return feedparser.parse(response.text)
- src/crypto_rss_mcp/cli.py:63-63 (registration)The @mcp.tool() decorator registers the get_rss_feed function as an MCP tool under that name.@mcp.tool()