get_top_topics
Fetch top-performing forum topics by engagement score for specified time periods like daily, weekly, monthly, quarterly, or yearly to identify valuable discussions and trending content.
Instructions
Fetch top-performing topics for a specific time period.
Args:
period: Time window for ranking. Must be one of:
- "daily": Top topics from today
- "weekly": Top topics this week
- "monthly": Top topics this month (default)
- "quarterly": Top topics this quarter
- "yearly": Top topics this year
page: Page number for pagination (0-indexed). Use page=1 to get more topics.
Use this to:
- Find the most valuable discussions in a time range
- Research historically important threads
- Identify evergreen popular content
Returns TopicSummary objects sorted by engagement score.
Example: Use "yearly" to find the most impactful discussions,
or "daily" to see what's trending today.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| period | No | Time window for ranking: 'daily', 'weekly', 'monthly' (default), 'quarterly', or 'yearly' | monthly |
| page | No | Page number for pagination (0-indexed, default: 0) |
Implementation Reference
- The primary MCP tool handler for 'get_top_topics', decorated with @mcp.tool(). Defines input parameters (period, page) with descriptions and validation via Pydantic Field. Includes comprehensive docstring for usage. Delegates to DiscourseClient.get_top_topics() via get_client() for execution. Return type annotated as list[TopicSummary].@mcp.tool() def get_top_topics( period: Annotated[ str, Field( default="monthly", description="Time window for ranking: 'daily', 'weekly', 'monthly' (default), 'quarterly', or 'yearly'", ), ] = "monthly", page: Annotated[ int | None, Field(default=None, description="Page number for pagination (0-indexed, default: 0)"), ] = None, ) -> list[TopicSummary]: """ Fetch top-performing topics for a specific time period. Args: period: Time window for ranking. Must be one of: - "daily": Top topics from today - "weekly": Top topics this week - "monthly": Top topics this month (default) - "quarterly": Top topics this quarter - "yearly": Top topics this year page: Page number for pagination (0-indexed). Use page=1 to get more topics. Use this to: - Find the most valuable discussions in a time range - Research historically important threads - Identify evergreen popular content Returns TopicSummary objects sorted by engagement score. Example: Use "yearly" to find the most impactful discussions, or "daily" to see what's trending today. """ return get_client().get_top_topics(period=period, page=page)
- src/uscardforum/api/topics.py:66-92 (helper)Core API helper in TopicsAPI class that implements the HTTP request to '/top.json' endpoint with period and page parameters. Validates period, parses JSON response, extracts topics, and maps to TopicSummary models.def get_top_topics( self, period: str = "monthly", *, page: int | None = None ) -> list[TopicSummary]: """Fetch top topics for a time period. Args: period: One of 'daily', 'weekly', 'monthly', 'quarterly', 'yearly' page: Page number for pagination (0-indexed, default: 0) Returns: List of top topic summaries """ allowed = {"daily", "weekly", "monthly", "quarterly", "yearly"} if period not in allowed: raise ValueError(f"period must be one of {sorted(list(allowed))}") params: dict[str, Any] = {"period": period} if page is not None: params["page"] = int(page) payload = self._get( "/top.json", params=params, headers={"Accept": "application/json, text/plain, */*"}, ) topics = payload.get("topic_list", {}).get("topics", []) return [TopicSummary(**t) for t in topics]
- src/uscardforum/client.py:185-198 (helper)DiscourseClient wrapper method that calls TopicsAPI.get_top_topics() and enriches the results with category names using _enrich_with_categories() for better usability.def get_top_topics( self, period: str = "monthly", *, page: int | None = None ) -> list[TopicSummary]: """Fetch top topics for a time period. Args: period: One of 'daily', 'weekly', 'monthly', 'quarterly', 'yearly' page: Page number for pagination (0-indexed, default: 0) Returns: List of top topic summaries """ topics = self._topics.get_top_topics(period=period, page=page) return self._enrich_with_categories(topics)
- src/uscardforum/server_tools/__init__.py:25-26 (registration)Import statement in server_tools/__init__.py that exposes get_top_topics for use in the MCP server, enabling automatic registration via @mcp.tool() decorator.from .topics import get_hot_topics, get_new_topics, get_top_topics from .search import search_forum
- src/uscardforum/server.py:26-26 (registration)Import of get_top_topics in the main server entrypoint file, ensuring the tool is loaded and registered when the MCP server starts.get_top_topics,