prediction_markets_trending_topics
Identify trending topics from Polymarket prediction markets based on 24-hour volume for portfolio sentiment analysis. Use retrieved topic slugs to fetch related markets for deeper insights.
Instructions
Use when analysing a user’s portfolio and you need external sentiment from prediction markets.
Retrieves today’s trending Polymarket topics (ordered by 24-hour volume).
Pass any slug from this list to prediction_markets_markets_by_topic
to pull the individual markets for that theme.
Returns
str A JSON array (string) of topic slugs ordered by 24-hour volume, e.g. '["Trump-Presidency", "Oil-Prices", "Iran"]'.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
Implementation Reference
- main.py:8-25 (handler)The main handler function for the 'prediction_markets_trending_topics' tool. Decorated with @mcp.tool, it calls the helper poly.trending() to fetch trending topics and serializes the result as a JSON string.@mcp.tool async def prediction_markets_trending_topics() -> str: """ Use when analysing a user’s portfolio and you need external sentiment from prediction markets. Retrieves today’s trending Polymarket topics (ordered by 24-hour volume). Pass any slug from this list to `prediction_markets_markets_by_topic` to pull the individual markets for that theme. Returns ------- str A JSON array (string) of topic slugs ordered by 24-hour volume, e.g. '["Trump-Presidency", "Oil-Prices", "Iran"]'. """ return json.dumps(await poly.trending())
- polymarket.py:19-30 (helper)Supporting utility function 'trending()' that performs web scraping on Polymarket.com using Playwright to extract the list of current trending topic slugs.async def trending() -> list[str]: async with async_playwright() as p: browser = await p.chromium.launch(headless=True) page = await browser.new_page() await page.goto("https://polymarket.com", wait_until="domcontentloaded") await page.wait_for_selector("div[role='tablist'] button[role='tab']") topics = await page.locator( "div[role='tablist'] button[role='tab']" ).all_inner_texts() await browser.close() return [t.strip() for t in topics if t.strip() != "All"]