get_trending_repos
Discover trending AI/ML repositories on GitHub by time period, programming language, and result count to track research progress and popular projects.
Instructions
Get trending AI/ML repositories on GitHub
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| period | No | Time period for trending | weekly |
| language | No | Filter by programming language | |
| max_results | No | Maximum number of results |
Input Schema (JSON Schema)
{
"properties": {
"language": {
"description": "Filter by programming language",
"type": "string"
},
"max_results": {
"default": 25,
"description": "Maximum number of results",
"type": "integer"
},
"period": {
"default": "weekly",
"description": "Time period for trending",
"enum": [
"daily",
"weekly",
"monthly"
],
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/ai_research_mcp/server.py:436-456 (handler)The primary handler function for the 'get_trending_repos' tool. It handles caching, calls the GitHub client helper, and formats the results as markdown.async def _get_trending_repos( self, period: str = "weekly", language: Optional[str] = None, max_results: int = 25, ) -> str: """Get trending repositories.""" cache_key = f"github_trending_{period}_{language}" cached = self.cache.get(cache_key, 3600) # 1 hour cache if cached: repos = cached else: repos = await asyncio.to_thread( self.github.get_trending_repositories, period=period, language=language, max_results=max_results, ) self.cache.set(cache_key, repos) return self._format_repos(repos)
- src/ai_research_mcp/server.py:135-158 (registration)Registration of the 'get_trending_repos' tool in the list_tools() handler, including description and input schema.Tool( name="get_trending_repos", description="Get trending AI/ML repositories on GitHub", inputSchema={ "type": "object", "properties": { "period": { "type": "string", "enum": ["daily", "weekly", "monthly"], "description": "Time period for trending", "default": "weekly", }, "language": { "type": "string", "description": "Filter by programming language", }, "max_results": { "type": "integer", "description": "Maximum number of results", "default": 25, }, }, }, ),
- Supporting helper method in GithubClient that implements the trending logic by searching recent repositories with AI topics, minimum stars, sorted by stars.def get_trending_repositories( self, period: str = "daily", language: Optional[str] = None, max_results: int = 25, ) -> List[Dict]: """Get trending repositories. Note: GitHub API doesn't have official trending endpoint, so we approximate by searching for recently created/updated repos with high stars. Args: period: 'daily', 'weekly', or 'monthly' language: Programming language filter max_results: Maximum number of results Returns: List of repository dictionaries """ # Map period to days period_days = { "daily": 1, "weekly": 7, "monthly": 30, } days = period_days.get(period, 7) # Search for recently starred repos with AI topics return self.search_repositories( topics=self.AI_TOPICS[:5], # Use top 5 most common topics min_stars=100, language=language, pushed_since=f"{days}d", sort_by="stars", max_results=max_results, )