get_trending_md_doc
Retrieve a Markdown-formatted document of CoinGecko's trending cryptocurrencies, including headers, tables, and metadata, for detailed analysis and data extraction.
Instructions
Retrieve a Markdown document containing the CoinGecko trending cryptocurrencies page.
Returns:
A string containing a Markdown-formatted document representing the full CoinGecko trending page.
The document includes:
- Page headers and introductory text.
- A table of trending cryptocurrencies with columns such as Rank, Name, Symbol, Price,
1h Change, 24h Change, 7d Change, 24h Volume, and Market Cap.
- Additional page content like footers, navigation, or metadata.
The trending coins table is embedded within the document and can be extracted for analysis.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- main.py:39-53 (handler)The handler function for the 'get_trending_md_doc' tool, decorated with @mcp.tool(). It invokes the scrape_trending_coins helper to retrieve and convert the CoinGecko trending page to Markdown format.@mcp.tool() async def get_trending_md_doc() -> str: """ Retrieve a Markdown document containing the CoinGecko trending cryptocurrencies page. Returns: A string containing a Markdown-formatted document representing the full CoinGecko trending page. The document includes: - Page headers and introductory text. - A table of trending cryptocurrencies with columns such as Rank, Name, Symbol, Price, 1h Change, 24h Change, 7d Change, 24h Volume, and Market Cap. - Additional page content like footers, navigation, or metadata. The trending coins table is embedded within the document and can be extracted for analysis. """ return await scrape_trending_coins()
- main.py:9-36 (helper)Helper function that performs the web scraping using Playwright to fetch the CoinGecko trending cryptocurrencies page, converts the HTML to Markdown using html2text, and returns the Markdown string.async def scrape_trending_coins() -> str: """Scrape the CoinGecko trending page and convert it to Markdown.""" async with async_playwright() as p: browser = await p.chromium.launch( headless=True ) context = await browser.new_context( user_agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36', permissions=['geolocation', 'notifications'] ) page = await context.new_page() await page.goto("https://www.coingecko.com/en/highlights/trending-crypto") # Wait for the page to load key content await page.wait_for_selector("table", timeout=60000) # Get the full HTML content of the page html_content = await page.content() # Convert HTML to Markdown using html2text h = html2text.HTML2Text() h.ignore_links = True # Skip links h.ignore_images = True # Skip images h.body_width = 0 # Disable line wrapping markdown = h.handle(html_content) await browser.close() return markdown
- main.py:39-39 (registration)The @mcp.tool() decorator registers the get_trending_md_doc function as an MCP tool.@mcp.tool()