get_trending_md_doc
Retrieve trending cryptocurrency data from CoinGecko as a Markdown document for analysis, including price changes, volume, and market cap in a structured table format.
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.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "get_trending_md_doc"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- main.py:39-53 (handler)The handler function for the 'get_trending_md_doc' tool, registered via @mcp.tool() decorator. It invokes the helper function scrape_trending_coins() to scrape the CoinGecko trending page and return it as Markdown.
@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)Supporting utility function that performs web scraping using Playwright to fetch the trending cryptocurrencies from CoinGecko and converts the HTML to Markdown format using html2text.
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