get_crypto_rss_list
Retrieve cryptocurrency RSS feeds from OPML files, optionally filtered by keyword to find relevant market updates and news sources.
Instructions
Retrieve a list of available cryptocurrency RSS feeds from a local or remote OPML file, optionally filtered by keyword.
Parameters:
keyword (str, optional): Filter feeds where the keyword appears in the description or category (case-insensitive).
opml_file (str, optional): Path to a local OPML file to read feeds from. If not provided, fetches from the remote OPML URL.
Returns:
str: A formatted string listing each RSS feed URL, its description, and category, parsed from the OPML file.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keyword | No | ||
| opml_file | No | RAW.opml |
Implementation Reference
- src/crypto_rss_mcp/cli.py:103-103 (registration)Registers the get_crypto_rss_list tool with the FastMCP server.@mcp.tool()
- src/crypto_rss_mcp/cli.py:104-114 (schema)Defines the input parameters, docstring describing usage, parameters, and return type for the tool.async def get_crypto_rss_list(keyword: str = None, opml_file: str = "RAW.opml") -> str: """ Retrieve a list of available cryptocurrency RSS feeds from a local or remote OPML file, optionally filtered by keyword. Parameters: keyword (str, optional): Filter feeds where the keyword appears in the description or category (case-insensitive). opml_file (str, optional): Path to a local OPML file to read feeds from. If not provided, fetches from the remote OPML URL. Returns: str: A formatted string listing each RSS feed URL, its description, and category, parsed from the OPML file. """
- src/crypto_rss_mcp/cli.py:115-129 (handler)Executes the tool logic: loads feeds from OPML, filters by keyword if provided, formats and returns the list as a string.feeds = load_rss_feeds_from_opml(opml_file=opml_file) if keyword: keyword = keyword.lower() feeds = [ feed for feed in feeds if keyword in feed['description'].lower() or keyword in (feed['category'] or '').lower() ] result = "Available Cryptocurrency RSS Feeds:\n\n" if not feeds: result += "No feeds found matching the keyword.\n" for feed in feeds: result += f"Category: {feed['category'] or 'Uncategorized'}\n" result += f"URL: {feed['url']}\n" result += f"Description: {feed['description']}\n\n" return result
- src/crypto_rss_mcp/cli.py:14-54 (helper)Helper function called by the handler to parse the OPML file and extract list of RSS feeds with URLs, descriptions, and categories.def load_rss_feeds_from_opml(opml_file: str) -> List[dict]: """Load RSS feeds from an OPML file.""" try: outline = opml.parse(opml_file) feeds = [] def parse_outline(items, category: str = ""): for item in items: print(item, hasattr(item, "__iter__")) if hasattr(item, "xmlUrl") and item.xmlUrl: # Collect feed with URL, description, and optional category feeds.append({ "url": item.xmlUrl, "description": item.title or item.text or "No description available", "category": category }) # Recursively process nested outlines def parse_outline(items, category: str = ""): for item in items: if hasattr(item, "xmlUrl") and item.xmlUrl: # Collect feed with URL, description, and optional category feeds.append({ "url": item.xmlUrl, "description": item.title or item.text or "No description available", "category": category }) # Recursively process nested outlines (children) try: # Iterate over item as a container of child outlines parse_outline(item, category=item.title or item.text or category) except TypeError: # If item is not iterable, skip to next item continue # Start parsing from top-level outlines parse_outline(outline) return feeds except FileNotFoundError: raise RuntimeError(f"OPML file not found: {OPML_FILE}") except Exception as e: raise RuntimeError(f"Failed to parse OPML file: {str(e)}")